本文整理汇总了Python中karesansui.lib.virt.virt.KaresansuiVirtConnection.get_nodeinfo方法的典型用法代码示例。如果您正苦于以下问题:Python KaresansuiVirtConnection.get_nodeinfo方法的具体用法?Python KaresansuiVirtConnection.get_nodeinfo怎么用?Python KaresansuiVirtConnection.get_nodeinfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类karesansui.lib.virt.virt.KaresansuiVirtConnection
的用法示例。
在下文中一共展示了KaresansuiVirtConnection.get_nodeinfo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process
# 需要导入模块: from karesansui.lib.virt.virt import KaresansuiVirtConnection [as 别名]
# 或者: from karesansui.lib.virt.virt.KaresansuiVirtConnection import get_nodeinfo [as 别名]
def process(self):
conn = KaresansuiVirtConnection()
try:
guests = conn.search_guests()
nodeinfo = conn.get_nodeinfo()
infos = []
for guest in guests:
id = guest.ID()
if id > -1:
name = guest.name()
print name
info = guest.info()
maxMem = info[1]
memory = info[2]
pcentCurrMem = memory * 100.0 / (nodeinfo["memory"]*1024)
pcentMaxMem = maxMem * 100.0 / (nodeinfo["memory"]*1024)
print "%.3f%%" % pcentCurrMem
#print pcentMaxMem
return True
finally:
conn.close()
示例2: _PUT
# 需要导入模块: from karesansui.lib.virt.virt import KaresansuiVirtConnection [as 别名]
# 或者: from karesansui.lib.virt.virt.KaresansuiVirtConnection import get_nodeinfo [as 别名]
def _PUT(self, *param, **params):
"""<comment-ja>
Japanese Comment
</comment-ja>
<comment-en>
TODO: English Comment
</comment-en>
"""
(host_id, guest_id) = self.chk_guestby1(param)
if guest_id is None:
return web.notfound()
if is_param(self.input, "memory"):
memory = int(self.input.memory)
else:
memory = None
max_memory = int(self.input.max_memory)
model = findbyguest1(self.orm, guest_id)
# virt
kvc = KaresansuiVirtConnection()
try:
domname = kvc.uuid_to_domname(model.uniq_key)
if not domname:
return web.conflict(web.ctx.path)
virt = kvc.search_kvg_guests(domname)[0]
info = virt.get_info()
# maxMem = info["maxMem"]
now_memory = info["memory"]
mem_info = kvc.get_mem_info()
nodeinfo = kvc.get_nodeinfo()
finally:
kvc.close()
# valid
# if (mem_info["host_free_mem"] + (now_memory / 1024)) < memory:
# return web.badrequest("Memory value is greater than the maximum memory value. - memory=%s" % self.input.memory)
options = {}
options["name"] = domname
options["maxmem"] = max_memory
if memory is None:
options["memory"] = max_memory
else:
options["memory"] = memory
_cmd = dict2command("%s/%s" % (karesansui.config["application.bin.dir"], VIRT_COMMAND_SET_MEMORY), options)
cmdname = "Set memory"
_jobgroup = JobGroup(cmdname, karesansui.sheconf["env.uniqkey"])
_jobgroup.jobs.append(Job("%s command" % cmdname, 0, _cmd))
_machine2jobgroup = m2j_new(
machine=model,
jobgroup_id=-1,
uniq_key=karesansui.sheconf["env.uniqkey"],
created_user=self.me,
modified_user=self.me,
)
save_job_collaboration(self.orm, self.pysilhouette.orm, _machine2jobgroup, _jobgroup)
return web.accepted(url=web.ctx.path)
示例3: _GET
# 需要导入模块: from karesansui.lib.virt.virt import KaresansuiVirtConnection [as 别名]
# 或者: from karesansui.lib.virt.virt.KaresansuiVirtConnection import get_nodeinfo [as 别名]
def _GET(self, *param, **params):
(host_id, guest_id) = self.chk_guestby1(param)
if guest_id is None: return web.notfound()
model = findbyguest1(self.orm, guest_id)
# virt
kvc = KaresansuiVirtConnection()
try:
domname = kvc.uuid_to_domname(model.uniq_key)
if not domname: return web.notfound()
virt = kvc.search_kvg_guests(domname)[0]
self.view.info = virt.get_info()
#self.view.mem_info = kvc.get_mem_info()
self.view.nodeinfo = kvc.get_nodeinfo()
self.view.guest = model
self.view.hypervisor = self.view.info['hypervisor']
finally:
kvc.close()
return True