本文整理汇总了Python中virtinst.util.get_xml_path函数的典型用法代码示例。如果您正苦于以下问题:Python get_xml_path函数的具体用法?Python get_xml_path怎么用?Python get_xml_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_xml_path函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: vds_get_hdd
def vds_get_hdd(self, vname):
"""
Function return vds hdd info.
"""
all_hdd_dev = {}
storages = self.storages_get_node()
dom = self.lookupVM(vname)
xml = dom.XMLDesc(0)
for num in range(1, 5):
hdd_dev = util.get_xml_path(xml, "/domain/devices/disk[%s]/@device" % (num))
if hdd_dev == 'disk':
dev_bus = util.get_xml_path(xml, "/domain/devices/disk[%s]/target/@dev" % (num))
hdd = util.get_xml_path(xml, "/domain/devices/disk[%s]/source/@file" % (num))
# If xml create custom
if not hdd:
hdd = util.get_xml_path(xml, "/domain/devices/disk[%s]/source/@dev" % (num))
try:
img = self.storageVolPath(hdd)
img_vol = img.name()
for storage in storages:
stg = self.storagePool(storage)
if stg.info()[0] != 0:
stg.refresh(0)
for img in stg.listVolumes():
if img == img_vol:
vol = img
vol_stg = storage
all_hdd_dev[dev_bus] = vol, vol_stg
except:
all_hdd_dev[dev_bus] = hdd, 'Not in the pool'
return all_hdd_dev
开发者ID:Nushio,项目名称:webvirtmgr,代码行数:35,代码来源:server.py
示例2: vms_on_host
def vms_on_host():
import virtinst.util as util
import libvirt
host_mem = conn.getInfo()[1] * 1048576
try:
vname = {}
for id in conn.listDomainsID():
id = int(id)
dom = conn.lookupByID(id)
mem = util.get_xml_path(dom.XMLDesc(0), "/domain/memory")
mem = int(mem) * 1024
mem_usage = (mem * 100) / host_mem
vcpu = util.get_xml_path(dom.XMLDesc(0), "/domain/vcpu")
vname[dom.name()] = (dom.info()[0], vcpu, mem, mem_usage)
for id in conn.listDefinedDomains():
dom = conn.lookupByName(id)
mem = util.get_xml_path(dom.XMLDesc(0), "/domain/memory")
mem = int(mem) * 1024
mem_usage = (mem * 100) / host_mem
vcpu = util.get_xml_path(dom.XMLDesc(0), "/domain/vcpu")
vname[dom.name()] = (dom.info()[0], vcpu, mem, mem_usage)
return vname
except libvirt.libvirtError as e:
add_error(e, 'libvirt')
return "error"
开发者ID:euforia,项目名称:webvirtmgr,代码行数:25,代码来源:views.py
示例3: vds_get_hdd
def vds_get_hdd(conn, dom, storages):
"""
Function return vds hdd info.
"""
xml = dom.XMLDesc(0)
hdd = util.get_xml_path(xml, "/domain/devices/disk[1]/source/@file")
# If xml create custom
if not hdd:
hdd = util.get_xml_path(xml, "/domain/devices/disk[1]/source/@dev")
try:
img = conn.storageVolLookupByPath(hdd)
img_vol = img.name()
for storage in storages:
stg = conn.storagePoolLookupByName(storage)
if stg.info()[0] != 0:
stg.refresh(0)
for img in stg.listVolumes():
if img == img_vol:
vol = img
vol_stg = storage
return vol, vol_stg
except:
return hdd, 'Not in the pool'
开发者ID:connectxyz,项目名称:webvirtmgr,代码行数:27,代码来源:libvirt_func.py
示例4: get_ipv4_forward
def get_ipv4_forward():
try:
xml = net.XMLDesc(0)
fw = util.get_xml_path(xml, "/network/forward/@mode")
forwardDev = util.get_xml_path(xml, "/network/forward/@dev")
return [fw, forwardDev]
except libvirt.libvirtError as e:
add_error(e, 'libvirt')
return "error"
开发者ID:gerge,项目名称:webvirtmgr,代码行数:9,代码来源:views.py
示例5: get_vm_nic
def get_vm_nic():
try:
xml = dom.XMLDesc(0)
mac = util.get_xml_path(xml, "/domain/devices/interface/mac/@address")
nic = util.get_xml_path(xml, "/domain/devices/interface/source/@network")
if nic is None:
nic = util.get_xml_path(xml, "/domain/devices/interface/source/@bridge")
return mac, nic
except libvirt.libvirtError as e:
add_error(e, 'libvirt')
return "error"
开发者ID:gerge,项目名称:webvirtmgr,代码行数:11,代码来源:views.py
示例6: get_vm_hdd
def get_vm_hdd():
try:
xml = dom.XMLDesc(0)
hdd_path = util.get_xml_path(xml, "/domain/devices/disk[1]/source/@file")
hdd_fmt = util.get_xml_path(xml, "/domain/devices/disk[1]/driver/@type")
#image = re.sub('\/.*\/', '', hdd_path)
size = dom.blockInfo(hdd_path, 0)[0]
#return image, size, hdd_fmt
return hdd_path, size, hdd_fmt
except libvirt.libvirtError as e:
add_error(e, 'libvirt')
return "error"
开发者ID:gerge,项目名称:webvirtmgr,代码行数:12,代码来源:views.py
示例7: get_ipv4_dhcp_range
def get_ipv4_dhcp_range():
try:
net = conn.networkLookupByName(pool)
xml = net.XMLDesc(0)
dhcpstart = util.get_xml_path(xml, "/network/ip/dhcp/range[1]/@start")
dhcpend = util.get_xml_path(xml, "/network/ip/dhcp/range[1]/@end")
if not dhcpstart or not dhcpend:
return None
return [IP(dhcpstart), IP(dhcpend)]
except libvirt.libvirtError as e:
add_error(e, 'libvirt')
return "error"
开发者ID:gerge,项目名称:webvirtmgr,代码行数:13,代码来源:views.py
示例8: get_emulator
def get_emulator():
try:
emulator = []
xml = conn.getCapabilities()
arch = conn.getInfo()[0]
if arch == 'x86_64':
emulator.append(util.get_xml_path(xml,"/capabilities/guest[1]/arch/emulator"))
emulator.append(util.get_xml_path(xml,"/capabilities/guest[2]/arch/emulator"))
else:
emulator = util.get_xml_path(xml,"/capabilities/guest/arch/emulator")
return emulator
except libvirt.libvirtError as e:
add_error(e, 'libvirt')
return "error"
开发者ID:afghanistanyn,项目名称:virtmgr,代码行数:14,代码来源:views.py
示例9: get_ipv4_net
def get_ipv4_net():
try:
net = conn.networkLookupByName(pool)
xml = net.XMLDesc(0)
addrStr = util.get_xml_path(xml, "/network/ip/@address")
netmaskStr = util.get_xml_path(xml, "/network/ip/@netmask")
netmask = IP(netmaskStr)
gateway = IP(addrStr)
network = IP(gateway.int() & netmask.int())
return IP(str(network) + "/" + netmaskStr)
except libvirt.libvirtError as e:
add_error(e, 'libvirt')
return "error"
开发者ID:gerge,项目名称:webvirtmgr,代码行数:15,代码来源:views.py
示例10: get_type
def get_type():
try:
xml = stg.XMLDesc(0)
return util.get_xml_path(xml, "/pool/@type")
except libvirt.libvirtError as e:
add_error(e, "libvirt")
return "error"
开发者ID:mba811,项目名称:virtmgr,代码行数:7,代码来源:views.py
示例11: new_volume
def new_volume(self, storage, name, size):
"""
Add new volume in storage
"""
stg = self.storagePool(storage)
size = int(size) * 1073741824
stg_type = util.get_xml_path(stg.XMLDesc(0), "/pool/@type")
if stg_type == 'dir':
name = name + '.img'
alloc = 0
else:
alloc = size
xml = """
<volume>
<name>%s</name>
<capacity>%s</capacity>
<allocation>%s</allocation>
<target>
<format type='qcow2'/>
</target>
</volume>""" % (name, size, alloc)
stg.createXML(xml, 0)
开发者ID:Nushio,项目名称:webvirtmgr,代码行数:25,代码来源:server.py
示例12: get_target_path
def get_target_path():
try:
xml = stg.XMLDesc(0)
return util.get_xml_path(xml, "/pool/target/path")
except libvirt.libvirtError as e:
add_error(e,'libvirt')
return "error"
开发者ID:homhei,项目名称:webvirtmgr,代码行数:7,代码来源:views.py
示例13: stg_info
def stg_info():
import virtinst.util as util
if stg.info()[3] == 0:
percent = 0
else:
percent = (stg.info()[2] * 100) / stg.info()[1]
info = stg.info()
info.append(int(percent))
info.append(stg.isActive())
xml = stg.XMLDesc(0)
info.append(util.get_xml_path(xml, "/pool/@type"))
info.append(util.get_xml_path(xml, "/pool/target/path"))
info.append(util.get_xml_path(xml, "/pool/source/device/@path"))
info.append(util.get_xml_path(xml, "/pool/source/format/@type"))
return info
开发者ID:tilltheendwjx,项目名称:webvirtmgr-1,代码行数:16,代码来源:views.py
示例14: get_dom_info
def get_dom_info():
import virtinst.util as util
info = []
xml = dom.XMLDesc(0)
info.append(util.get_xml_path(xml, "/domain/vcpu"))
mem = util.get_xml_path(xml, "/domain/memory")
mem = int(mem) / 1024
info.append(int(mem))
info.append(util.get_xml_path(xml, "/domain/devices/interface/mac/@address"))
nic = util.get_xml_path(xml, "/domain/devices/interface/source/@network")
if nic is None:
nic = util.get_xml_path(xml, "/domain/devices/interface/source/@bridge")
info.append(nic)
return info
开发者ID:tilltheendwjx,项目名称:webvirtmgr-1,代码行数:16,代码来源:views.py
示例15: get_vm_vnc
def get_vm_vnc():
try:
xml = dom.XMLDesc(0)
vnc = util.get_xml_path(xml, "/domain/devices/graphics/@port")
return vnc
except:
print "Get vnc port failed"
开发者ID:gerge,项目名称:webvirtmgr,代码行数:7,代码来源:views.py
示例16: get_machine
def get_machine():
try:
xml = conn.getCapabilities()
machine = util.get_xml_path(xml,"/capabilities/guest/arch/machine/@canonical")
return machine
except libvirt.libvirtError as e:
add_error(e, 'libvirt')
return "error"
开发者ID:afghanistanyn,项目名称:virtmgr,代码行数:8,代码来源:views.py
示例17: get_volume_for_pool
def get_volume_for_pool(pool_object=None, pool_name=None, conn=None):
"""
Returns volume class associated with passed pool_object/name
"""
pool_object = StorageVolume.lookup_pool_by_name(pool_object=pool_object,
pool_name=pool_name,
conn=conn)
return StoragePool.get_volume_for_pool(util.get_xml_path(pool_object.XMLDesc(0), "/pool/@type"))
开发者ID:aliceinwire,项目名称:virt-manager,代码行数:8,代码来源:Storage.py
示例18: get_vm_boot_menu
def get_vm_boot_menu():
try:
xml = dom.XMLDesc(0)
boot_menu = util.get_xml_path(xml, "/domain/os/bootmenu/@enable")
return boot_menu
except libvirt.libvirtError as e:
add_error(e, 'libvirt')
return "error"
开发者ID:gerge,项目名称:webvirtmgr,代码行数:8,代码来源:views.py
示例19: get_vm_arch
def get_vm_arch():
try:
xml = dom.XMLDesc(0)
arch = util.get_xml_path(xml, "/domain/os/type/@arch")
return arch
except libvirt.libvirtError as e:
add_error(e, 'libvirt')
return "error"
开发者ID:gerge,项目名称:webvirtmgr,代码行数:8,代码来源:views.py
示例20: get_vm_vnc
def get_vm_vnc():
try:
xml = dom.XMLDesc(0)
vnc = util.get_xml_path(xml, "/domain/devices/graphics/@port")
return vnc
except libvirt.libvirtError as e:
add_error(e, 'libvirt')
return "error"
开发者ID:gerge,项目名称:webvirtmgr,代码行数:8,代码来源:views.py
注:本文中的virtinst.util.get_xml_path函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论