本文整理汇总了Python中cm.models.vm.VM.admin_get方法的典型用法代码示例。如果您正苦于以下问题:Python VM.admin_get方法的具体用法?Python VM.admin_get怎么用?Python VM.admin_get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cm.models.vm.VM
的用法示例。
在下文中一共展示了VM.admin_get方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: vm_stats
# 需要导入模块: from cm.models.vm import VM [as 别名]
# 或者: from cm.models.vm.VM import admin_get [as 别名]
def vm_stats(caller_id, vm_id, stat_name, time, stat_range, resolution):
"""
Function returns requested statistics for specific VM. Stats are returned
in format required by CC1 Web Interface's monitoring javascript.
@cmview_admin_cm
@param_post{vm_id}
@param_post{stat_name,string|list(string)} type of required statistics
@param_post{time,int} time of last row
@param_post{stat_range,string} time interval between first and last stats
@param_post{resolution,string} statistics resolution
@response{list} usage of VM resources (format required by CC1 Web Interface)
"""
vm_u = VM.admin_get(vm_id).long_dict['user_id']
if type(stat_name) is int:
stat_name = [stat_name]
n = []
for stat in stat_name:
n.append(stat_names.keys()[stat_names.values().index(stat)])
p = int(stat_ranges.keys()[stat_ranges.values().index(int(stat_range))])
r = int(stat_resolutions.keys()[stat_resolutions.values().index(resolution)])
return RrdHandler().get_vm_stats('vm-%d-%d' % (vm_id, vm_u), n, int(time) - p, time, r)
示例2: vm_stats
# 需要导入模块: from cm.models.vm import VM [as 别名]
# 或者: from cm.models.vm.VM import admin_get [as 别名]
def vm_stats(caller_id, vm_id, stat_name, time, stat_range, resolution):
"""
Function returns statistics for specific \c vmid.
@decoratedby{src.cm.utils.decorators.user_log}
@parameter{vmid}
@parameter{stat_name,string} type of required statistics
@parameter{time,string} time of last row
@parameter{range,string} period of time from time to past
@parameter{resolution,string} statistics resolution
@response{dict} list of the total usage of VM resources from start VM
"""
vm_u = VM.admin_get(vm_id).long_dict['user_id']
if type(stat_name) is int:
stat_name = [stat_name]
n = []
for stat in stat_name:
n.append(stat_names.keys()[stat_names.values().index(stat)])
p = int(stat_ranges.keys()[stat_ranges.values().index(int(stat_range))])
r = int(stat_resolutions.keys()[stat_resolutions.values().index(resolution)])
return RrdHandler().get_vm_stats('vm-%d-%d' % (vm_id, vm_u), n, int(time) - p, time, r)
示例3: get_by_id
# 需要导入模块: from cm.models.vm import VM [as 别名]
# 或者: from cm.models.vm.VM import admin_get [as 别名]
def get_by_id(caller_id, vm_id):
"""
@cmview_admin_cm
@param_post{vm_id} id of the requested VM
@response{dict} VM with id @prm{id}
"""
vm = VM.admin_get(vm_id)
vm_mod = vm.long_dict
return vm_mod
示例4: erase
# 需要导入模块: from cm.models.vm import VM [as 别名]
# 或者: from cm.models.vm.VM import admin_get [as 别名]
def erase(caller_id, vm_id_list):
"""
Cleans up after each of the specified VMs. Erase should be called for
failed machines after the inspection of the failure.
@cmview_admin_cm
@param_post{vm_id_list,list} list of VM id's
"""
for vm_id in vm_id_list:
vm = VM.admin_get(vm_id)
VM.erase(vm)
示例5: destroy
# 需要导入模块: from cm.models.vm import VM [as 别名]
# 或者: from cm.models.vm.VM import admin_get [as 别名]
def destroy(caller_id, vm_id_list):
"""
Destroyes specified VMs. Destroyed VM can in no way be recovered.
@cmview_admin_cm
@param_post{vm_id_list,list} ids to destroy
@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)
示例6: detach_vnc
# 需要导入模块: from cm.models.vm import VM [as 别名]
# 或者: from cm.models.vm.VM import admin_get [as 别名]
def detach_vnc(caller_id, vm_id):
"""
Detaches VNC redirection from VM.
@cmview_admin_cm
@param_post{vm_id,int} id of the VM to have detached VM redirection
"""
vm = VM.admin_get(vm_id)
vm.detach_vnc()
try:
vm.save()
except:
raise CMException('vnc_detach')
示例7: erase
# 需要导入模块: from cm.models.vm import VM [as 别名]
# 或者: from cm.models.vm.VM import admin_get [as 别名]
def erase(caller_id, vm_id_list):
"""
Method cleans up after each of VM, which id is in \c vm_ids. Should be
called for failed machines.
@cmview_admin_cm
@parameter{vm_id_list,list} list of vm id's
@noresponse
"""
for vm_id in vm_id_list:
vm = VM.admin_get(vm_id)
VM.erase(vm)
示例8: destroy
# 需要导入模块: from cm.models.vm import VM [as 别名]
# 或者: from cm.models.vm.VM import admin_get [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)
示例9: detach_vnc
# 需要导入模块: from cm.models.vm import VM [as 别名]
# 或者: from cm.models.vm.VM import admin_get [as 别名]
def detach_vnc(caller_id, vm_id):
"""
Detaches VNC redirection from VM.
@cmview_user
@parameter{vm_id,int} id of the VM to have detached VM redirection
@response{None}
"""
vm = VM.admin_get(vm_id)
vm.detach_vnc()
try:
vm.save()
except:
raise CMException('vnc_detach')
示例10: save_and_shutdown
# 需要导入模块: from cm.models.vm import VM [as 别名]
# 或者: from cm.models.vm.VM import admin_get [as 别名]
def save_and_shutdown(caller_id, vm_id, name, description):
"""
Saves and shutdowns specified VM, without checking User quota.
@cmview_admin_cm
@param_post{vm_id,string} id of the VM to save
@param_post{name,string}
@param_post{description,string}
"""
vm = VM.admin_get(vm_id)
user = User.get(vm.user.id)
if user.used_storage + vm.system_image.size > user.storage:
raise CMException('user_storage_limit')
VM.save_and_shutdown(user.id, vm, name, description)
示例11: edit
# 需要导入模块: from cm.models.vm import VM [as 别名]
# 或者: from cm.models.vm.VM import admin_get [as 别名]
def edit(caller_id, vm_id, name, description):
"""
Updates VM attributes.
@cmview_admin_cm
@param_post{vm_id}
@param_post{name} (optional) new VM name
@param_post{description} (optional) new VM description
@response{src.cm.views.utils.vm.edit()}
"""
vm = VM.admin_get(vm_id)
vm.name = name
vm.description = description
vm.save()
示例12: edit
# 需要导入模块: from cm.models.vm import VM [as 别名]
# 或者: from cm.models.vm.VM import admin_get [as 别名]
def edit(caller_id, vm_id, name, description):
"""
Change vm parameters. You should get them by vm.get_by_id.
@cmview_admin_cm
@parameter{vm_id}
@parameter{name} new VM name
@parameter{description} new VM description
@response{src.cm.views.utils.vm.edit()}
"""
vm = VM.admin_get(vm_id)
vm.name = name
vm.description = description
vm.save()
示例13: save_and_shutdown
# 需要导入模块: from cm.models.vm import VM [as 别名]
# 或者: from cm.models.vm.VM import admin_get [as 别名]
def save_and_shutdown(caller_id, vm_id, name, description):
"""
Method calls save_and_shutdown for each VM with id is in @prm{vm_id} (for
administrator only).
@cmview_admin_cm
@parameter{vm_id,string}
@parameter{name,string}
@parameter{description,string}
"""
vm = VM.admin_get(vm_id)
user = User.get(vm.user.id)
if user.used_storage + vm.system_image.size > user.storage:
raise CMException('user_storage_limit')
VM.save_and_shutdown(user.id, vm, name, description)