]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
NSX: Fix newly created port's status should be DOWN
authorAaron Rosen <aaronorosen@gmail.com>
Wed, 12 Feb 2014 22:25:31 +0000 (14:25 -0800)
committerThomas Goirand <thomas@goirand.fr>
Thu, 13 Mar 2014 07:20:32 +0000 (15:20 +0800)
Previously when creating a port in neutron using the nsx plugin
the port status returned would be ACTIVE even if this was not the
case. Now, DOWN is returned which will be updated by the backend
when the port goes ACTIVE.

Change-Id: I600fb1292ae79146cb14c7e23170262973878de0
Closes-bug: #1279551

neutron/plugins/nicira/NeutronPlugin.py
neutron/tests/unit/vmware/test_nsx_plugin.py
neutron/tests/unit/vmware/test_nsx_sync.py

index bad803cdebdee1c6ad4e0182d0e4d113f952940f..db5c7bc4b955aa34d3087314c8a6971597982d14 100644 (file)
@@ -1129,6 +1129,8 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
         # ATTR_NOT_SPECIFIED is for the case where a port is created on a
         # shared network that is not owned by the tenant.
         port_data = port['port']
+        # Set port status as 'DOWN'. This will be updated by backend sync.
+        port_data['status'] = constants.PORT_STATUS_DOWN
         with context.session.begin(subtransactions=True):
             # First we allocate port in neutron database
             neutron_db = super(NvpPluginV2, self).create_port(context, port)
index 73543cddb1c31c355ca3734ff8c5d6e3c7e21773..2e9de71a2e1322aa17fe69b38b2c87bd6dc25065 100644 (file)
@@ -112,6 +112,8 @@ class NsxPluginV2TestCase(test_plugin.NeutronDbPluginV2TestCase):
             self.fc.fake_request)
         super(NsxPluginV2TestCase, self).setUp(plugin=plugin,
                                                ext_mgr=ext_mgr)
+        # Newly created port's status is always 'DOWN' till NSX wires them.
+        self.port_create_status = constants.PORT_STATUS_DOWN
         cfg.CONF.set_override('metadata_mode', None, 'NSX')
         self.addCleanup(self.fc.reset_all)
         self.addCleanup(mock.patch.stopall)
index 7a94fac43cae032d58aa4795139ec0e5a604acd1..1a89d0a6b3258c0a819f27823e34f46942c4bfe2 100644 (file)
@@ -584,16 +584,16 @@ class SyncTestCase(base.BaseTestCase):
             lp_uuid = self.fc._fake_lswitch_lport_dict.keys()[0]
             lport = self.fc._fake_lswitch_lport_dict[lp_uuid]
             q_port_id = self._get_tag_dict(lport['tags'])['q_port_id']
-            lport['status'] = 'false'
+            lport['status'] = 'true'
             q_port_data = self._plugin._get_port(ctx, q_port_id)
             self._plugin._synchronizer.synchronize_port(ctx, q_port_data)
             # Reload from db
             q_ports = self._plugin.get_ports(ctx)
             for q_port in q_ports:
                 if q_port['id'] == q_port_id:
-                    exp_status = constants.PORT_STATUS_DOWN
-                else:
                     exp_status = constants.PORT_STATUS_ACTIVE
+                else:
+                    exp_status = constants.PORT_STATUS_DOWN
                 self.assertEqual(exp_status, q_port['status'])
 
     def test_synchronize_port_on_get(self):