]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix port status not being updated properly
authorDarragh O'Reilly <darragh.oreilly@hp.com>
Wed, 18 Mar 2015 20:45:10 +0000 (20:45 +0000)
committerDarragh O'Reilly <darragh.oreilly@hp.com>
Tue, 24 Mar 2015 09:57:20 +0000 (09:57 +0000)
This problem was introduced by hierarchical port bindings and
affected ports bound on linuxbridge hosts as that agent only
passes the first 11 chars of the port_id to the plugin.

Closes-Bug: 1433461
Change-Id: I8a3863ac1bb1c359de210c535462acbb107adf98

neutron/plugins/ml2/plugin.py
neutron/tests/unit/ml2/test_ml2_plugin.py

index 5fca2bc4ed3732a7023f5deef0d7b1b460b774df..2e47ad62f8376b30d00509cf3ddcb041df95c2ec 100644 (file)
@@ -1337,7 +1337,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
                 updated_port = self._make_port_dict(port)
                 network = self.get_network(context,
                                            original_port['network_id'])
-                levels = db.get_binding_levels(session, port_id,
+                levels = db.get_binding_levels(session, port.id,
                                                port.port_binding.host)
                 mech_context = driver_context.PortContext(
                     self, context, updated_port, network, port.port_binding,
index c9ccf773b07c29444aaa0f6360bb0548784e488b..a9fcbc7e5cc825e626f0c0973504d1f1c0f0a163 100644 (file)
@@ -270,6 +270,17 @@ class TestMl2PortsV2(test_plugin.TestPortsV2, Ml2PluginV2TestCase):
             self.assertEqual('DOWN', port['port']['status'])
             self.assertEqual('DOWN', self.port_create_status)
 
+    def test_update_port_status_short_id(self):
+        ctx = context.get_admin_context()
+        plugin = manager.NeutronManager.get_plugin()
+        with self.port() as port:
+            with mock.patch.object(ml2_db, 'get_binding_levels',
+                                   return_value=[]) as mock_gbl:
+                port_id = port['port']['id']
+                short_id = port_id[:11]
+                plugin.update_port_status(ctx, short_id, 'UP')
+                mock_gbl.assert_called_once_with(mock.ANY, port_id, mock.ANY)
+
     def test_update_port_mac(self):
         self.check_update_port_mac(
             host_arg={portbindings.HOST_ID: HOST},