Skip to content

Commit 449a0ca

Browse files
committed
Fix AttributeError when some ports don't have physnet
The base_physnet plugin base class checks the port list in the node cache to see if a physical_network field is set on the first port. It appears that in some cases the field might be set on the first port but not on one or more other ports. This change fixes this by checking all ports. Fixes: #7
1 parent d9a9f25 commit 449a0ca

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

stackhpc_inspector_plugins/plugins/base_physnet.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def _get_physnet_patch(self, physnet, port):
5858
:param port: The ironic port to patch.
5959
:returns: A dict to be used as a patch for the port, or None.
6060
"""
61+
# Bug is here.
6162
if (not CONF.processing.overwrite_existing or
6263
port.physical_network == physnet):
6364
return
@@ -67,12 +68,14 @@ def before_update(self, introspection_data, node_info, **kwargs):
6768
"""Process introspection data and patch port physical network."""
6869
inventory = utils.get_inventory(introspection_data)
6970

71+
LOG.info("Plugin: %s", type(self))
7072
# Use a client with a version set explicitly.
7173
client = ironic.get_client(api_version=REQUIRED_IRONIC_VERSION)
7274

7375
ironic_ports = node_info.ports()
7476
if (ironic_ports and
75-
not hasattr(ironic_ports.values()[0], 'physical_network')):
77+
not all(hasattr(port, 'physical_network')
78+
for port in ironic_ports.values())):
7679
# If the ports do not have a physical network field, use our newer
7780
# versioned client to fetch some that do.
7881
port_list = client.node.list_ports(node_info.uuid, limit=0,
@@ -93,6 +96,7 @@ def before_update(self, introspection_data, node_info, **kwargs):
9396
continue
9497

9598
# Determine the physical network for this port.
99+
# Port not touched in here.
96100
physnet = self.get_physnet(port, iface['name'], introspection_data)
97101
if physnet is None:
98102
LOG.debug("Skipping physical network processing for interface "

0 commit comments

Comments
 (0)