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


Python CloudStackProvider.change_service_for_vm方法代码示例

本文整理汇总了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
开发者ID:flaviohenriqu,项目名称:database-as-a-service,代码行数:32,代码来源:resize_vm.py

示例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
开发者ID:mbergo,项目名称:database-as-a-service,代码行数:37,代码来源:resize_vm.py


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