mirror of
https://github.com/retspen/webvirtcloud
synced 2024-10-31 19:44:16 +00:00
clone instance fixes mac address not separated by :, to correct format xx:xx:...
This commit is contained in:
parent
646bdbbe0e
commit
a34c55d3bc
1 changed files with 10 additions and 1 deletions
|
@ -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':
|
||||
|
|
Loading…
Reference in a new issue