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:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user