From ca92ebdf968bef67e5259cdacce27c2cab84bd8a Mon Sep 17 00:00:00 2001 From: Kevin Benton Date: Tue, 16 Sep 2014 20:36:42 -0700 Subject: [PATCH] Set floating IP port status to "N/A" The status of the port associated with a floating IP would always show as DOWN. This caused confusion to operators that weren't aware that this is expected behavior since the port is only used for an IP allocation. This commit sets the port status to "N/A" to reflect the fact that the port associated with a floating IP has no operational status. DocImpact APIImpact Closes-Bug: #1196851 Change-Id: I2f94afa001b213d61f0e5892aae2e6e6de98fe4c --- neutron/common/constants.py | 1 + neutron/db/l3_db.py | 1 + neutron/plugins/ml2/plugin.py | 3 ++- neutron/tests/unit/ibm/test_sdnve_plugin.py | 3 +++ neutron/tests/unit/test_l3_plugin.py | 7 +++++++ 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/neutron/common/constants.py b/neutron/common/constants.py index 185c6d0d6..4839dde3e 100644 --- a/neutron/common/constants.py +++ b/neutron/common/constants.py @@ -24,6 +24,7 @@ PORT_STATUS_ACTIVE = 'ACTIVE' PORT_STATUS_BUILD = 'BUILD' PORT_STATUS_DOWN = 'DOWN' PORT_STATUS_ERROR = 'ERROR' +PORT_STATUS_NOTAPPLICABLE = 'N/A' FLOATINGIP_STATUS_ACTIVE = 'ACTIVE' FLOATINGIP_STATUS_DOWN = 'DOWN' diff --git a/neutron/db/l3_db.py b/neutron/db/l3_db.py index a07574c95..954f01da9 100644 --- a/neutron/db/l3_db.py +++ b/neutron/db/l3_db.py @@ -861,6 +861,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase): 'admin_state_up': True, 'device_id': fip_id, 'device_owner': DEVICE_OWNER_FLOATINGIP, + 'status': l3_constants.PORT_STATUS_NOTAPPLICABLE, 'name': ''} if fip.get('floating_ip_address'): diff --git a/neutron/plugins/ml2/plugin.py b/neutron/plugins/ml2/plugin.py index c4dfe26ca..0f42741f8 100644 --- a/neutron/plugins/ml2/plugin.py +++ b/neutron/plugins/ml2/plugin.py @@ -931,7 +931,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2, def _create_port_db(self, context, port): attrs = port[attributes.PORT] - attrs['status'] = const.PORT_STATUS_DOWN + if not attrs.get('status'): + attrs['status'] = const.PORT_STATUS_DOWN session = context.session with session.begin(subtransactions=True): diff --git a/neutron/tests/unit/ibm/test_sdnve_plugin.py b/neutron/tests/unit/ibm/test_sdnve_plugin.py index 3edb46172..82ba6181f 100644 --- a/neutron/tests/unit/ibm/test_sdnve_plugin.py +++ b/neutron/tests/unit/ibm/test_sdnve_plugin.py @@ -122,3 +122,6 @@ class IBMPluginRouterTestCase(test_l3_plugin.L3NatDBIntTestCase): 'Client', new=MockClient)): super(IBMPluginRouterTestCase, self).setUp(plugin=_plugin_name) + + def test_floating_port_status_not_applicable(self): + self.skipTest('Plugin changes floating port status') diff --git a/neutron/tests/unit/test_l3_plugin.py b/neutron/tests/unit/test_l3_plugin.py index df3945816..2eb95469a 100644 --- a/neutron/tests/unit/test_l3_plugin.py +++ b/neutron/tests/unit/test_l3_plugin.py @@ -1658,6 +1658,13 @@ class L3NatTestCaseBase(L3NatTestCaseMixin): self.assertIsNotNone(body['floatingip']['fixed_ip_address']) self.assertIsNotNone(body['floatingip']['router_id']) + def test_floating_port_status_not_applicable(self): + with self.floatingip_with_assoc(): + port_body = self._list('ports', + query_params='device_owner=network:floatingip')['ports'][0] + self.assertEqual(l3_constants.PORT_STATUS_NOTAPPLICABLE, + port_body['status']) + def test_floatingip_update( self, expected_status=l3_constants.FLOATINGIP_STATUS_ACTIVE): with self.port() as p: -- 2.45.2