Check for no neutron network in inventory

The host network or SSH network specified with --overcloud-ssh-network
may not exist in Neutron. There is no requirement that it does. Add a
check and log a warning instead of trying to use the None object when
the network is not found. When it's not found, neutron data is not added
to the inventory.

Signed-off-by: James Slagle <jslagle@redhat.com>
Change-Id: I20d6ae39511e368e724522d133a133d1c864cb1b
This commit is contained in:
James Slagle 2021-06-29 19:37:54 -04:00
parent 5836974cf2
commit 1f7b1a963a
1 changed files with 9 additions and 4 deletions

View File

@ -500,10 +500,15 @@ class TripleoInventory(object):
found_ctlplane_port = False
ctlplane_net = self.connection.network.find_network(
self.host_network)
for p in ports:
if p.network_id == ctlplane_net.id:
found_ctlplane_port = True
break
if ctlplane_net:
for p in ports:
if p.network_id == ctlplane_net.id:
found_ctlplane_port = True
break
else:
LOG.warning("Host SSH network %s not found in neutron, not "
"using neutron data for inventory",
self.host_network)
if not found_ctlplane_port:
return None