diff --git a/neutron/plugins/ml2/plugin.py b/neutron/plugins/ml2/plugin.py index 5bf0de5278f..61f87b10f41 100644 --- a/neutron/plugins/ml2/plugin.py +++ b/neutron/plugins/ml2/plugin.py @@ -421,7 +421,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2, self._update_port_dict_binding(port, new_binding) new_context = driver_context.PortContext( self, orig_context._plugin_context, port, - orig_context.network.current, new_binding, None) + orig_context.network.current, new_binding, None, + original_port=orig_context.original) # Attempt to bind the port and return the context with the # result. diff --git a/neutron/tests/unit/plugins/ml2/test_plugin.py b/neutron/tests/unit/plugins/ml2/test_plugin.py index e8db6ebaa20..a41e807bc0d 100644 --- a/neutron/tests/unit/plugins/ml2/test_plugin.py +++ b/neutron/tests/unit/plugins/ml2/test_plugin.py @@ -1741,6 +1741,20 @@ class TestMl2PortBinding(Ml2PluginV2TestCase, self.context, 'foo_port_id', {'port': port}) self.assertFalse(mock_dist.called) + def test__bind_port_original_port_set(self): + plugin = directory.get_plugin() + plugin.mechanism_manager = mock.Mock() + mock_port = {'id': 'port_id'} + context = mock.Mock() + context.network.current = {'id': 'net_id'} + context.original = mock_port + with mock.patch.object(plugin, '_update_port_dict_binding'), \ + mock.patch.object(segments_db, 'get_network_segments', + return_value=[]): + new_context = plugin._bind_port(context) + self.assertEqual(mock_port, new_context.original) + self.assertFalse(new_context == context) + class TestMl2PortBindingNoSG(TestMl2PortBinding): HAS_PORT_FILTER = False