summaryrefslogtreecommitdiff
path: root/openstackclient/compute
diff options
context:
space:
mode:
authorStephen Finucane <sfinucan@redhat.com>2021-10-13 10:18:53 +0100
committerStephen Finucane <sfinucan@redhat.com>2021-10-13 12:51:28 +0100
commit3f4142d5ddfca8c594d35bb0e5fd65009286d11b (patch)
tree55450b83209c421b83a667facf7cb94471b713ba /openstackclient/compute
parent53f1efa010f9319ef939109d2ed5c4a852271d74 (diff)
downloadpython-openstackclient-3f4142d5ddfca8c594d35bb0e5fd65009286d11b.tar.gz
compute: Fix filtering servers by tags
The nova API expects the 'tags' and 'not-tags' filters of the 'GET /servers' (list servers) API to be a CSV string [1]: tags (Optional) A list of tags to filter the server list by. Servers that match all tags in this list will be returned. Boolean expression in this case is 't1 AND t2'. Tags in query must be separated by comma. New in version 2.26 not-tags (Optional) A list of tags to filter the server list by. Servers that don’t match all tags in this list will be returned. Boolean expression in this case is 'NOT (t1 AND t2)'. Tags in query must be separated by comma. New in version 2.26 We were instead providing a Python list, which was simply being URL encoded. Correct this. [1] https://docs.openstack.org/api-ref/compute/?expanded=list-servers-detail#list-servers Change-Id: Ie0251a0dccdf3385089e5bbaedf646a5e928cc48 Signed-off-by: Stephen Finucane <sfinucan@redhat.com> Closes-Bug: #1946816 (cherry picked from commit 53debe7fe1978f661768a27430f646a288948ecc) (cherry picked from commit cbc64f9469600624e74631f42ca214487e800155)
Diffstat (limited to 'openstackclient/compute')
-rw-r--r--openstackclient/compute/v2/server.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py
index b81d2a18..329d7d3e 100644
--- a/openstackclient/compute/v2/server.py
+++ b/openstackclient/compute/v2/server.py
@@ -2201,7 +2201,7 @@ class ListServer(command.Lister):
)
raise exceptions.CommandError(msg)
- search_opts['tags'] = parsed_args.tags
+ search_opts['tags'] = ','.join(parsed_args.tags)
if parsed_args.not_tags:
if compute_client.api_version < api_versions.APIVersion('2.26'):
@@ -2211,7 +2211,7 @@ class ListServer(command.Lister):
)
raise exceptions.CommandError(msg)
- search_opts['not-tags'] = parsed_args.not_tags
+ search_opts['not-tags'] = ','.join(parsed_args.not_tags)
if parsed_args.locked:
if compute_client.api_version < api_versions.APIVersion('2.73'):