本文整理汇总了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")
示例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)
示例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)