Skip to content

Commit

Permalink
Fix OpenNebula inventory crash when NIC does not have IP (ansible-col…
Browse files Browse the repository at this point in the history
…lections#8489)

* Fix OpenNebula inventory crash when NIC does not have IP

Match IPv6 behaviour.

When a NIC does not have an IP:
  File "ansible/inventory/manager.py", line 292, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "ansible-cm/plugins/inventory/opennebula.py", line 263, in parse
    self._populate()
  File "ansible-cm/plugins/inventory/opennebula.py", line 226, in _populate
    servers = self._retrieve_servers(filter_by_label)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "ansible-cm/plugins/inventory/opennebula.py", line 210, in _retrieve_servers
    server['v4_first_ip'] = self._get_vm_ipv4(vm)
                            ^^^^^^^^^^^^^^^^^^^^^
  File "ansible-cm/plugins/inventory/opennebula.py", line 154, in _get_vm_ipv4
    return net['IP']

* Update to call to match IPv6 and add changelog fragment

* Update changelog fragment.

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
  • Loading branch information
2 people authored and Massl123 committed Feb 7, 2025
1 parent b18f51e commit 05ad202
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- opennebula inventory plugin - fix invalid reference to IP when inventory runs against NICs with no IPv4 address (https://github.com/ansible-collections/community.general/pull/8489).
3 changes: 2 additions & 1 deletion plugins/inventory/opennebula.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ def _get_vm_ipv4(self, vm):
nic = [nic]

for net in nic:
return net['IP']
if net.get('IP'):
return net['IP']

return False

Expand Down

0 comments on commit 05ad202

Please sign in to comment.