Fix column names for server list --no-name-lookup
When --long is not present change the 'Image Name' column to 'Image' and add the 'Flavor' column. These columns will contain Names unless --no-name-lookup is specified when they will contain IDs. Change-Id: I92cfb22136aee32616894e60e9227b4da185da99
This commit is contained in:
parent
2c57f7bfb2
commit
2689984ba7
@ -330,7 +330,7 @@ List servers
|
|||||||
[--all-projects]
|
[--all-projects]
|
||||||
[--project <project> [--project-domain <project-domain>]]
|
[--project <project> [--project-domain <project-domain>]]
|
||||||
[--long]
|
[--long]
|
||||||
[-n | --no-name-lookup]
|
[--no-name-lookup | -n]
|
||||||
[--marker <server>]
|
[--marker <server>]
|
||||||
[--limit <num-servers>]
|
[--limit <num-servers>]
|
||||||
[--deleted]
|
[--deleted]
|
||||||
@ -402,6 +402,8 @@ List servers
|
|||||||
|
|
||||||
Skips image and flavor names lookup
|
Skips image and flavor names lookup
|
||||||
|
|
||||||
|
``-n`` may be used as an alias for this option.
|
||||||
|
|
||||||
.. option:: --marker <server>
|
.. option:: --marker <server>
|
||||||
|
|
||||||
The last server of the previous page. Display list of servers
|
The last server of the previous page. Display list of servers
|
||||||
|
@ -1060,17 +1060,16 @@ class ListServer(command.Lister):
|
|||||||
'OS-EXT-AZ:availability_zone',
|
'OS-EXT-AZ:availability_zone',
|
||||||
'OS-EXT-SRV-ATTR:host',
|
'OS-EXT-SRV-ATTR:host',
|
||||||
]
|
]
|
||||||
elif parsed_args.no_name_lookup:
|
else:
|
||||||
|
if parsed_args.no_name_lookup:
|
||||||
columns = (
|
columns = (
|
||||||
'ID',
|
'ID',
|
||||||
'Name',
|
'Name',
|
||||||
'Status',
|
'Status',
|
||||||
|
'Networks',
|
||||||
'Image ID',
|
'Image ID',
|
||||||
'Flavor ID',
|
'Flavor ID',
|
||||||
)
|
)
|
||||||
column_headers = tuple(columns)
|
|
||||||
mixed_case_fields = []
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
columns = (
|
columns = (
|
||||||
'ID',
|
'ID',
|
||||||
@ -1078,8 +1077,16 @@ class ListServer(command.Lister):
|
|||||||
'Status',
|
'Status',
|
||||||
'Networks',
|
'Networks',
|
||||||
'Image Name',
|
'Image Name',
|
||||||
|
'Flavor Name',
|
||||||
|
)
|
||||||
|
column_headers = (
|
||||||
|
'ID',
|
||||||
|
'Name',
|
||||||
|
'Status',
|
||||||
|
'Networks',
|
||||||
|
'Image',
|
||||||
|
'Flavor',
|
||||||
)
|
)
|
||||||
column_headers = tuple(columns)
|
|
||||||
mixed_case_fields = []
|
mixed_case_fields = []
|
||||||
|
|
||||||
marker_id = None
|
marker_id = None
|
||||||
|
@ -1441,7 +1441,8 @@ class TestServerList(TestServer):
|
|||||||
'Name',
|
'Name',
|
||||||
'Status',
|
'Status',
|
||||||
'Networks',
|
'Networks',
|
||||||
'Image Name',
|
'Image',
|
||||||
|
'Flavor',
|
||||||
)
|
)
|
||||||
columns_long = (
|
columns_long = (
|
||||||
'ID',
|
'ID',
|
||||||
@ -1459,14 +1460,6 @@ class TestServerList(TestServer):
|
|||||||
'Properties',
|
'Properties',
|
||||||
)
|
)
|
||||||
|
|
||||||
columns_no_name_lookup = (
|
|
||||||
'ID',
|
|
||||||
'Name',
|
|
||||||
'Status',
|
|
||||||
'Image ID',
|
|
||||||
'Flavor ID',
|
|
||||||
)
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestServerList, self).setUp()
|
super(TestServerList, self).setUp()
|
||||||
|
|
||||||
@ -1546,6 +1539,7 @@ class TestServerList(TestServer):
|
|||||||
s.status,
|
s.status,
|
||||||
server._format_servers_list_networks(s.networks),
|
server._format_servers_list_networks(s.networks),
|
||||||
self.image.name,
|
self.image.name,
|
||||||
|
self.flavor.name,
|
||||||
))
|
))
|
||||||
self.data_long.append((
|
self.data_long.append((
|
||||||
s.id,
|
s.id,
|
||||||
@ -1568,6 +1562,7 @@ class TestServerList(TestServer):
|
|||||||
s.id,
|
s.id,
|
||||||
s.name,
|
s.name,
|
||||||
s.status,
|
s.status,
|
||||||
|
server._format_servers_list_networks(s.networks),
|
||||||
s.image['id'],
|
s.image['id'],
|
||||||
s.flavor['id']
|
s.flavor['id']
|
||||||
))
|
))
|
||||||
@ -1616,7 +1611,7 @@ class TestServerList(TestServer):
|
|||||||
columns, data = self.cmd.take_action(parsed_args)
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
self.servers_mock.list.assert_called_with(**self.kwargs)
|
self.servers_mock.list.assert_called_with(**self.kwargs)
|
||||||
self.assertEqual(self.columns_no_name_lookup, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
self.assertEqual(tuple(self.data_no_name_lookup), tuple(data))
|
self.assertEqual(tuple(self.data_no_name_lookup), tuple(data))
|
||||||
|
|
||||||
def test_server_list_n_option(self):
|
def test_server_list_n_option(self):
|
||||||
@ -1632,7 +1627,7 @@ class TestServerList(TestServer):
|
|||||||
columns, data = self.cmd.take_action(parsed_args)
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
self.servers_mock.list.assert_called_with(**self.kwargs)
|
self.servers_mock.list.assert_called_with(**self.kwargs)
|
||||||
self.assertEqual(self.columns_no_name_lookup, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
self.assertEqual(tuple(self.data_no_name_lookup), tuple(data))
|
self.assertEqual(tuple(self.data_no_name_lookup), tuple(data))
|
||||||
|
|
||||||
def test_server_list_with_image(self):
|
def test_server_list_with_image(self):
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Add ``--no-name-lookup`` option to ``server list`` command to skip the lookup of
|
||||||
|
flavor and image names. This can save a significant amount of time on clouds with
|
||||||
|
a large number of images. ``-n`` is an alias for this option.
|
Loading…
Reference in New Issue
Block a user