mirror of
https://github.com/retspen/webvirtcloud
synced 2025-07-31 12:41:08 +00:00
Libxml2 converted to lxml, django framework upgrade to 1.11.x and some bug fixes
This commit is contained in:
parent
beea57189c
commit
ace30ca952
16 changed files with 265 additions and 106 deletions
|
@ -203,10 +203,10 @@ class wvmInstance(wvmConnect):
|
|||
|
||||
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
|
||||
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
|
||||
|
@ -215,9 +215,9 @@ class wvmInstance(wvmConnect):
|
|||
|
||||
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
|
||||
for net in ctx.xpath('/domain/devices/interface'):
|
||||
mac_host = net.xpath('mac/@address')[0]
|
||||
nic_host = net.xpath('source/@network|source/@bridge|source/@dev|target/@dev')[0]
|
||||
try:
|
||||
net = self.get_network(nic_host)
|
||||
ip = get_mac_ipaddr(net, mac_host)
|
||||
|
@ -229,7 +229,7 @@ class wvmInstance(wvmConnect):
|
|||
return util.get_xml_path(self._XMLDesc(0), func=networks)
|
||||
|
||||
def get_disk_device(self):
|
||||
def disks(ctx):
|
||||
def disks(doc):
|
||||
result = []
|
||||
dev = None
|
||||
volume = None
|
||||
|
@ -237,13 +237,14 @@ class wvmInstance(wvmConnect):
|
|||
src_fl = None
|
||||
disk_format = None
|
||||
disk_size = None
|
||||
for disk in ctx.xpathEval('/domain/devices/disk'):
|
||||
device = disk.xpathEval('@device')[0].content
|
||||
|
||||
for disk in doc.xpath('/domain/devices/disk'):
|
||||
device = disk.xpath('@device')[0]
|
||||
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
|
||||
dev = disk.xpath('target/@dev')[0]
|
||||
src_fl = disk.xpath('source/@file|source/@dev|source/@name|source/@volume')[0]
|
||||
disk_format = disk.xpath('driver/@type')[0]
|
||||
try:
|
||||
vol = self.get_volume_by_path(src_fl)
|
||||
volume = vol.name()
|
||||
|
@ -263,19 +264,19 @@ class wvmInstance(wvmConnect):
|
|||
return util.get_xml_path(self._XMLDesc(0), func=disks)
|
||||
|
||||
def get_media_device(self):
|
||||
def disks(ctx):
|
||||
def disks(doc):
|
||||
result = []
|
||||
dev = None
|
||||
volume = None
|
||||
storage = None
|
||||
src_fl = None
|
||||
for media in ctx.xpathEval('/domain/devices/disk'):
|
||||
device = media.xpathEval('@device')[0].content
|
||||
for media in doc.xpath('/domain/devices/disk'):
|
||||
device = media.xpath('@device')[0]
|
||||
if device == 'cdrom':
|
||||
try:
|
||||
dev = media.xpathEval('target/@dev')[0].content
|
||||
dev = media.xpath('target/@dev')
|
||||
try:
|
||||
src_fl = media.xpathEval('source/@file')[0].content
|
||||
src_fl = media.xpath('source/@file')
|
||||
vol = self.get_volume_by_path(src_fl)
|
||||
volume = vol.name()
|
||||
stg = vol.storagePoolLookupByVolume()
|
||||
|
@ -487,8 +488,7 @@ class wvmInstance(wvmConnect):
|
|||
return socket
|
||||
|
||||
def get_console_type(self):
|
||||
console_type = util.get_xml_path(self._XMLDesc(0),
|
||||
"/domain/devices/graphics/@type")
|
||||
console_type = util.get_xml_path(self._XMLDesc(0),"/domain/devices/graphics/@type")
|
||||
return console_type
|
||||
|
||||
def set_console_type(self, console_type):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue