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
This commit is contained in:
Thobias Salazar Trevisan 2022-10-24 14:20:44 -03:00
parent b52ae93cd2
commit 794334ec24
2 changed files with 4 additions and 3 deletions

View File

@ -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.

View File

@ -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(