Skip to content

Commit

Permalink
[VNC API Server] API list resource ignores unknown filters
Browse files Browse the repository at this point in the history
If a resource type is listed with unknown filter(s), we should not take
care of that filter(s).

Change-Id: I1a98c03a178f80da89a72550bd1f553c622be010
Closes-Bug: #1657533
  • Loading branch information
Édouard Thuleau committed Jan 18, 2017
1 parent 839bc72 commit 1378173
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/config/api-server/tests/test_crud_basic.py
Expand Up @@ -950,6 +950,12 @@ def create_vns():
self.assertThat(obj_dict[0]['fq_name'][:-1],
Equals(proj_obj.fq_name))

# unanchored list with unknown filter
read_vn_objs = self._vnc_lib.virtual_networks_list(
parent_id=proj_obj.uuid,
filters={'foo': 'bar'})['virtual-networks']
self.assertEqual(len(read_vn_objs), num_objs)

# parent anchored detailed list without filters
read_vn_objs = self._vnc_lib.virtual_networks_list(
parent_id=proj_obj.uuid, detail=True)
Expand Down
5 changes: 4 additions & 1 deletion src/config/common/vnc_cassandra.py
Expand Up @@ -975,7 +975,10 @@ def filter_rows(coll_infos, filters=None):
return coll_infos

filtered_infos = {}
columns = ['prop:%s' % filter_key for filter_key in filters]
columns = ['prop:%s' % filter_key for filter_key in filters if
filter_key in obj_class.prop_fields]
if not columns:
return coll_infos
rows = self.multiget(self._OBJ_UUID_CF_NAME,
coll_infos.keys(),
columns=columns)
Expand Down
4 changes: 3 additions & 1 deletion src/config/common/vnc_rdbms.py
Expand Up @@ -1078,7 +1078,9 @@ def object_list(self, res_type, parent_uuids=None, back_ref_uuids=None,

if filters:
for key, value in filters.iteritems():
value = [ json.dumps(v) for v in value]
if key not in obj_class.prop_fields:
continue
value = [json.dumps(v) for v in value]
sqa_objs = sqa_objs.filter(getattr(sqa_class, key).in_(value))

if count:
Expand Down

0 comments on commit 1378173

Please sign in to comment.