Merge "Delete port binding level for deleted bindings"

This commit is contained in:
Zuul 2019-03-05 15:41:45 +00:00 committed by Gerrit Code Review
commit 8b7370a934
2 changed files with 22 additions and 1 deletions

View File

@ -2293,5 +2293,9 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
@utils.transaction_guard @utils.transaction_guard
@db_api.retry_if_session_inactive() @db_api.retry_if_session_inactive()
def delete_port_binding(self, context, host, port_id): def delete_port_binding(self, context, host, port_id):
ports_obj.PortBinding.delete_objects(context, host=host, ports_obj.PortBinding.delete_objects(context,
host=host,
port_id=port_id) port_id=port_id)
db.clear_binding_levels(context,
port_id=port_id,
host=host)

View File

@ -1663,6 +1663,23 @@ class TestMl2PluginOnly(Ml2PluginV2TestCase):
self.assertEqual(port_id, ml2_plugin.Ml2Plugin._device_to_port_id( self.assertEqual(port_id, ml2_plugin.Ml2Plugin._device_to_port_id(
self.context, port_id)) self.context, port_id))
@mock.patch.object(ml2_db, 'clear_binding_levels')
@mock.patch.object(port_obj.PortBinding, 'delete_objects')
def test_delete_port_binding_delete_binding_and_levels(
self,
clear_bl_mock,
delete_port_binding_mock):
port_id = uuidutils.generate_uuid()
host = 'fake-host'
plugin = directory.get_plugin()
plugin.delete_port_binding(self.context, host, port_id)
self.assertTrue(clear_bl_mock.called_with(self.context,
port_id=port_id,
host=host))
self.assertTrue(delete_port_binding_mock.called_with(self.context,
host=host,
port_id=port_id))
class Test_GetNetworkMtu(Ml2PluginV2TestCase): class Test_GetNetworkMtu(Ml2PluginV2TestCase):