From dcebb77d9d7a2cebcc645dd632a12d224bd113c8 Mon Sep 17 00:00:00 2001 From: Moshe Levi Date: Tue, 27 Feb 2018 21:09:14 +0200 Subject: [PATCH] Don't validate local_link_connection when port has client-id Infiniband ports do not require the local_link_connection field to be populated as the network topology is discoverable by the Infiniband Subnet Manager. This change removes the requirement for local_link_connection for Infiniband ports. Infiniband ports have a client-id in their extra field. Closes-Bug: #1753222 Change-Id: I2bfac4ccaf825bd9aa8ea0d2b447fcd7767acbc5 --- ironic/common/neutron.py | 6 +++++ ironic/tests/unit/common/test_neutron.py | 27 +++++++++++++++++++ ...n-port-has-client-id-8e584586dc4fca50.yaml | 7 +++++ 3 files changed, 40 insertions(+) create mode 100644 releasenotes/notes/dont-validate-local_link_connection-when-port-has-client-id-8e584586dc4fca50.yaml diff --git a/ironic/common/neutron.py b/ironic/common/neutron.py index 8d260ef4d2..d05cf72496 100644 --- a/ironic/common/neutron.py +++ b/ironic/common/neutron.py @@ -453,6 +453,12 @@ def validate_port_info(node, port): :param port: Ironic port object. :returns: True if port info is valid, False otherwise. """ + # Note(moshele): client-id in the port extra field indicates an InfiniBand + # port. In this case we don't require local_link_connection to be + # populated because the network topology is discoverable by the Infiniband + # Subnet Manager. + if port.extra.get('client-id'): + return True if (node.network_interface == 'neutron' and not port.local_link_connection): LOG.warning("The local_link_connection is required for " diff --git a/ironic/tests/unit/common/test_neutron.py b/ironic/tests/unit/common/test_neutron.py index 15cb50e686..9efb9d8cdb 100644 --- a/ironic/tests/unit/common/test_neutron.py +++ b/ironic/tests/unit/common/test_neutron.py @@ -528,6 +528,33 @@ class TestNeutronNetworkActions(db_base.DbTestCase): self.assertTrue(res) self.assertFalse(log_mock.warning.called) + @mock.patch.object(neutron, 'LOG', autospec=True) + def test_validate_port_info_flat_interface_with_client_id(self, log_mock): + self.node.network_interface = 'flat' + self.node.save() + llc = {} + port = object_utils.create_test_port( + self.context, node_id=self.node.id, uuid=uuidutils.generate_uuid(), + address='52:54:00:cf:2d:33', local_link_connection=llc, + extra={'client-id': self._CLIENT_ID}) + res = neutron.validate_port_info(self.node, port) + self.assertTrue(res) + self.assertFalse(log_mock.warning.called) + + @mock.patch.object(neutron, 'LOG', autospec=True) + def test_validate_port_info_neutron_interface_with_client_id( + self, log_mock): + self.node.network_interface = 'neutron' + self.node.save() + llc = {} + port = object_utils.create_test_port( + self.context, node_id=self.node.id, uuid=uuidutils.generate_uuid(), + address='52:54:00:cf:2d:33', local_link_connection=llc, + extra={'client-id': self._CLIENT_ID}) + res = neutron.validate_port_info(self.node, port) + self.assertTrue(res) + self.assertFalse(log_mock.warning.called) + @mock.patch.object(neutron, 'get_client', autospec=True) class TestValidateNetwork(base.TestCase): diff --git a/releasenotes/notes/dont-validate-local_link_connection-when-port-has-client-id-8e584586dc4fca50.yaml b/releasenotes/notes/dont-validate-local_link_connection-when-port-has-client-id-8e584586dc4fca50.yaml new file mode 100644 index 0000000000..d7d83bb899 --- /dev/null +++ b/releasenotes/notes/dont-validate-local_link_connection-when-port-has-client-id-8e584586dc4fca50.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fixes an issue with validation of Infiniband ports. Infiniband ports do not + require the ``local_link_connection`` field to be populated as the network + topology is discoverable by the Infiniband Subnet Manager. See `bug 1753222 + `_ for details.