Skip to content

Commit

Permalink
Merge "Fix port_id filter not honored" into stable/grizzly
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed May 2, 2013
2 parents 9fda3ca + e576736 commit 1385a81
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions quantum/db/l3_db.py
Expand Up @@ -44,6 +44,11 @@
DEVICE_OWNER_ROUTER_GW = l3_constants.DEVICE_OWNER_ROUTER_GW
DEVICE_OWNER_FLOATINGIP = l3_constants.DEVICE_OWNER_FLOATINGIP

# Maps API field to DB column
# API parameter name and Database column names may differ.
# Useful to keep the filtering between API and Database.
API_TO_DB_COLUMN_MAP = {'port_id': 'fixed_port_id'}


class Router(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
"""Represents a v2 quantum router."""
Expand Down Expand Up @@ -721,6 +726,11 @@ def get_floatingips(self, context, filters=None, fields=None,
page_reverse=False):
marker_obj = self._get_marker_obj(context, 'floatingip', limit,
marker)
if filters is not None:
for key, val in API_TO_DB_COLUMN_MAP.iteritems():
if key in filters:
filters[val] = filters.pop(key)

return self._get_collection(context, FloatingIP,
self._make_floatingip_dict,
filters=filters, fields=fields,
Expand Down
9 changes: 9 additions & 0 deletions quantum/tests/unit/test_l3_plugin.py
Expand Up @@ -1329,6 +1329,15 @@ def test_floatingip_list_with_sort(self):
self._delete('floatingips', fp2['floatingip']['id'])
self._delete('floatingips', fp3['floatingip']['id'])

def test_floatingip_list_with_port_id(self):
with self.floatingip_with_assoc() as fip:
port_id = fip['floatingip']['port_id']
res = self._list('floatingips',
query_params="port_id=%s" % port_id)
self.assertEqual(len(res['floatingips']), 1)
res = self._list('floatingips', query_params="port_id=aaa")
self.assertEqual(len(res['floatingips']), 0)

def test_floatingip_list_with_pagination(self):
with contextlib.nested(self.subnet(cidr="10.0.0.0/24"),
self.subnet(cidr="11.0.0.0/24"),
Expand Down

0 comments on commit 1385a81

Please sign in to comment.