Merge "ml2: Add original port to context on _bind_port"
This commit is contained in:
commit
937e9546f3
@ -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.
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user