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


Python VM.save_and_shutdown方法代码示例

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


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

示例1: save_and_shutdown

# 需要导入模块: from cm.models.vm import VM [as 别名]
# 或者: from cm.models.vm.VM import save_and_shutdown [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: save_and_shutdown

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

    @cmview_user
    @param_post{vm_id,int} id of the VM to save and shutdown.
    @param_post{name,string} name of the new SystemImage VM should be saved to
    @param_post{description,string} description of the new SystemImage VM
    should be saved to
    """
    user = User.get(caller_id)
    vm = VM.get(caller_id, vm_id)

    if user.used_storage + vm.system_image.size > user.storage:
        raise CMException('user_storage_limit')

    VM.save_and_shutdown(caller_id, vm, name, description)
开发者ID:cc1-cloud,项目名称:cc1,代码行数:19,代码来源:vm.py

示例3: save_and_shutdown

# 需要导入模块: from cm.models.vm import VM [as 别名]
# 或者: from cm.models.vm.VM import save_and_shutdown [as 别名]
def save_and_shutdown(caller_id, vm_id, name, description):
    """
    Calls src.cm.views.utils.image.save_and_shutdown() for the VM selected.

    @cmview_user

    @parameter{vm_id,int} id of the VM to save and shutdown.
    @parameter{name,string}
    @parameter{description,string}
    """
    user = User.get(caller_id)
    vm = VM.get(caller_id, vm_id)

    if user.used_storage + vm.system_image.size > user.storage:
        raise CMException('user_storage_limit')

    VM.save_and_shutdown(caller_id, vm, name, description)
开发者ID:cloudcache,项目名称:cc1,代码行数:19,代码来源:vm.py


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