本文整理汇总了Python中dbaas_cloudstack.provider.CloudStackProvider.change_service_for_vm方法的典型用法代码示例。如果您正苦于以下问题:Python CloudStackProvider.change_service_for_vm方法的具体用法?Python CloudStackProvider.change_service_for_vm怎么用?Python CloudStackProvider.change_service_for_vm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dbaas_cloudstack.provider.CloudStackProvider
的用法示例。
在下文中一共展示了CloudStackProvider.change_service_for_vm方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: undo
# 需要导入模块: from dbaas_cloudstack.provider import CloudStackProvider [as 别名]
# 或者: from dbaas_cloudstack.provider.CloudStackProvider import change_service_for_vm [as 别名]
def undo(self, workflow_dict):
try:
original_cloudstackpack = workflow_dict['original_cloudstackpack']
environment = workflow_dict['environment']
cs_credentials = get_credentials_for(
environment=environment, credential_type=CredentialType.CLOUDSTACK)
cs_provider = CloudStackProvider(credentials=cs_credentials)
original_serviceofferingid = original_cloudstackpack.offering.serviceofferingid
if workflow_dict['offering_changed']:
host = workflow_dict['host']
host_csattr = HostAttr.objects.get(host=host)
offering_changed = cs_provider.change_service_for_vm(
vm_id=host_csattr.vm_id, serviceofferingid=original_serviceofferingid)
if not offering_changed:
raise Exception("Could not change offering for Host {}".format(host))
else:
LOG.info('No resize to instance {}'.format(workflow_dict['instance']))
return True
except Exception:
traceback = full_stack()
workflow_dict['exceptions']['error_codes'].append(DBAAS_0015)
workflow_dict['exceptions']['traceback'].append(traceback)
return False
示例2: do
# 需要导入模块: from dbaas_cloudstack.provider import CloudStackProvider [as 别名]
# 或者: from dbaas_cloudstack.provider.CloudStackProvider import change_service_for_vm [as 别名]
def do(self, workflow_dict):
try:
database = workflow_dict['database']
cloudstackpack = workflow_dict['cloudstackpack']
instances_detail = workflow_dict['instances_detail']
environment = workflow_dict['environment']
cs_credentials = get_credentials_for(environment = environment, credential_type = CredentialType.CLOUDSTACK)
cs_provider = CloudStackProvider(credentials = cs_credentials)
serviceofferingid = cloudstackpack.offering.serviceofferingid
for instance_detail in instances_detail:
instance = instance_detail['instance']
host = instance.hostname
host_csattr = HostAttr.objects.get(host=host)
offering_changed = cs_provider.change_service_for_vm(vm_id = host_csattr.vm_id, serviceofferingid = serviceofferingid)
if not offering_changed:
raise Exception, "Could not change offering for Host {}".format(host)
instance_detail['offering_changed'] = True
LOG.info('Updating offering DatabaseInfra.')
databaseinfraoffering = DatabaseInfraOffering.objects.get(databaseinfra = database.databaseinfra)
databaseinfraoffering.offering = cloudstackpack.offering
databaseinfraoffering.save()
return True
except Exception:
traceback = full_stack()
workflow_dict['exceptions']['error_codes'].append(DBAAS_0015)
workflow_dict['exceptions']['traceback'].append(traceback)
return False