1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-24 23:25:24 +00:00

Handle empty name for fixed networks

This commit is contained in:
catborise 2019-01-23 09:14:54 +03:00
parent bd63e3e4e6
commit a3be93874c

View file

@ -178,7 +178,9 @@ class wvmNetwork(wvmConnect):
for net in doc.xpath('/network/ip/dhcp/host'): for net in doc.xpath('/network/ip/dhcp/host'):
ip = net.xpath('@ip')[0] ip = net.xpath('@ip')[0]
mac = net.xpath('@mac')[0] mac = net.xpath('@mac')[0]
name = net.xpath('@name')[0] name = net.xpath('@name')
name = name[0] if name else ""
result.append({'ip': ip, 'mac': mac, 'name': name}) result.append({'ip': ip, 'mac': mac, 'name': name})
return result return result
@ -186,7 +188,10 @@ class wvmNetwork(wvmConnect):
def modify_fixed_address(self, name, address, mac): def modify_fixed_address(self, name, address, mac):
util.validate_macaddr(mac) util.validate_macaddr(mac)
if name:
new_xml = '<host mac="{}" name="{}" ip="{}"/>'.format(mac, name, IP(address)) new_xml = '<host mac="{}" name="{}" ip="{}"/>'.format(mac, name, IP(address))
else:
new_xml = '<host mac="{}" ip="{}"/>'.format(mac, IP(address))
new_host_xml = ElementTree.fromstring(new_xml) new_host_xml = ElementTree.fromstring(new_xml)
tree = ElementTree.fromstring(self._XMLDesc(0)) tree = ElementTree.fromstring(self._XMLDesc(0))