1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

OpenNebula one_vm.py: Fix missing keys (#2435)

* OpenNebula one_vm.py: Fix missing keys

* fixup OpenNebula one_vm.py: Fix missing keys
This commit is contained in:
Jan Orel 2021-05-04 12:21:55 +02:00 committed by GitHub
parent 1f41e66f09
commit aaa561163b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- one_vm - Allow missing NIC keys (https://github.com/ansible-collections/community.general/pull/2435).

View file

@ -752,11 +752,20 @@ def get_vm_info(client, vm):
if 'NIC' in vm.TEMPLATE: if 'NIC' in vm.TEMPLATE:
if isinstance(vm.TEMPLATE['NIC'], list): if isinstance(vm.TEMPLATE['NIC'], list):
for nic in vm.TEMPLATE['NIC']: for nic in vm.TEMPLATE['NIC']:
networks_info.append({'ip': nic['IP'], 'mac': nic['MAC'], 'name': nic['NETWORK'], 'security_groups': nic['SECURITY_GROUPS']}) networks_info.append({
'ip': nic.get('IP', ''),
'mac': nic.get('MAC', ''),
'name': nic.get('NETWORK', ''),
'security_groups': nic.get('SECURITY_GROUPS', '')
})
else: else:
networks_info.append( networks_info.append({
{'ip': vm.TEMPLATE['NIC']['IP'], 'mac': vm.TEMPLATE['NIC']['MAC'], 'ip': vm.TEMPLATE['NIC'].get('IP', ''),
'name': vm.TEMPLATE['NIC']['NETWORK'], 'security_groups': vm.TEMPLATE['NIC']['SECURITY_GROUPS']}) 'mac': vm.TEMPLATE['NIC'].get('MAC', ''),
'name': vm.TEMPLATE['NIC'].get('NETWORK', ''),
'security_groups':
vm.TEMPLATE['NIC'].get('SECURITY_GROUPS', '')
})
import time import time
current_time = time.localtime() current_time = time.localtime()