ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
816 stars 1.5k forks source link

Fix OpenNebula inventory crash when NIC does not have IP #8489

Closed aioue closed 3 months ago

aioue commented 3 months ago
SUMMARY

Fix OpenNebula inventory crash when NIC does not have IP.

Now matches IPv6 behaviour.

ISSUE TYPE

community.general.opennebula

ADDITIONAL INFORMATION

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']
ansibullbot commented 3 months ago

cc @feldsam click here for bot help

aioue commented 3 months ago

Updated as per your suggestion and changelog fragment added. Thank you for your review.

felixfontein commented 3 months ago

I'll merge tomorrow if nobody objects.

patchback[bot] commented 3 months ago

Backport to stable-8: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-8/3716187fc35cb9ea8a0722745124bf2d9399246a/pr-8489

Backported as https://github.com/ansible-collections/community.general/pull/8518

🤖 @patchback I'm built with octomachinery and my source is open — https://github.com/sanitizers/patchback-github-app.

patchback[bot] commented 3 months ago

Backport to stable-9: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-9/3716187fc35cb9ea8a0722745124bf2d9399246a/pr-8489

Backported as https://github.com/ansible-collections/community.general/pull/8519

🤖 @patchback I'm built with octomachinery and my source is open — https://github.com/sanitizers/patchback-github-app.

felixfontein commented 3 months ago

@aioue thanks for your contribution!