Skip to content

Commit e157365

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Allow port list to shown undefined attributes"
2 parents e438c34 + 0626f95 commit e157365

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

openstackclient/network/v2/port.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,9 +584,11 @@ def take_action(self, parsed_args):
584584

585585
data = network_client.ports(**filters)
586586

587-
return (column_headers,
587+
headers, attrs = utils.calculate_header_and_attrs(
588+
column_headers, columns, parsed_args)
589+
return (headers,
588590
(utils.get_item_properties(
589-
s, columns,
591+
s, attrs,
590592
formatters=_formatters,
591593
) for s in data))
592594

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,16 @@ def test_port_list(self):
131131
self.assertNotIn(mac1, item_map.values())
132132
self.assertIn(mac2, item_map.values())
133133

134+
# Test list with unknown fields
135+
json_output = json.loads(self.openstack(
136+
'port list -f json -c ID -c Name -c device_id'
137+
))
138+
id_list = [p['ID'] for p in json_output]
139+
self.assertIn(id1, id_list)
140+
self.assertIn(id2, id_list)
141+
# Check an unknown field exists
142+
self.assertIn('device_id', json_output[0])
143+
134144
def test_port_set(self):
135145
"""Test create, set, show, delete"""
136146
name = uuid.uuid4().hex

0 commit comments

Comments
 (0)