diff options
author | Thobias Salazar Trevisan <thobiast@gmail.com> | 2022-10-24 14:20:44 -0300 |
---|---|---|
committer | Thobias Salazar Trevisan <thobiast@gmail.com> | 2022-12-14 15:19:08 -0300 |
commit | 794334ec2405bcfe086b3a56c796a9b6c2f7c685 (patch) | |
tree | 5422243a25077335484cdc348643010e7f790dd9 | |
parent | b52ae93cd2f18e23185685b4984b466e92635531 (diff) | |
download | python-openstackclient-794334ec2405bcfe086b3a56c796a9b6c2f7c685.tar.gz |
Fix server list error with --long and -c options
Using options --long and -c and specifying same columns added
by --long option, it passes duplicated column names to prettytable and
report the following error:
Field names must be unique!
This patch removes duplicated columns.
Change-Id: I9c0bd09c50dac568ca1980a6b53a6c544b85c2aa
-rw-r--r-- | openstackclient/compute/v2/server.py | 6 | ||||
-rw-r--r-- | openstackclient/tests/unit/compute/v2/test_server.py | 1 |
2 files changed, 4 insertions, 3 deletions
diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py index 3fb9bf09..fff67ff7 100644 --- a/openstackclient/compute/v2/server.py +++ b/openstackclient/compute/v2/server.py @@ -2586,9 +2586,9 @@ class ListServer(command.Lister): columns += ('Metadata',) column_headers += ('Properties',) - # convert back to tuple - column_headers = tuple(column_headers) - columns = tuple(columns) + # remove duplicates + column_headers = tuple(dict.fromkeys(column_headers)) + columns = tuple(dict.fromkeys(columns)) if parsed_args.marker is not None: # Check if both "--marker" and "--deleted" are used. diff --git a/openstackclient/tests/unit/compute/v2/test_server.py b/openstackclient/tests/unit/compute/v2/test_server.py index d7e84ba3..16ec9e12 100644 --- a/openstackclient/tests/unit/compute/v2/test_server.py +++ b/openstackclient/tests/unit/compute/v2/test_server.py @@ -4706,6 +4706,7 @@ class TestServerList(_TestServerList): self.assertIn('Availability Zone', columns) self.assertIn('Host', columns) self.assertIn('Properties', columns) + self.assertCountEqual(columns, set(columns)) def test_server_list_no_name_lookup_option(self): self.data = tuple( |