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

update as per guidance

This commit is contained in:
Tom Paine 2024-08-21 17:06:15 +01:00
parent 92fb4f19e6
commit c66aea5ae8

View file

@ -97,6 +97,7 @@ except ImportError:
from ansible.errors import AnsibleError from ansible.errors import AnsibleError
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable from ansible.plugins.inventory import BaseInventoryPlugin, Constructable
from ansible.module_utils.common.text.converters import to_native from ansible.module_utils.common.text.converters import to_native
from ansible.module_utils.common._collections_compat import Sequence
from ansible_collections.community.general.plugins.plugin_utils.unsafe import make_unsafe from ansible_collections.community.general.plugins.plugin_utils.unsafe import make_unsafe
@ -200,8 +201,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
server['name'] = vm.NAME server['name'] = vm.NAME
server['id'] = vm.ID server['id'] = vm.ID
if hasattr(vm.HISTORY_RECORDS, 'HISTORY'): if isinstance(vm.HISTORY_RECORDS.HISTORY, Sequence) and len(vm.HISTORY_RECORDS.HISTORY) > 0:
if isinstance(vm.HISTORY_RECORDS.HISTORY, list) and len(vm.HISTORY_RECORDS.HISTORY) > 0:
if hasattr(vm.HISTORY_RECORDS.HISTORY[-1], 'HOSTNAME'): if hasattr(vm.HISTORY_RECORDS.HISTORY[-1], 'HOSTNAME'):
server['host'] = vm.HISTORY_RECORDS.HISTORY[-1].HOSTNAME server['host'] = vm.HISTORY_RECORDS.HISTORY[-1].HOSTNAME
server['LABELS'] = labels server['LABELS'] = labels