From 8b19db164aa9ecdf2c0bbc97f6e2799f15cebf27 Mon Sep 17 00:00:00 2001 From: Hongbin Lu Date: Tue, 8 May 2018 22:35:35 +0000 Subject: [PATCH] Annotate filter parameters for tag attributes * Add additional attributes 'tags-any', 'not-tags' and 'not-tags-any' to the attribute map. These three attributes represent the query parameters on list request. * Add 'is_filter' keyword for attributes 'tags', 'tags-any', 'not-tags' and 'not-tags-any'. This indicates that these four attributes can be used as filter parameters. In the future, we will rely on this metadata to perform filter validation: https://review.openstack.org/#/c/554368/ Change-Id: I9e2033e7ba9d198f96c1ce6089a809d6721dd82d Related-Bug: #1749820 --- neutron/extensions/tagging.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/neutron/extensions/tagging.py b/neutron/extensions/tagging.py index 449b5f380f2..b1029ff83b6 100644 --- a/neutron/extensions/tagging.py +++ b/neutron/extensions/tagging.py @@ -31,12 +31,22 @@ from neutron.db import standard_attr TAG = 'tag' TAGS = TAG + 's' +TAGS_ANY = TAGS + '-any' +NOT_TAGS = 'not-' + TAGS +NOT_TAGS_ANY = NOT_TAGS + '-any' MAX_TAG_LEN = 60 TAG_PLUGIN_TYPE = 'TAG' TAG_SUPPORTED_RESOURCES = standard_attr.get_tag_resource_parent_map() TAG_ATTRIBUTE_MAP = { - TAGS: {'allow_post': False, 'allow_put': False, 'is_visible': True} + TAGS: {'allow_post': False, 'allow_put': False, + 'is_visible': True, 'is_filter': True}, + TAGS_ANY: {'allow_post': False, 'allow_put': False, + 'is_visible': False, 'is_filter': True}, + NOT_TAGS: {'allow_post': False, 'allow_put': False, + 'is_visible': False, 'is_filter': True}, + NOT_TAGS_ANY: {'allow_post': False, 'allow_put': False, + 'is_visible': False, 'is_filter': True}, }