diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py index a09fd44d0a..9180361dee 100644 --- a/openstackclient/compute/v2/server.py +++ b/openstackclient/compute/v2/server.py @@ -2204,7 +2204,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'): @@ -2214,7 +2214,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'): diff --git a/openstackclient/tests/unit/compute/v2/test_server.py b/openstackclient/tests/unit/compute/v2/test_server.py index 57840cb076..2f83fa2bd3 100644 --- a/openstackclient/tests/unit/compute/v2/test_server.py +++ b/openstackclient/tests/unit/compute/v2/test_server.py @@ -4269,7 +4269,7 @@ class TestServerList(TestServer): parsed_args = self.check_parser(self.cmd, arglist, verifylist) columns, data = self.cmd.take_action(parsed_args) - self.search_opts['tags'] = ['tag1', 'tag2'] + self.search_opts['tags'] = 'tag1,tag2' self.servers_mock.list.assert_called_with(**self.kwargs) @@ -4312,7 +4312,7 @@ class TestServerList(TestServer): parsed_args = self.check_parser(self.cmd, arglist, verifylist) columns, data = self.cmd.take_action(parsed_args) - self.search_opts['not-tags'] = ['tag1', 'tag2'] + self.search_opts['not-tags'] = 'tag1,tag2' self.servers_mock.list.assert_called_with(**self.kwargs) diff --git a/releasenotes/notes/bug-1946816-7665858605453578.yaml b/releasenotes/notes/bug-1946816-7665858605453578.yaml new file mode 100644 index 0000000000..f9e8406a9e --- /dev/null +++ b/releasenotes/notes/bug-1946816-7665858605453578.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Filtering servers by tags (``server list --tag``, + ``server list --not-tag``) now works correctly. + [Bug `1946816 `_]