本文整理汇总了Python中vrtManager.util.get_xml_path函数的典型用法代码示例。如果您正苦于以下问题:Python get_xml_path函数的具体用法?Python get_xml_path怎么用?Python get_xml_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_xml_path函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: clone_from_template
def clone_from_template(self, clone, template, metadata=False):
vol = self.get_volume_by_path(template)
stg = vol.storagePoolLookupByVolume()
storage_type = util.get_xml_path(stg.XMLDesc(0), "/pool/@type")
format = util.get_xml_path(vol.XMLDesc(0), "/volume/target/format/@type")
if storage_type == 'dir':
clone += '.img'
else:
metadata = False
xml = """
<volume>
<name>%s</name>
<capacity>0</capacity>
<allocation>0</allocation>
<target>
<format type='%s'/>
<permissions>
<owner>107</owner>
<group>107</group>
<mode>0644</mode>
<label>virt_image_t</label>
</permissions>
<compat>1.1</compat>
<features>
<lazy_refcounts/>
</features>
</target>
</volume>""" % (clone, format)
stg.createXMLFrom(xml, vol, metadata)
clone_vol = stg.storageVolLookupByName(clone)
return clone_vol.path()
开发者ID:razvanboarta,项目名称:webvirtcloud,代码行数:31,代码来源:create.py
示例2: get_console_listen_addr
def get_console_listen_addr(self):
listen_addr = util.get_xml_path(self._XMLDesc(0), "/domain/devices/graphics/@listen")
if listen_addr is None:
listen_addr = util.get_xml_path(self._XMLDesc(0), "/domain/devices/graphics/listen/@address")
if listen_addr is None:
return "127.0.0.1"
return listen_addr
开发者ID:pirogoeth,项目名称:webvirtcloud,代码行数:7,代码来源:instance.py
示例3: get_ipv4_dhcp_range
def get_ipv4_dhcp_range(self):
xml = self._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)]
开发者ID:ahmdsmir,项目名称:webvirtmgr,代码行数:8,代码来源:network.py
示例4: get_ipv4
def get_ipv4(self):
xml = self._XMLDesc()
int_ipv4_ip = util.get_xml_path(xml, "/interface/protocol/ip/@address")
int_ipv4_mask = util.get_xml_path(xml, "/interface/protocol/ip/@prefix")
if not int_ipv4_ip or not int_ipv4_mask:
return None
else:
return int_ipv4_ip + '/' + int_ipv4_mask
开发者ID:daniviga,项目名称:webvirtmgr,代码行数:8,代码来源:interface.py
示例5: get_net_device
def get_net_device(self):
netdevice = []
for dev in self.wvm.listAllDevices(0):
xml = dev.XMLDesc(0)
dev_type = util.get_xml_path(xml, '/device/capability/@type')
if dev_type == 'net':
netdevice.append(util.get_xml_path(xml, '/device/capability/interface'))
return netdevice
开发者ID:daniviga,项目名称:webvirtmgr,代码行数:8,代码来源:connection.py
示例6: get_instance_vcpu
def get_instance_vcpu(self, name):
inst = self.get_instance(name)
cur_vcpu = util.get_xml_path(inst.XMLDesc(0), "/domain/vcpu/@current")
if cur_vcpu:
vcpu = cur_vcpu
else:
vcpu = util.get_xml_path(inst.XMLDesc(0), "/domain/vcpu")
return vcpu
开发者ID:andrem,项目名称:webvirtcloud,代码行数:8,代码来源:instance.py
示例7: graphics_listen
def graphics_listen(self, name):
inst = self.get_instance(name)
listen_addr = util.get_xml_path(inst.XMLDesc(0), "/domain/devices/graphics/@listen")
if listen_addr is None:
listen_addr = util.get_xml_path(inst.XMLDesc(0), "/domain/devices/graphics/listen/@address")
if listen_addr is None:
return "None"
return listen_addr
开发者ID:andrem,项目名称:webvirtcloud,代码行数:8,代码来源:instance.py
示例8: get_host_instances
def get_host_instances(self):
vname = {}
memory = self.wvm.getInfo()[1] * 1048576
for name in self.get_instances():
dom = self.get_instance(name)
mem = util.get_xml_path(dom.XMLDesc(0), "/domain/memory")
mem = int(mem) * 1024
mem_usage = (mem * 100) / memory
vcpu = util.get_xml_path(dom.XMLDesc(0), "/domain/vcpu")
vname[dom.name()] = (dom.info()[0], vcpu, mem, mem_usage)
return vname
开发者ID:gpns,项目名称:webvirtmgr,代码行数:11,代码来源:connection.py
示例9: get_rbd_storage_data
def get_rbd_storage_data(stg):
xml = stg.XMLDesc(0)
ceph_user = util.get_xml_path(xml, "/pool/source/auth/@username")
def get_ceph_hosts(ctx):
hosts = []
for host in ctx.xpathEval("/pool/source/host"):
name = host.prop("name")
if name:
hosts.append({'name': name, 'port': host.prop("port")})
return hosts
ceph_hosts = util.get_xml_path(xml, func=get_ceph_hosts)
secret_uuid = util.get_xml_path(xml, "/pool/source/auth/secret/@uuid")
return ceph_user, secret_uuid, ceph_hosts
开发者ID:GOMYWAY-NETWORKS,项目名称:webvirtcloud,代码行数:14,代码来源:create.py
示例10: get_disk_device
def get_disk_device(self):
def disks(ctx):
result = []
dev = None
volume = None
storage = None
src_fl = None
disk_format = None
info = None
for disk in ctx.xpathEval('/domain/devices/disk[@device="disk"]'):
try:
dev = disk.xpathEval("target/@dev")[0].content
src_fl = disk.xpathEval("source/@file|source/@dev|source/@name")[0].content
disk_format = disk.xpathEval("driver/@type")[0].content
try:
vol = self.get_volume_by_path(src_fl)
volume = vol.name()
stg = vol.storagePoolLookupByVolume()
storage = stg.name()
info = vol.info()
except libvirtError:
volume = src_fl
except:
pass
finally:
obj = {"dev": dev, "image": volume, "storage": storage, "path": src_fl, "format": disk_format}
if info:
obj.update({"type": info[0], "capacity": info[1], "allocation": info[2]})
result.append(obj)
return result
return util.get_xml_path(self._XMLDesc(0), func=disks)
开发者ID:CovertLamp,项目名称:virtkick-backend,代码行数:33,代码来源:instance.py
示例11: get_hd_resources_device
def get_hd_resources_device(self):
def hd_resources(ctx):
result = []
bus = None
slot = None
func = None
for hostdev in ctx.xpathEval('/domain/devices/hostdev'):
type_info = hostdev.xpathEval('@type')[0].content
if type_info == 'pci':
try:
bus = hostdev.xpathEval('source/address/@bus')[0].content
slot = hostdev.xpathEval('source/address/@slot')[0].content
func = hostdev.xpathEval('source/address/@function')[0].content
if bus is None or slot is None or func is None:
continue
result.append(bus[2:] + ":" + slot[2:] + "." + func[2:])
bus = None
slot = None
func = None
except:
pass
return result
return util.get_xml_path(self._XMLDesc(0), func=hd_resources)
开发者ID:fuwenbin,项目名称:webvirtmgr-nfv,代码行数:27,代码来源:instance.py
示例12: get_media_devices
def get_media_devices(self):
def disks(doc):
result = []
dev = volume = storage = None
src_file = None
for media in doc.xpath('/domain/devices/disk'):
device = media.xpath('@device')[0]
if device == 'cdrom':
try:
dev = media.xpath('target/@dev')[0]
bus = media.xpath('target/@bus')[0]
try:
src_file = media.xpath('source/@file')[0]
vol = self.get_volume_by_path(src_file)
volume = vol.name()
stg = vol.storagePoolLookupByVolume()
storage = stg.name()
except:
src_file = None
volume = src_file
except:
pass
finally:
result.append({'dev': dev, 'image': volume, 'storage': storage, 'path': src_file, 'bus': bus})
return result
return util.get_xml_path(self._XMLDesc(0), func=disks)
开发者ID:QDaniel,项目名称:webvirtcloud,代码行数:27,代码来源:instance.py
示例13: get_net_device
def get_net_device(self):
def get_mac_ipaddr(net, mac_host):
def fixed(doc):
for net in doc.xpath('/network/ip/dhcp/host'):
mac = net.xpath('@mac')[0]
host = net.xpath('@ip')[0]
if mac == mac_host:
return host
return None
return util.get_xml_path(net.XMLDesc(0), func=fixed)
def networks(ctx):
result = []
for net in ctx.xpath('/domain/devices/interface'):
mac_host = net.xpath('mac/@address')[0]
network_host = net.xpath('source/@network|source/@bridge|source/@dev')[0]
target_host = '' if not net.xpath('target/@dev') else net.xpath('target/@dev')[0]
filterref_host = '' if not net.xpath('filterref/@filter') else net.xpath('filterref/@filter')[0]
try:
net = self.get_network(network_host)
ip = get_mac_ipaddr(net, mac_host)
except libvirtError as e:
ip = None
result.append({'mac': mac_host, 'nic': network_host, 'target': target_host,'ip': ip, 'filterref': filterref_host})
return result
return util.get_xml_path(self._XMLDesc(0), func=networks)
开发者ID:QDaniel,项目名称:webvirtcloud,代码行数:28,代码来源:instance.py
示例14: get_net_device
def get_net_device(self):
def get_mac_ipaddr(net, mac_host):
def fixed(ctx):
for net in ctx.xpathEval('/network/ip/dhcp/host'):
mac = net.xpathEval('@mac')[0].content
host = net.xpathEval('@ip')[0].content
if mac == mac_host:
return host
return None
return util.get_xml_path(net.XMLDesc(0), func=fixed)
def networks(ctx):
result = []
for net in ctx.xpathEval('/domain/devices/interface'):
mac_host = net.xpathEval('mac/@address')[0].content
nic_host = net.xpathEval('source/@network|source/@bridge|source/@dev|target/@dev')[0].content
try:
net = self.get_network(nic_host)
ip = get_mac_ipaddr(net, mac_host)
except:
ip = None
result.append({'mac': mac_host, 'nic': nic_host, 'ip': ip})
return result
return util.get_xml_path(self._XMLDesc(0), func=networks)
开发者ID:andrem,项目名称:webvirtcloud,代码行数:26,代码来源:instance.py
示例15: get_volume_type
def get_volume_type(self, path):
vol = self.get_volume_by_path(path)
vol_type = util.get_xml_path(vol.XMLDesc(0), "/volume/target/format/@type")
if vol_type:
return vol_type
else:
return 'raw'
开发者ID:k3oni,项目名称:webvirtmgr,代码行数:7,代码来源:create.py
示例16: create_volume
def create_volume(self, storage, name, size, image_format=image_format, metadata=False):
size = int(size) * 1073741824
stg = self.get_storage(storage)
storage_type = util.get_xml_path(stg.XMLDesc(0), "/pool/@type")
if storage_type == 'dir':
name += '.img'
alloc = 0
else:
alloc = size
metadata = False
xml = """
<volume>
<name>%s</name>
<capacity>%s</capacity>
<allocation>%s</allocation>
<target>
<format type='%s'/>
<permissions>
<owner>107</owner>
<group>107</group>
<mode>0644</mode>
<label>virt_image_t</label>
</permissions>
</target>
</volume>""" % (name, size, alloc, image_format)
stg.createXML(xml, metadata)
try:
stg.refresh(0)
except:
pass
vol = stg.storageVolLookupByName(name)
return vol.path()
开发者ID:razvanboarta,项目名称:webvirtcloud,代码行数:32,代码来源:create.py
示例17: get_iface_info
def get_iface_info(self, name):
iface = self.get_iface(name)
xml = iface.XMLDesc(0)
mac = iface.MACString()
itype = util.get_xml_path(xml, "/interface/@type")
state = iface.isActive()
return {'name': name, 'type': itype, 'state': state, 'mac': mac}
开发者ID:daniviga,项目名称:webvirtmgr,代码行数:7,代码来源:interface.py
示例18: get_media_device
def get_media_device(self):
def disks(ctx):
result = []
dev = None
volume = None
storage = None
src_fl = None
for media in ctx.xpathEval('/domain/devices/disk'):
device = media.xpathEval('@device')[0].content
if device == 'cdrom':
try:
dev = media.xpathEval('target/@dev')[0].content
try:
src_fl = media.xpathEval('source/@file')[0].content
vol = self.get_volume_by_path(src_fl)
volume = vol.name()
stg = vol.storagePoolLookupByVolume()
storage = stg.name()
except:
src_fl = None
volume = src_fl
except:
pass
finally:
result.append({'dev': dev, 'image': volume, 'storage': storage, 'path': src_fl})
return result
return util.get_xml_path(self._XMLDesc(0), func=disks)
开发者ID:andrem,项目名称:webvirtcloud,代码行数:28,代码来源:instance.py
示例19: get_disk_device
def get_disk_device(self):
def disks(ctx):
result = []
dev = None
volume = None
storage = None
file = None
for disk in ctx.xpathEval('/domain/devices/disk'):
device = disk.xpathEval('@device')[0].content
if device == 'disk':
try:
dev = disk.xpathEval('target/@dev')[0].content
file = disk.xpathEval('source/@file|source/@dev|source/@name')[0].content
try:
vol = self.get_volume_by_path(file)
volume = vol.name()
stg = vol.storagePoolLookupByVolume()
storage = stg.name()
except libvirtError:
volume = file
except:
pass
finally:
result.append({'dev': dev, 'image': volume, 'storage': storage, 'path': file})
return result
return util.get_xml_path(self._XMLDesc(0), func=disks)
开发者ID:GSMAi,项目名称:webvirtmgr,代码行数:26,代码来源:instance.py
示例20: get_disk_device
def get_disk_device(self):
def disks(ctx):
result = []
dev = None
volume = None
storage = None
src_fl = None
disk_format = None
disk_size = None
for disk in ctx.xpathEval('/domain/devices/disk'):
device = disk.xpathEval('@device')[0].content
if device == 'disk':
try:
dev = disk.xpathEval('target/@dev')[0].content
src_fl = disk.xpathEval('source/@file|source/@dev|source/@name|source/@volume')[0].content
disk_format = disk.xpathEval('driver/@type')[0].content
try:
vol = self.get_volume_by_path(src_fl)
volume = vol.name()
disk_size = vol.info()[1]
stg = vol.storagePoolLookupByVolume()
storage = stg.name()
except libvirtError:
volume = src_fl
except:
pass
finally:
result.append(
{'dev': dev, 'image': volume, 'storage': storage, 'path': src_fl,
'format': disk_format, 'size': disk_size})
return result
return util.get_xml_path(self._XMLDesc(0), func=disks)
开发者ID:andrem,项目名称:webvirtcloud,代码行数:33,代码来源:instance.py
注:本文中的vrtManager.util.get_xml_path函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论