From 7a7291794eb718fc0a6105efacf88b2ee5594043 Mon Sep 17 00:00:00 2001 From: Carl Baldwin Date: Wed, 30 Jul 2014 00:45:54 +0000 Subject: [PATCH] Pass filters in arrays in get_agent_gw_ports_exist_for_network Change-Id: I8925d7072b7cae7645e772b8a769a7e6f03ec64f Closes-Bug: #1350119 --- neutron/db/l3_dvr_db.py | 7 +++---- neutron/tests/unit/db/test_l3_dvr_db.py | 13 +++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/neutron/db/l3_dvr_db.py b/neutron/db/l3_dvr_db.py index 5856cbbea..844a318d1 100644 --- a/neutron/db/l3_dvr_db.py +++ b/neutron/db/l3_dvr_db.py @@ -295,9 +295,9 @@ class L3_NAT_with_dvr_db_mixin(l3_db.L3_NAT_db_mixin, return filters = { - 'network_id': network_id, - 'device_id': agent_id, - 'device_owner': DEVICE_OWNER_AGENT_GW + 'network_id': [network_id], + 'device_id': [agent_id], + 'device_owner': [DEVICE_OWNER_AGENT_GW] } ports = self._core_plugin.get_ports(context, filters) if ports: @@ -346,7 +346,6 @@ class L3_NAT_with_dvr_db_mixin(l3_db.L3_NAT_db_mixin, context, l3_const.AGENT_TYPE_L3, host) if l3_agent_db: LOG.debug("Agent ID exists: %s", l3_agent_db['id']) - # TODO(Swami): is this call still valid for external agent gw port? f_port = self.get_agent_gw_ports_exist_for_network( context, network_id, host, l3_agent_db['id']) if not f_port: diff --git a/neutron/tests/unit/db/test_l3_dvr_db.py b/neutron/tests/unit/db/test_l3_dvr_db.py index 0e8070f73..caa288412 100644 --- a/neutron/tests/unit/db/test_l3_dvr_db.py +++ b/neutron/tests/unit/db/test_l3_dvr_db.py @@ -19,6 +19,7 @@ from neutron.common import constants as l3_const from neutron import context from neutron.db import api as db from neutron.db import l3_dvr_db +from neutron import manager from neutron.tests import base @@ -134,3 +135,15 @@ class L3DvrTestCase(base.BaseTestCase): def test__is_distributed_router_distributed(self): router = {'id': 'foo_router_id', 'distributed': True} self._test__is_distributed_router(router, True) + + def test_get_agent_gw_ports_exist_for_network(self): + with mock.patch.object(manager.NeutronManager, 'get_plugin') as gp: + plugin = mock.Mock() + gp.return_value = plugin + plugin.get_ports.return_value = [] + self.mixin.get_agent_gw_ports_exist_for_network( + self.ctx, 'network_id', 'host', 'agent_id') + plugin.get_ports.assert_called_with(self.ctx, { + 'network_id': ['network_id'], + 'device_id': ['agent_id'], + 'device_owner': [l3_const.DEVICE_OWNER_AGENT_GW]}) -- 2.45.2