Merge "Fix port_id filter not honored"
This commit is contained in:
commit
a7ad343909
@ -43,6 +43,11 @@ DEVICE_OWNER_ROUTER_INTF = l3_constants.DEVICE_OWNER_ROUTER_INTF
|
||||
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."""
|
||||
@ -714,6 +719,11 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
|
||||
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,
|
||||
|
@ -1345,6 +1345,15 @@ class L3NatDBTestCase(L3NatTestCaseBase):
|
||||
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"),
|
||||
|
Loading…
Reference in New Issue
Block a user