Merge "Fix for the launchpad bug 1440649"

stable/ocata
Jenkins 8 years ago committed by Gerrit Code Review
commit 77ea0ad892
  1. 11
      networking_l2gw/services/l2gateway/plugin.py
  2. 30
      networking_l2gw/tests/unit/services/l2gateway/test_plugin.py

@ -214,14 +214,19 @@ class L2GatewayPlugin(l2gateway_db.L2GatewayMixin):
dst_ip=pl_dict.get('dst_ip')))
return physical_locator
def delete_port_mac(self, context, port_dict):
def delete_port_mac(self, context, port):
"""Process the deleted port and trigger the RPC
to delete from the gateway.
When the ML2 plugin invokes this call, the argument port is
a single port dict, whereas the L2gateway service plugin
sends it as a list of port dicts.
"""
mac_list = []
if not isinstance(port_dict, list):
port_list = [port_dict]
port_list = port
if not isinstance(port, list):
port_list = [port]
for port_dict in port_list:
if port_dict['device_owner']:
logical_switches = db.get_all_logical_switches_by_name(

@ -553,7 +553,7 @@ class TestL2GatewayPlugin(base.BaseTestCase):
self.context, ovsdb_identifier,
fake_logical_switch, fake_locator_dict, fake_dict)
def test_delete_port_mac(self):
def test_delete_port_mac_with_list(self):
network_id = 'fake_network_id'
fake_port_dict = {'network_id': 'fake_network_id',
'device_owner': 'fake_owner',
@ -581,6 +581,34 @@ class TestL2GatewayPlugin(base.BaseTestCase):
delete_rpc.assert_called_with(
self.context, 'fake_ovsdb_id', 'fake_uuid', ['fake_mac'])
def test_delete_port_mac(self):
network_id = 'fake_network_id'
fake_port_list = [{'network_id': 'fake_network_id',
'device_owner': 'fake_owner',
'mac_address': 'fake_mac',
'ovsdb_identifier': 'fake_ovsdb_id'}]
fake_logical_switch_dict = {'uuid': 'fake_uuid',
'ovsdb_identifier': 'fake_ovsdb_id'}
fake_logical_switch_list = [fake_logical_switch_dict]
fake_dict = {'mac': 'fake_mac',
'logical_switch_uuid': 'fake_uuid',
'ovsdb_identifier': 'fake_ovsdb_id'}
with contextlib.nested(
mock.patch.object(db,
'get_all_logical_switches_by_name',
return_value=fake_logical_switch_list),
mock.patch.object(db,
'get_ucast_mac_remote_by_mac_and_ls',
return_value=True),
mock.patch.object(l2gw_plugin.L2gatewayAgentApi,
'delete_vif_from_gateway')) as (
get_ls, get_mac, delete_rpc):
self.plugin.delete_port_mac(self.context, fake_port_list)
get_ls.assert_called_with(self.context, network_id)
get_mac.assert_called_with(self.context, fake_dict)
delete_rpc.assert_called_with(
self.context, 'fake_ovsdb_id', 'fake_uuid', ['fake_mac'])
def test_delete_l2_gateway_connection(self):
self.db_context = ctx.get_admin_context()
fake_conn_dict = {'l2_gateway_id': 'fake_l2gw_id',

Loading…
Cancel
Save