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


Python CloudStackProvider.destroy_virtual_machine方法代码示例

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


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

示例1: do

# 需要导入模块: from dbaas_cloudstack.provider import CloudStackProvider [as 别名]
# 或者: from dbaas_cloudstack.provider.CloudStackProvider import destroy_virtual_machine [as 别名]
    def do(self, workflow_dict):
        try:

            cs_credentials = get_credentials_for(
                environment=workflow_dict['source_environment'],
                credential_type=CredentialType.CLOUDSTACK)

            cs_provider = CloudStackProvider(credentials=cs_credentials)

            for source_host in workflow_dict['source_hosts']:
                host_attr = HostAttr.objects.get(host=source_host)
                LOG.info("Destroying virtualmachine %s" % host_attr.vm_id)

                cs_provider.destroy_virtual_machine(
                    project_id=cs_credentials.project,
                    environment=workflow_dict['source_environment'],
                    vm_id=host_attr.vm_id)

                host_attr.delete()
                LOG.info("HostAttr deleted!")

                source_host.delete()
                LOG.info("Source host deleted")

            return True
        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0020)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False
开发者ID:flaviohenriqu,项目名称:database-as-a-service,代码行数:34,代码来源:remove_vms.py

示例2: undo

# 需要导入模块: from dbaas_cloudstack.provider import CloudStackProvider [as 别名]
# 或者: from dbaas_cloudstack.provider.CloudStackProvider import destroy_virtual_machine [as 别名]
    def undo(self, workflow_dict):
        LOG.info("Running undo...")
        try:

            cs_credentials = get_credentials_for(
                environment=workflow_dict['environment'],
                credential_type=CredentialType.CLOUDSTACK)

            cs_provider = CloudStackProvider(credentials=cs_credentials)

            instances = workflow_dict['databaseinfra'].instances.all()

            if not instances:

                for vm_id in workflow_dict['vms_id']:
                    cs_provider.destroy_virtual_machine(
                    project_id=cs_credentials.project,
                    environment=workflow_dict['environment'],
                    vm_id=vm_id)


                for host in workflow_dict['hosts']:
                    host_attr = HostAttr.objects.filter(host=host)

                    host.delete()
                    LOG.info("Host deleted!")

                    if host_attr:
                        host_attr[0].delete()
                        LOG.info("HostAttr deleted!")

            for instance in instances:
                host = instance.hostname

                host_attr = HostAttr.objects.get(host=host)

                LOG.info("Destroying virtualmachine %s" % host_attr.vm_id)

                cs_provider.destroy_virtual_machine(
                    project_id=cs_credentials.project,
                    environment=workflow_dict['environment'],
                    vm_id=host_attr.vm_id)

                host_attr.delete()
                LOG.info("HostAttr deleted!")

                instance.delete()
                LOG.info("Instance deleted")

                host.delete()
                LOG.info("Host deleted!")

            return True
        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0011)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False
开发者ID:mbergo,项目名称:database-as-a-service,代码行数:62,代码来源:create_virtualmachines.py

示例3: undo

# 需要导入模块: from dbaas_cloudstack.provider import CloudStackProvider [as 别名]
# 或者: from dbaas_cloudstack.provider.CloudStackProvider import destroy_virtual_machine [as 别名]
    def undo(self, workflow_dict):
        LOG.info("Running undo...")
        try:
            cs_credentials = get_credentials_for(
                environment=workflow_dict['target_environment'],
                credential_type=CredentialType.CLOUDSTACK)

            cs_provider = CloudStackProvider(credentials=cs_credentials)

            for source_instance in workflow_dict['source_instances']:
                source_instance.future_instance = None
                source_instance.save()
                LOG.info("Source instance updated")

            for target_instance in workflow_dict['target_instances']:
                target_instance.delete()
                LOG.info("Target instance deleted")

            for source_host in workflow_dict['source_hosts']:
                source_host.future_host = None
                source_host.save()
                LOG.info("Source host updated")

            for target_host in workflow_dict['target_hosts']:
                host_attr = HostAttr.objects.get(host=target_host)
                LOG.info("Destroying virtualmachine %s" % host_attr.vm_id)

                cs_provider.destroy_virtual_machine(
                    project_id=cs_credentials.project,
                    environment=workflow_dict['target_environment'],
                    vm_id=host_attr.vm_id)

                host_attr.delete()
                LOG.info("HostAttr deleted!")

                target_host.delete()
                LOG.info("Target host deleted")

            return True
        except Exception:
            traceback = full_stack()

            workflow_dict['exceptions']['error_codes'].append(DBAAS_0020)
            workflow_dict['exceptions']['traceback'].append(traceback)

            return False
开发者ID:tsunli,项目名称:database-as-a-service,代码行数:48,代码来源:create_virtualmachines.py


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