当前位置: 首页>>代码示例>>Python>>正文


Python AppScaleTools.add_instances方法代码示例

本文整理汇总了Python中appscale.tools.appscale_tools.AppScaleTools.add_instances方法的典型用法代码示例。如果您正苦于以下问题:Python AppScaleTools.add_instances方法的具体用法?Python AppScaleTools.add_instances怎么用?Python AppScaleTools.add_instances使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在appscale.tools.appscale_tools.AppScaleTools的用法示例。


在下文中一共展示了AppScaleTools.add_instances方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_add_nodes_in_virt_deployment

# 需要导入模块: from appscale.tools.appscale_tools import AppScaleTools [as 别名]
# 或者: from appscale.tools.appscale_tools.AppScaleTools import add_instances [as 别名]
  def test_add_nodes_in_virt_deployment(self):
    # don't use a 192.168.X.Y IP here, since sometimes we set our virtual
    # machines to boot with those addresses (and that can mess up our tests).
    ips_yaml = """
database: 1.2.3.4
zookeeper: 1.2.3.4
appengine: 1.2.3.4
    """

    # mock out reading the yaml file, and slip in our own
    fake_yaml_file = flexmock(name='fake_yaml')
    fake_yaml_file.should_receive('read').and_return(ips_yaml)
    builtins = flexmock(sys.modules['__builtin__'])
    builtins.should_call('open')  # set the fall-through
    builtins.should_receive('open').with_args('/tmp/boo.yaml', 'r') \
      .and_return(fake_yaml_file)

    # and pretend we're on a virtualized cluster
    locations_yaml = yaml.dump({
      "infrastructure" : "xen"
    })

    # say that the ssh key works
    flexmock(subprocess)
    subprocess.should_receive('Popen').with_args(re.compile('ssh'),
      shell=True, stdout=self.fake_temp_file, stderr=subprocess.STDOUT,
      stdin=self.fake_input_file) \
      .and_return(self.success)

    # mock out reading the locations.json file, and slip in our own json
    flexmock(os.path)
    os.path.should_call('exists')  # set the fall-through
    os.path.should_receive('exists').with_args(
      LocalState.get_locations_json_location(self.keyname)).and_return(True)

    fake_nodes_json = flexmock(name="fake_nodes_json")
    fake_nodes_json.should_receive('read').and_return(json.dumps({
      "node_info": [{ "public_ip": "public1",
                      "private_ip": "private1",
                      "jobs": ["shadow", "login"] }]}))
    builtins.should_receive('open').with_args(
      LocalState.get_locations_json_location(self.keyname), 'r') \
      .and_return(fake_nodes_json)

    # mock out writing the secret key to ~/.appscale, as well as reading it
    # later
    secret_key_location = LocalState.get_secret_key_location(self.keyname)
    fake_secret = flexmock(name="fake_secret")
    fake_secret.should_receive('read').and_return('the secret')
    builtins.should_receive('open').with_args(secret_key_location, 'r') \
      .and_return(fake_secret)

    # mock out the SOAP call to the AppController and assume it succeeded
    json_node_info = json.dumps(yaml.safe_load(ips_yaml))
    fake_appcontroller = flexmock(name='fake_appcontroller')
    fake_appcontroller.should_receive('start_roles_on_nodes') \
      .with_args(json_node_info, 'the secret').and_return('OK')
    flexmock(SOAPpy)
    SOAPpy.should_receive('SOAPProxy').with_args('https://public1:17443') \
      .and_return(fake_appcontroller)

    argv = [
      "--ips", "/tmp/boo.yaml",
      "--keyname", self.keyname
    ]
    options = ParseArgs(argv, self.function).args
    AppScaleTools.add_instances(options)
开发者ID:Sunnepah,项目名称:appscale-tools,代码行数:69,代码来源:test_appscale_add_instances.py


注:本文中的appscale.tools.appscale_tools.AppScaleTools.add_instances方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。