Skip to content

Commit

Permalink
Fix server list error with --long and -c options
Browse files Browse the repository at this point in the history
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
  • Loading branch information
thobiast committed Dec 14, 2022
1 parent b52ae93 commit 794334e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions openstackclient/compute/v2/server.py
Expand Up @@ -2586,9 +2586,9 @@ def take_action(self, parsed_args):
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.
Expand Down
1 change: 1 addition & 0 deletions openstackclient/tests/unit/compute/v2/test_server.py
Expand Up @@ -4706,6 +4706,7 @@ def test_server_list_column_option(self):
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(
Expand Down

0 comments on commit 794334e

Please sign in to comment.