From a3be93874c13f6a585dae2569e13b53af69af9b0 Mon Sep 17 00:00:00 2001 From: catborise Date: Wed, 23 Jan 2019 09:14:54 +0300 Subject: [PATCH] Handle empty name for fixed networks --- vrtManager/network.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vrtManager/network.py b/vrtManager/network.py index 32b0819..8b430c6 100644 --- a/vrtManager/network.py +++ b/vrtManager/network.py @@ -178,7 +178,9 @@ class wvmNetwork(wvmConnect): for net in doc.xpath('/network/ip/dhcp/host'): ip = net.xpath('@ip')[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}) return result @@ -186,7 +188,10 @@ class wvmNetwork(wvmConnect): def modify_fixed_address(self, name, address, mac): util.validate_macaddr(mac) - new_xml = ''.format(mac, name, IP(address)) + if name: + new_xml = ''.format(mac, name, IP(address)) + else: + new_xml = ''.format(mac, IP(address)) new_host_xml = ElementTree.fromstring(new_xml) tree = ElementTree.fromstring(self._XMLDesc(0))