Do not filter pools by attributes when non are provided

This change stops the AttributeFilter from filtering when no
attributes were provided.

This also removes the pool_id attribte from the request, as this
is used in a different filter.

Change-Id: If57d81e0343fa442828da7390bf20249f4791861
This commit is contained in:
Graham Hayes 2018-02-18 16:16:16 +00:00
parent 9a89306b89
commit c6ee02d71a
1 changed files with 11 additions and 0 deletions

View File

@ -69,6 +69,17 @@ class AttributeFilter(base.Filter):
except exceptions.RelationNotLoaded:
pool_attributes = {}
# Remove the "pool_id" attribute, that is used in
# PoolIDAttributeFilter. If the item is not in the dict, it is
# fine, we should just continue.
pool_attributes.pop('pool_id', None)
if pool_attributes == {}:
# If we did not send any attribute to filter on, we should
# not filter the pools based on an empty set, as this will
# return no pools.
return True
# Check if the keys requested exist in this pool
if not {key for key in six.iterkeys(pool_attributes)}.issuperset(
zone_attributes):