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


Python VM.destroy方法代码示例

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


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

示例1: save_and_shutdown

# 需要导入模块: from cm.models.vm import VM [as 别名]
# 或者: from cm.models.vm.VM import destroy [as 别名]
    def save_and_shutdown(farm, name, description):
        """
        """
        from cm.models.vm import VM

        if farm.state == farm_states["failed"]:
            raise CMException("farm_wrong_state")

        head_vm = farm.head
        try:
            VM.save_and_shutdown(head_vm.user_id, head_vm, name, description)
        except Exception:
            CMException("farm_save")

        node_vms = []
        if farm.state == farm_states["init_head"]:
            for vm in farm.vms.all():
                if vm.is_head():
                    continue
                vm.release_resources()
                vm.state = vm_states["closed"]
        else:
            for vm in farm.vms.all():
                if not vm.is_head():
                    node_vms.append(vm)
            VM.destroy(node_vms)

        try:
            farm.state = farm_states["closed"]
            farm.save()
        except:
            CMException("farm_save")
开发者ID:pojoba02,项目名称:cc1,代码行数:34,代码来源:farm.py

示例2: destroy

# 需要导入模块: from cm.models.vm import VM [as 别名]
# 或者: from cm.models.vm.VM import destroy [as 别名]
    def destroy(farms):
        """
        Destroyes farms' VMs (Head and Worker Nodes of each farm) without saving them.

        @parameter{farms,list} list of farms to destroy

        @response{list(dict)} list of statuses returned by destroyed VMs

        @raises{farm_wrong_state,CMException}
        @raises{farm_destroy,CMException}
        """
        from cm.models.vm import VM

        vm_resp = []
        for farm in farms:
            # those are states in which farm can not be destroyed
            if farm.state in (farm_states["init"], farm_states["closing"], farm_states["closed"]):
                raise CMException("farm_wrong_state")

        for farm in farms:
            # stop all threads
            if farm.state == farm_states["init_head"]:
                for vm in farm.vms.all():
                    if vm.is_head():
                        continue
                    vm.release_resources()
                    vm.state = vm_states["closed"]
                    vm.stop_time = datetime.now()
                    vm.save()
                    log.debug(vm.user.id, "vm state %s" % vm.state)
                r = VM.destroy([farm.head])
            else:
                for vm in farm.vms.all():
                    if vm.state == vm_states["init"]:
                        raise CMException("farm_wrong_state")
                log.debug(farm.user_id, "killing wn: %s" % farm.vms)
                r = VM.destroy(farm.vms.all())

            if True in [x["status"] != "ok" for x in r]:
                farm.state = farm_states["failed"]
                try:
                    farm.save()
                except Exception:
                    raise CMException("farm_destroy")
            vm_resp.append(r)

            farm.state = farm_states["closed"]

            try:
                farm.save()
            except Exception:
                raise CMException("farm_destroy")

            log.debug(farm.user_id, "session commited")
            for vm in farm.vms.all():
                log.debug(vm.user.id, "vm state %s" % vm.state)

        return vm_resp
开发者ID:pojoba02,项目名称:cc1,代码行数:60,代码来源:farm.py

示例3: destroy

# 需要导入模块: from cm.models.vm import VM [as 别名]
# 或者: from cm.models.vm.VM import destroy [as 别名]
def destroy(caller_id, vm_ids):
    """
    This function only destroys VM. All the cleanup (removing disk, saving,
    rescuing resources, ...) is done by hook through
    \c contextualization.update_vm method (yeah, intuitive).

    Simple sequence diagram:

    @code
            CLM        CM         CTX           Node (HOOK)
             .
            Destroy -->destroy
             |          |       (LV.destroy)
             |          |------------------------->HookScript
             .          .                          |
             .          .          ctx.update_vm<--|
             .          .           |              |
             .          .           |------------->cp
             .          .           |------------->rm
             .          .          update_resources
    @endcode

    @cmview_user
    @param_post{vm_ids,list} list of virtual machines' ids

    @response{list(dict)} VM.destroy() retval
    """
    vms = []
    for vm_id in vm_ids:
        vms.append(VM.get(caller_id, vm_id))
    return VM.destroy(vms)
开发者ID:cc1-cloud,项目名称:cc1,代码行数:33,代码来源:vm.py

示例4: save_and_shutdown

# 需要导入模块: from cm.models.vm import VM [as 别名]
# 或者: from cm.models.vm.VM import destroy [as 别名]
    def save_and_shutdown(farm, name, description):
        """
        """
        from cm.models.vm import VM

        if farm.state == farm_states['failed']:
            raise CMException('farm_wrong_state')

        head_vm = farm.head
        try:
            head_vm.name = name
            head_vm.description = description
            head_vm.save_vm = 2
            head_vm.save()
            head_vm.save_image()
            head_vm.release_resources()
            head_vm.remove()
            head_vm.state = vm_states['closed']
            head_vm.save()
        except Exception:
            CMException('farm_save')

        node_vms = []
        if farm.state == farm_states['init_head']:
            for vm in farm.vms.all():
                if vm.is_head():
                    continue
                vm.release_resources()
                vm.state = vm_states['closed']
        else:
            for vm in farm.vms.all():
                node_vms.append(vm)
            VM.destroy(node_vms)

        try:
            farm.state = farm_states['closed']
            farm.save()
        except:
            CMException('farm_save')
开发者ID:cloudcache,项目名称:cc1,代码行数:41,代码来源:farm.py

示例5: destroy

# 需要导入模块: from cm.models.vm import VM [as 别名]
# 或者: from cm.models.vm.VM import destroy [as 别名]
def destroy(caller_id, vm_id_list):
    """
    Method destroyes VMs with ids listed in \c vm_ids.
    @cmview_admin_cm

    @parameter{vm_ids,list} list of vm id's

    @response{src.cm.views.utils.image.destroy()}
    """

    vms = []
    for vm_id in vm_id_list:
        vms.append(VM.admin_get(vm_id))
    return VM.destroy(vms)
开发者ID:cloudcache,项目名称:cc1,代码行数:16,代码来源:vm.py


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