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


Python InfrastructureManager.terminate_instances方法代码示例

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


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

示例1: terminate_instances

# 需要导入模块: from infrastructure_manager import InfrastructureManager [as 别名]
# 或者: from infrastructure_manager.InfrastructureManager import terminate_instances [as 别名]
  def terminate_instances(self, prefix, blocking):
    i = InfrastructureManager(blocking=blocking)

    params1 = {'infrastructure': prefix}
    self.assertRaises(AgentConfigurationException, i.terminate_instances, params1, 'secret')

    params2 = {
      'credentials': {
        'a': 'b', 'EC2_URL': 'http://ec2.url.com',
        'EC2_ACCESS_KEY': 'access_key', 'EC2_SECRET_KEY': 'secret_key'},
      'infrastructure': prefix,
      'instance_ids': ['i-12345'],
      'region' : 'my-zone-1',
      'keyname': 'bookeyname'
    }

    reservation = Reservation()
    instance = flexmock(name='instance', private_dns_name='private-ip',
                        public_dns_name='public-ip', id='i-id', state='terminated',
                        key_name='bookeyname', ip_address='public-ip',
                        private_ip_address='private-ip')
    reservation.instances = [instance]
    self.fake_ec2.should_receive('get_all_instances').and_return([reservation])

    flexmock(i).should_receive('_InfrastructureManager__kill_vms')
    result = i.terminate_instances(params2, 'secret')
    if not blocking:
      time.sleep(.1)
    self.assertTrue(result['success'])
开发者ID:tmarballi,项目名称:appscale,代码行数:31,代码来源:test_ec2_agent.py

示例2: terminate_instances

# 需要导入模块: from infrastructure_manager import InfrastructureManager [as 别名]
# 或者: from infrastructure_manager.InfrastructureManager import terminate_instances [as 别名]
  def terminate_instances(self, prefix, blocking):
    i = InfrastructureManager(blocking=blocking)

    params1 = {'infrastructure': prefix}
    result1 = i.terminate_instances(params1, 'secret')
    self.assertFalse(result1['success'])
    self.assertEquals(result1['reason'], 'no credentials')

    params2 = {
      'credentials': {'a': 'b', 'EC2_URL': 'http://ec2.url.com',
                      'EC2_ACCESS_KEY': 'access_key', 'EC2_SECRET_KEY': 'secret_key'},
      'infrastructure': prefix,
      'instance_ids': ['i-12345']
    }
    result2 = i.terminate_instances(params2, 'secret')
    if not blocking:
      time.sleep(2)
    self.assertTrue(result2['success'])
开发者ID:GavinHwa,项目名称:appscale,代码行数:20,代码来源:test_ec2_agent.py

示例3: stopMachines

# 需要导入模块: from infrastructure_manager import InfrastructureManager [as 别名]
# 或者: from infrastructure_manager.InfrastructureManager import terminate_instances [as 别名]
    def stopMachines(self, params, block=False):
        """
        This method would terminate all the  instances associated with the account
	that have a keyname prefixed with stochss (all instances created by the backend service)
	params must contain credentials key/value
        """
        try:
            i = InfrastructureManager(blocking=block)
            res = i.terminate_instances(params, backendservices.KEYPREFIX)
            return True
        except Exception, e:
            logging.error("Terminate machine failed with error : %s", str(e))
            return False
开发者ID:JWW81,项目名称:stochss,代码行数:15,代码来源:backendservice.py

示例4: stopMachines

# 需要导入模块: from infrastructure_manager import InfrastructureManager [as 别名]
# 或者: from infrastructure_manager.InfrastructureManager import terminate_instances [as 别名]
 def stopMachines(self, params):
     '''
     This method would terminate all the  instances associated with the account
     It expects the following two fields in the  parameter argument
     params ={"infrastructure":"ec2",
          'credentials':{"EC2_ACCESS_KEY":"______________", 
           "EC2_SECRET_KEY":"__________"},
               }
     '''
     try:
         i = InfrastructureManager(blocking=True)
         res = i.terminate_instances(params)
         print str(res)
         return True
     except Exception, e:
         logging.error("Terminate machine failed with error : %s", str(e))
         return False
开发者ID:shellander,项目名称:stochss,代码行数:19,代码来源:backendservice.py

示例5: stopMachines

# 需要导入模块: from infrastructure_manager import InfrastructureManager [as 别名]
# 或者: from infrastructure_manager.InfrastructureManager import terminate_instances [as 别名]
    def stopMachines(self, params, block=False):
        '''
        This method would terminate all the  instances associated with the account
	that have a keyname prefixed with stochss (all instances created by the backend service)
	params must contain credentials key/value
        '''
        key_prefix = self.KEYPREFIX
        if "key_prefix" in params and not params["key_prefix"].startswith(key_prefix):
            key_prefix += params["key_prefix"]
        elif "key_prefix" in params: 
            key_prefix = params["key_prefix"]
        try:
            logging.info("Stopping compute nodes with key_prefix: {0}".format(key_prefix))
            i = InfrastructureManager(blocking=block)
            res = i.terminate_instances(params,key_prefix)
            return True
        except Exception, e:
            logging.error("Terminate machine failed with error : %s", str(e))
            return False
开发者ID:JohnAbel,项目名称:stochss,代码行数:21,代码来源:backendservice.py


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