Skip to content

Commit 4dbfc47

Browse files
committed
Return the port column headers expected in the list command
In [1], it was added the ability to print in the "port list" command any field not defined in the hardcoded column set for this command. But in [2], it was added a filter list in the API call in order to reduce the CLI execution time. The unintentional drawback of this optimization was that is no longer possible to print any field outside the "port list" column set. Because the optimization if preferred and it is always possible to use "port show" to see all the port fields, the code added in [1] is removed. [1]https://review.opendev.org/c/openstack/python-openstackclient/+/522901 [2]https://review.opendev.org/c/openstack/python-openstackclient/+/754117 Closes-Bug: #2098980 Related-Bug: #1707848 Related-Bug: #1897100 Change-Id: Ia944b8e108c454219d642cfa595ffafdf060a57f
1 parent 2e5a830 commit 4dbfc47

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

openstackclient/network/v2/port.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -944,15 +944,12 @@ def take_action(self, parsed_args):
944944
for item in columns
945945
]
946946

947-
headers, attrs = utils.calculate_header_and_attrs(
948-
column_headers, columns, parsed_args
949-
)
950947
return (
951-
headers,
948+
column_headers,
952949
(
953950
utils.get_item_properties(
954951
s,
955-
attrs,
952+
columns,
956953
formatters=_list_formatters,
957954
)
958955
for s in data

openstackclient/tests/functional/network/v2/test_port.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
import uuid
1414

15+
from tempest.lib import exceptions as tempest_exc
16+
1517
from openstackclient.tests.functional.network.v2 import common
1618

1719

@@ -162,8 +164,16 @@ def test_port_list(self):
162164
id_list = [p['ID'] for p in json_output]
163165
self.assertIn(id1, id_list)
164166
self.assertIn(id2, id_list)
165-
# Check an unknown field exists
166-
self.assertIn('device_id', json_output[0])
167+
# Check an unknown field does not exist
168+
self.assertNotIn('device_id', json_output[0])
169+
170+
# Test list with only unknown fields
171+
exc = self.assertRaises(
172+
tempest_exc.CommandFailed,
173+
self.openstack,
174+
'port list -c device_id',
175+
)
176+
self.assertIn("No recognized column names in ['device_id']", str(exc))
167177

168178
def test_port_set(self):
169179
"""Test create, set, show, delete"""

0 commit comments

Comments
 (0)