本文整理汇总了Python中dbaas_cloudstack.provider.CloudStackProvider.start_virtual_machine方法的典型用法代码示例。如果您正苦于以下问题:Python CloudStackProvider.start_virtual_machine方法的具体用法?Python CloudStackProvider.start_virtual_machine怎么用?Python CloudStackProvider.start_virtual_machine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dbaas_cloudstack.provider.CloudStackProvider
的用法示例。
在下文中一共展示了CloudStackProvider.start_virtual_machine方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start_vm
# 需要导入模块: from dbaas_cloudstack.provider import CloudStackProvider [as 别名]
# 或者: from dbaas_cloudstack.provider.CloudStackProvider import start_virtual_machine [as 别名]
def start_vm(workflow_dict):
try:
environment = workflow_dict['environment']
cs_credentials = get_credentials_for(environment = environment, credential_type = CredentialType.CLOUDSTACK)
cs_provider = CloudStackProvider(credentials = cs_credentials)
instances_detail = workflow_dict['instances_detail']
for instance_detail in instances_detail:
instance = instance_detail['instance']
host = instance.hostname
host_csattr = HostAttr.objects.get(host=host)
started = cs_provider.start_virtual_machine(vm_id = host_csattr.vm_id)
if not started:
raise Exception, "Could not start host {}".format(host)
for instance_detail in instances_detail:
instance = instance_detail['instance']
host = instance.hostname
host_csattr = HostAttr.objects.get(host=host)
host_ready = check_ssh(server=host.address, username=host_csattr.vm_user, password=host_csattr.vm_password, wait=5, interval=10)
if not host_ready:
error = "Host %s is not ready..." % host
LOG.warn(error)
raise Exception, error
return True
except Exception, e:
traceback = full_stack()
workflow_dict['exceptions']['error_codes'].append(DBAAS_0015)
workflow_dict['exceptions']['traceback'].append(traceback)
return False