Skip to content

Commit 794334e

Browse files
committed
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
1 parent b52ae93 commit 794334e

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

openstackclient/compute/v2/server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2586,9 +2586,9 @@ def take_action(self, parsed_args):
25862586
columns += ('Metadata',)
25872587
column_headers += ('Properties',)
25882588

2589-
# convert back to tuple
2590-
column_headers = tuple(column_headers)
2591-
columns = tuple(columns)
2589+
# remove duplicates
2590+
column_headers = tuple(dict.fromkeys(column_headers))
2591+
columns = tuple(dict.fromkeys(columns))
25922592

25932593
if parsed_args.marker is not None:
25942594
# Check if both "--marker" and "--deleted" are used.

openstackclient/tests/unit/compute/v2/test_server.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4706,6 +4706,7 @@ def test_server_list_column_option(self):
47064706
self.assertIn('Availability Zone', columns)
47074707
self.assertIn('Host', columns)
47084708
self.assertIn('Properties', columns)
4709+
self.assertCountEqual(columns, set(columns))
47094710

47104711
def test_server_list_no_name_lookup_option(self):
47114712
self.data = tuple(

0 commit comments

Comments
 (0)