1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2025-07-31 12:41:08 +00:00

instance network page reconfigured. libxml2 artifacts cleaned. Some minor makeups

This commit is contained in:
catborise 2018-07-24 13:52:47 +03:00
parent 8b2451284f
commit b178bad93e
4 changed files with 48 additions and 22 deletions

View file

@ -217,13 +217,14 @@ class wvmInstance(wvmConnect):
result = []
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]
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]
try:
net = self.get_network(nic_host)
net = self.get_network(network_host)
ip = get_mac_ipaddr(net, mac_host)
except:
except libvirtError as e:
ip = None
result.append({'mac': mac_host, 'nic': nic_host, 'ip': ip})
result.append({'mac': mac_host, 'nic': network_host, 'target': target_host,'ip': ip})
return result
return util.get_xml_path(self._XMLDesc(0), func=networks)
@ -746,12 +747,13 @@ class wvmInstance(wvmConnect):
tree = ElementTree.fromstring(xml)
for num, interface in enumerate(tree.findall('devices/interface')):
net = self.get_network(network_data['net-source-' + str(num)])
if interface.get('type') == 'bridge':
source = interface.find('mac')
source.set('address', network_data['net-mac-' + str(num)])
source = interface.find('source')
source.set('bridge', network_data['net-source-' + str(num)])
source.set('bridge', net.bridgeName())
source.set('network', net.name())
new_xml = ElementTree.tostring(tree)
self._defineXML(new_xml)