From 70284e402a9eac7e3bd3c48db56f41ff4f01ee50 Mon Sep 17 00:00:00 2001 From: Tom Paine Date: Tue, 27 Aug 2024 14:03:31 +0100 Subject: [PATCH] restore attribute checks --- plugins/inventory/opennebula.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/inventory/opennebula.py b/plugins/inventory/opennebula.py index 2cfca24510..dc624cae9f 100644 --- a/plugins/inventory/opennebula.py +++ b/plugins/inventory/opennebula.py @@ -201,9 +201,10 @@ class InventoryModule(BaseInventoryPlugin, Constructable): server['name'] = vm.NAME server['id'] = vm.ID - if isinstance(vm.HISTORY_RECORDS.HISTORY, Sequence) and len(vm.HISTORY_RECORDS.HISTORY) > 0: - if hasattr(vm.HISTORY_RECORDS.HISTORY[-1], 'HOSTNAME'): - server['host'] = vm.HISTORY_RECORDS.HISTORY[-1].HOSTNAME + if vm.HISTORY_RECORDS.HISTORY: + if isinstance(vm.HISTORY_RECORDS.HISTORY, Sequence) and len(vm.HISTORY_RECORDS.HISTORY) > 0: + if hasattr(vm.HISTORY_RECORDS.HISTORY[-1], 'HOSTNAME'): + server['host'] = vm.HISTORY_RECORDS.HISTORY[-1].HOSTNAME server['LABELS'] = labels server['v4_first_ip'] = self._get_vm_ipv4(vm) server['v6_first_ip'] = self._get_vm_ipv6(vm)