LLC Hook: Do not assume interfaces are added to Ironic

The current local_link_connection hook assumes that all inspected
interfaces are either added to or already exist in ironic as ports. When
CONF.processing.add_ports is set to PXE, and a node has more interfaces
than the one that we PXE on, then there will be more interfaces in the
inventory than added to Ironic. This patch ensures we must handle that
scenario.

Change-Id: I42c98c571ae8cfc26f319b712b5ac5bad88bb75d
Closes-Bug: #1628991
This commit is contained in:
Sam Betts 2016-09-29 18:02:25 +01:00
parent 20d941eeb1
commit c18d3cf450
3 changed files with 16 additions and 1 deletions

View File

@ -97,7 +97,12 @@ class GenericLocalLinkConnectionHook(base.ProcessingHook):
continue
mac_address = iface['mac_address']
port = ironic_ports[mac_address]
port = ironic_ports.get(mac_address)
if not port:
LOG.debug("Skipping LLC processing for interface %s, matching "
"port not found in Ironic.", mac_address,
node_info=node_info, data=introspection_data)
continue
lldp_data = iface.get('lldp')
if lldp_data is None:

View File

@ -122,6 +122,13 @@ class TestGenericLocalLinkConnectionHook(test_base.NodeTest):
self.hook.before_update(self.data, self.node_info)
self.assertCalledWithPatch(patches, mock_patch)
@mock.patch.object(node_cache.NodeInfo, 'patch_port')
def test_interface_not_in_ironic(self, mock_patch):
self.node_info._ports = {}
patches = []
self.hook.before_update(self.data, self.node_info)
self.assertCalledWithPatch(patches, mock_patch)
def test_no_inventory(self):
del self.data['inventory']
self.assertRaises(utils.Error, self.hook.before_update,

View File

@ -0,0 +1,3 @@
---
fixes:
- LLC hook no longer assumes all inspected ports are added to ironic