Fix port_id filter not honored
Add dict. to map API params to DB columns Change-Id: I5f10eea77533e91afeb690e39301d7282e1b1620 Fixes: bug #1169706
This commit is contained in:
parent
b1b89da57f
commit
f639788c59
@ -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_ROUTER_GW = l3_constants.DEVICE_OWNER_ROUTER_GW
|
||||||
DEVICE_OWNER_FLOATINGIP = l3_constants.DEVICE_OWNER_FLOATINGIP
|
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):
|
class Router(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
|
||||||
"""Represents a v2 quantum router."""
|
"""Represents a v2 quantum router."""
|
||||||
@ -713,6 +718,11 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
|
|||||||
page_reverse=False):
|
page_reverse=False):
|
||||||
marker_obj = self._get_marker_obj(context, 'floatingip', limit,
|
marker_obj = self._get_marker_obj(context, 'floatingip', limit,
|
||||||
marker)
|
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,
|
return self._get_collection(context, FloatingIP,
|
||||||
self._make_floatingip_dict,
|
self._make_floatingip_dict,
|
||||||
filters=filters, fields=fields,
|
filters=filters, fields=fields,
|
||||||
|
@ -1328,6 +1328,15 @@ class L3NatDBTestCase(L3NatTestCaseBase):
|
|||||||
self._delete('floatingips', fp2['floatingip']['id'])
|
self._delete('floatingips', fp2['floatingip']['id'])
|
||||||
self._delete('floatingips', fp3['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):
|
def test_floatingip_list_with_pagination(self):
|
||||||
with contextlib.nested(self.subnet(cidr="10.0.0.0/24"),
|
with contextlib.nested(self.subnet(cidr="10.0.0.0/24"),
|
||||||
self.subnet(cidr="11.0.0.0/24"),
|
self.subnet(cidr="11.0.0.0/24"),
|
||||||
|
Loading…
Reference in New Issue
Block a user