From bbf8bb47d91aca4bc4293c474d7562e2b96dd70a Mon Sep 17 00:00:00 2001 From: Simon <4375225+skropf@users.noreply.github.com> Date: Mon, 29 Jun 2026 21:39:08 +0200 Subject: [PATCH] OpenNebula inventory fails if VM without NIC exists (#12361) * fix error of opennebula plugin when retrieving VM without NIC * add changelog fragment * added more descriptive name, added link to PR Co-authored-by: Felix Fontein --------- Co-authored-by: Felix Fontein --- changelogs/fragments/fix-opennebula_vm_without_nic.yml | 2 ++ plugins/inventory/opennebula.py | 6 ++++++ 2 files changed, 8 insertions(+) create mode 100644 changelogs/fragments/fix-opennebula_vm_without_nic.yml diff --git a/changelogs/fragments/fix-opennebula_vm_without_nic.yml b/changelogs/fragments/fix-opennebula_vm_without_nic.yml new file mode 100644 index 0000000000..c498035fbb --- /dev/null +++ b/changelogs/fragments/fix-opennebula_vm_without_nic.yml @@ -0,0 +1,2 @@ +bugfixes: + - opennebula inventory plugin - fix crash when retrieving VM without NIC (https://github.com/ansible-collections/community.general/pull/12361). diff --git a/plugins/inventory/opennebula.py b/plugins/inventory/opennebula.py index 52625213a1..a745f704a3 100644 --- a/plugins/inventory/opennebula.py +++ b/plugins/inventory/opennebula.py @@ -138,6 +138,9 @@ class InventoryModule(BaseInventoryPlugin, Constructable): def _get_vm_ipv4(self, vm): nic = vm.TEMPLATE.get("NIC") + if not nic: + return False + if isinstance(nic, dict): nic = [nic] @@ -150,6 +153,9 @@ class InventoryModule(BaseInventoryPlugin, Constructable): def _get_vm_ipv6(self, vm): nic = vm.TEMPLATE.get("NIC") + if not nic: + return False + if isinstance(nic, dict): nic = [nic]