vmware_guest: Fix VM creation when adding a network device without a MAC address (#24138)
* vmware_guest: Fix VM creation when adding a network device without a MAC address * Provide python2.4 compatibility
This commit is contained in:
parent
e5cd675b38
commit
ef13f0f389
2 changed files with 11 additions and 3 deletions
|
@ -238,13 +238,19 @@ def gather_vm_facts(content, vm):
|
|||
if not hasattr(entry, 'macAddress'):
|
||||
continue
|
||||
|
||||
if entry.macAddress:
|
||||
mac_addr = entry.macAddress
|
||||
mac_addr_dash = mac_addr.replace(':', '-')
|
||||
else:
|
||||
mac_addr = mac_addr_dash = None
|
||||
|
||||
factname = 'hw_eth' + str(ethernet_idx)
|
||||
facts[factname] = {
|
||||
'addresstype': entry.addressType,
|
||||
'label': entry.deviceInfo.label,
|
||||
'macaddress': entry.macAddress,
|
||||
'macaddress': mac_addr,
|
||||
'ipaddresses': net_dict.get(entry.macAddress, None),
|
||||
'macaddress_dash': entry.macAddress.replace(':', '-'),
|
||||
'macaddress_dash': mac_addr_dash,
|
||||
'summary': entry.deviceInfo.summary,
|
||||
}
|
||||
facts['hw_interfaces'].append('eth' + str(ethernet_idx))
|
||||
|
|
|
@ -399,7 +399,6 @@ class PyVmomiDeviceHelper(object):
|
|||
(device_type, device_infos['name']))
|
||||
|
||||
nic.device.wakeOnLanEnabled = True
|
||||
nic.device.addressType = 'assigned'
|
||||
nic.device.deviceInfo = vim.Description()
|
||||
nic.device.deviceInfo.label = device_label
|
||||
nic.device.deviceInfo.summary = device_infos['name']
|
||||
|
@ -408,7 +407,10 @@ class PyVmomiDeviceHelper(object):
|
|||
nic.device.connectable.allowGuestControl = True
|
||||
nic.device.connectable.connected = True
|
||||
if 'mac' in device_infos:
|
||||
nic.device.addressType = 'assigned'
|
||||
nic.device.macAddress = device_infos['mac']
|
||||
else:
|
||||
nic.device.addressType = 'generated'
|
||||
|
||||
return nic
|
||||
|
||||
|
|
Loading…
Reference in a new issue