From: Darragh O'Reilly Date: Wed, 18 Mar 2015 20:45:10 +0000 (+0000) Subject: Fix port status not being updated properly X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=355ab2f31cf81575c6e1c0899526177711425428;p=openstack-build%2Fneutron-build.git Fix port status not being updated properly 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 --- diff --git a/neutron/plugins/ml2/plugin.py b/neutron/plugins/ml2/plugin.py index 5fca2bc4e..2e47ad62f 100644 --- a/neutron/plugins/ml2/plugin.py +++ b/neutron/plugins/ml2/plugin.py @@ -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, diff --git a/neutron/tests/unit/ml2/test_ml2_plugin.py b/neutron/tests/unit/ml2/test_ml2_plugin.py index c9ccf773b..a9fcbc7e5 100644 --- a/neutron/tests/unit/ml2/test_ml2_plugin.py +++ b/neutron/tests/unit/ml2/test_ml2_plugin.py @@ -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},