[英]Libvirt python add vCPU and memory
我正在为Libvirt使用python绑定。 如何使用libvirt在Xen中为域添加或删除VCPU和内存?
在命令行中,我正在使用:
Vcpu:
xm vcpu-set [domain-id] [count in #cores]
记忆:
Memory: xm mem-set [domain-id] [count in MB]
如何使用libvirt绑定在python中运行这些命令? 不使用子流程。
from xen.util.xmlrpcclient import ServerProxy
server = ServerProxy(serverURI)
def xm_vcpu_pin(args):
def cpu_make_map(cpulist):
cpus = []
for c in cpulist.split(','):
if c == '':
continue
if c.find('-') != -1:
(x, y) = c.split('-')
for i in range(int(x), int(y) + 1):
cpus.append(int(i))
else:
# remove this element from the list
if c[0] == '^':
cpus = [x for x in cpus if x != int(c[1:])]
else:
cpus.append(int(c))
cpus.sort()
return ",".join(map(str, cpus))
dom = args[0]
vcpu = args[1]
cpumap = cpu_make_map(args[2])
server.xend.domain.pincpu(dom, vcpu, cpumap)
使用python固定vcpus的完整示例
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.