From a34c55d3bca60274c7184ad3620817810e8c0dea Mon Sep 17 00:00:00 2001 From: Jan Krcmar Date: Fri, 29 Jan 2016 14:44:19 +0100 Subject: [PATCH] clone instance fixes mac address not separated by :, to correct format xx:xx:... --- vrtManager/instance.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/vrtManager/instance.py b/vrtManager/instance.py index f47747c..20728db 100644 --- a/vrtManager/instance.py +++ b/vrtManager/instance.py @@ -612,6 +612,14 @@ class wvmInstance(wvmConnect): pool) return storage + def fix_mac(self, mac): + if ":" in mac: + return mac + # if mac does not contain ":", try to split into tuples and join with ":" + n = 2 + mac_tuples = [mac[i:i+n] for i in range(0, len(mac), n)] + return ':'.join(mac_tuples) + def clone_instance(self, clone_data): clone_dev_path = [] @@ -624,7 +632,8 @@ class wvmInstance(wvmConnect): for num, net in enumerate(tree.findall('devices/interface')): elm = net.find('mac') - elm.set('address', clone_data['net-' + str(num)]) + mac_address = self.fix_mac(clone_data['net-' + str(num)]) + elm.set('address', mac_address) for disk in tree.findall('devices/disk'): if disk.get('device') == 'disk':