Merge "Add a few selectable fields to the "openstack server list" output"
This commit is contained in:
commit
73d56bc8d4
@ -1715,6 +1715,27 @@ class ListServer(command.Lister):
|
|||||||
|
|
||||||
marker_id = None
|
marker_id = None
|
||||||
|
|
||||||
|
# support for additional columns
|
||||||
|
if parsed_args.columns:
|
||||||
|
# convert tuple to list to edit them
|
||||||
|
column_headers = list(column_headers)
|
||||||
|
columns = list(columns)
|
||||||
|
|
||||||
|
for c in parsed_args.columns:
|
||||||
|
if c in ('Project ID', 'project_id'):
|
||||||
|
columns.append('tenant_id')
|
||||||
|
column_headers.append('Project ID')
|
||||||
|
if c in ('User ID', 'user_id'):
|
||||||
|
columns.append('user_id')
|
||||||
|
column_headers.append('User ID')
|
||||||
|
if c in ('Created At', 'created_at'):
|
||||||
|
columns.append('created_at')
|
||||||
|
column_headers.append('Created At')
|
||||||
|
|
||||||
|
# convert back to tuple
|
||||||
|
column_headers = tuple(column_headers)
|
||||||
|
columns = tuple(columns)
|
||||||
|
|
||||||
if parsed_args.marker:
|
if parsed_args.marker:
|
||||||
# Check if both "--marker" and "--deleted" are used.
|
# Check if both "--marker" and "--deleted" are used.
|
||||||
# In that scenario a lookup is not needed as the marker
|
# In that scenario a lookup is not needed as the marker
|
||||||
|
@ -3129,6 +3129,25 @@ class TestServerList(TestServer):
|
|||||||
self.assertEqual(self.columns_long, columns)
|
self.assertEqual(self.columns_long, columns)
|
||||||
self.assertEqual(tuple(self.data_long), tuple(data))
|
self.assertEqual(tuple(self.data_long), tuple(data))
|
||||||
|
|
||||||
|
def test_server_list_column_option(self):
|
||||||
|
arglist = [
|
||||||
|
'-c', 'Project ID',
|
||||||
|
'-c', 'User ID',
|
||||||
|
'-c', 'Created At',
|
||||||
|
'--long'
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('long', True),
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
self.servers_mock.list.assert_called_with(**self.kwargs)
|
||||||
|
self.assertIn('Project ID', columns)
|
||||||
|
self.assertIn('User ID', columns)
|
||||||
|
self.assertIn('Created At', columns)
|
||||||
|
|
||||||
def test_server_list_no_name_lookup_option(self):
|
def test_server_list_no_name_lookup_option(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--no-name-lookup',
|
'--no-name-lookup',
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- Add ``--c project_id | user_id | created_at`` to ``openstack server list``
|
||||||
|
command to get these columns as an output.
|
Loading…
x
Reference in New Issue
Block a user