inventory: Ignore errors connecting to libvirt

If one of the VM hosts is offline, we still want to be able to generate
the inventory from the other host.
This commit is contained in:
2025-07-27 12:35:30 -05:00
parent 53c0107651
commit fad63d5973

View File

@@ -101,10 +101,14 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
assert self.inventory
for uri in uri_list:
if read_only:
conn = libvirt.openReadOnly(uri)
else:
conn = libvirt.open(uri)
try:
if read_only:
conn = libvirt.openReadOnly(uri)
else:
conn = libvirt.open(uri)
except libvirt.libvirtError as e:
log.error('Unable to open to libvirt URI: %s', e)
continue
for dom in conn.listAllDomains():
host = Host(dom)
state = host.get_state()[0]