]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Pass filters in arrays in get_agent_gw_ports_exist_for_network
authorCarl Baldwin <carl.baldwin@hp.com>
Wed, 30 Jul 2014 00:45:54 +0000 (00:45 +0000)
committerCarl Baldwin <carl.baldwin@hp.com>
Wed, 30 Jul 2014 03:58:26 +0000 (03:58 +0000)
Change-Id: I8925d7072b7cae7645e772b8a769a7e6f03ec64f
Closes-Bug: #1350119

neutron/db/l3_dvr_db.py
neutron/tests/unit/db/test_l3_dvr_db.py

index 5856cbbea139f0fbce19db8a87b8d1a30b58ec2c..844a318d1eddbd729f6e4ab22c413271fe6cbb1a 100644 (file)
@@ -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:
index 0e8070f734c1c7961fdb7f5d84199e82bf242c4d..caa288412b1ab12c9c6c64162dc6ca78ce361abf 100644 (file)
@@ -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]})