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

Add check for empty records and add test

This commit is contained in:
Tom Paine 2024-08-21 14:32:41 +01:00
parent 4b4505e3f9
commit c7e7b6c9e3
2 changed files with 15 additions and 2 deletions

View file

@ -200,7 +200,8 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
server['name'] = vm.NAME server['name'] = vm.NAME
server['id'] = vm.ID server['id'] = vm.ID
server['host'] = vm.HISTORY_RECORDS.HISTORY[-1].HOSTNAME if vm.HISTORY_RECORDS.HISTORY[-1]:
server['host'] = vm.HISTORY_RECORDS.HISTORY[-1].HOSTNAME
server['LABELS'] = labels server['LABELS'] = labels
server['v4_first_ip'] = self._get_vm_ipv4(vm) server['v4_first_ip'] = self._get_vm_ipv4(vm)
server['v6_first_ip'] = self._get_vm_ipv6(vm) server['v6_first_ip'] = self._get_vm_ipv6(vm)

View file

@ -58,7 +58,19 @@ def get_vm_pool():
'ETIME': 0, 'ETIME': 0,
'GID': 132, 'GID': 132,
'GNAME': 'CSApparelVDC', 'GNAME': 'CSApparelVDC',
'HISTORY_RECORDS': {}, 'HISTORY_RECORDS': OrderedDict({
'HISTORY': OrderedDict({
'OID': '42',
'SEQ': '384',
'HOSTNAME': 'sam-691-sam',
'HID': '10',
'CID': '0',
'DS_ID': '100',
'VM_MAD': 'kvm',
'TM_MAD': '3par',
'ACTION': '0'
})
}),
'ID': 7157, 'ID': 7157,
'LAST_POLL': 1632762935, 'LAST_POLL': 1632762935,
'LCM_STATE': 3, 'LCM_STATE': 3,