Skip to content

Commit b9daff2

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Fix column names for server list --no-name-lookup"
2 parents 6f2d606 + 2689984 commit b9daff2

4 files changed

Lines changed: 36 additions & 26 deletions

File tree

doc/source/cli/command-objects/server.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ List servers
330330
[--all-projects]
331331
[--project <project> [--project-domain <project-domain>]]
332332
[--long]
333-
[-n | --no-name-lookup]
333+
[--no-name-lookup | -n]
334334
[--marker <server>]
335335
[--limit <num-servers>]
336336
[--deleted]
@@ -402,6 +402,8 @@ List servers
402402
403403
Skips image and flavor names lookup
404404
405+
``-n`` may be used as an alias for this option.
406+
405407
.. option:: --marker <server>
406408
407409
The last server of the previous page. Display list of servers

openstackclient/compute/v2/server.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,26 +1060,33 @@ def take_action(self, parsed_args):
10601060
'OS-EXT-AZ:availability_zone',
10611061
'OS-EXT-SRV-ATTR:host',
10621062
]
1063-
elif parsed_args.no_name_lookup:
1064-
columns = (
1065-
'ID',
1066-
'Name',
1067-
'Status',
1068-
'Image ID',
1069-
'Flavor ID',
1070-
)
1071-
column_headers = tuple(columns)
1072-
mixed_case_fields = []
1073-
10741063
else:
1075-
columns = (
1064+
if parsed_args.no_name_lookup:
1065+
columns = (
1066+
'ID',
1067+
'Name',
1068+
'Status',
1069+
'Networks',
1070+
'Image ID',
1071+
'Flavor ID',
1072+
)
1073+
else:
1074+
columns = (
1075+
'ID',
1076+
'Name',
1077+
'Status',
1078+
'Networks',
1079+
'Image Name',
1080+
'Flavor Name',
1081+
)
1082+
column_headers = (
10761083
'ID',
10771084
'Name',
10781085
'Status',
10791086
'Networks',
1080-
'Image Name',
1087+
'Image',
1088+
'Flavor',
10811089
)
1082-
column_headers = tuple(columns)
10831090
mixed_case_fields = []
10841091

10851092
marker_id = None

openstackclient/tests/unit/compute/v2/test_server.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,7 +1441,8 @@ class TestServerList(TestServer):
14411441
'Name',
14421442
'Status',
14431443
'Networks',
1444-
'Image Name',
1444+
'Image',
1445+
'Flavor',
14451446
)
14461447
columns_long = (
14471448
'ID',
@@ -1459,14 +1460,6 @@ class TestServerList(TestServer):
14591460
'Properties',
14601461
)
14611462

1462-
columns_no_name_lookup = (
1463-
'ID',
1464-
'Name',
1465-
'Status',
1466-
'Image ID',
1467-
'Flavor ID',
1468-
)
1469-
14701463
def setUp(self):
14711464
super(TestServerList, self).setUp()
14721465

@@ -1546,6 +1539,7 @@ def setUp(self):
15461539
s.status,
15471540
server._format_servers_list_networks(s.networks),
15481541
self.image.name,
1542+
self.flavor.name,
15491543
))
15501544
self.data_long.append((
15511545
s.id,
@@ -1568,6 +1562,7 @@ def setUp(self):
15681562
s.id,
15691563
s.name,
15701564
s.status,
1565+
server._format_servers_list_networks(s.networks),
15711566
s.image['id'],
15721567
s.flavor['id']
15731568
))
@@ -1616,7 +1611,7 @@ def test_server_list_no_name_lookup_option(self):
16161611
columns, data = self.cmd.take_action(parsed_args)
16171612

16181613
self.servers_mock.list.assert_called_with(**self.kwargs)
1619-
self.assertEqual(self.columns_no_name_lookup, columns)
1614+
self.assertEqual(self.columns, columns)
16201615
self.assertEqual(tuple(self.data_no_name_lookup), tuple(data))
16211616

16221617
def test_server_list_n_option(self):
@@ -1632,7 +1627,7 @@ def test_server_list_n_option(self):
16321627
columns, data = self.cmd.take_action(parsed_args)
16331628

16341629
self.servers_mock.list.assert_called_with(**self.kwargs)
1635-
self.assertEqual(self.columns_no_name_lookup, columns)
1630+
self.assertEqual(self.columns, columns)
16361631
self.assertEqual(tuple(self.data_no_name_lookup), tuple(data))
16371632

16381633
def test_server_list_with_image(self):
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
features:
3+
- |
4+
Add ``--no-name-lookup`` option to ``server list`` command to skip the lookup of
5+
flavor and image names. This can save a significant amount of time on clouds with
6+
a large number of images. ``-n`` is an alias for this option.

0 commit comments

Comments
 (0)