Novaclient shell list command should support a minimal server list
The Nova API supports both a basic (id and name) and detailed server list, and this is supported in the client by the "detailed=True" argument to servers.list(). However the shell do_list() method always leaves this to its default value. For administrators on a large system, or where the tenants has a lot of instances a detailed list can be painfully slow. This change adds support for a --minimal option to list. Fixes bug: 1228137 Change-Id: I3126ee6b372606a98f0d7a4e344556f8c05ae224
This commit is contained in:
parent
cafd5bf810
commit
8deaf3769d
|
@ -679,6 +679,10 @@ class ShellTest(utils.TestCase):
|
|||
self.run_command('list')
|
||||
self.assert_called('GET', '/servers/detail')
|
||||
|
||||
def test_list_minimal(self):
|
||||
self.run_command('list --minimal')
|
||||
self.assert_called('GET', '/servers')
|
||||
|
||||
def test_list_with_images(self):
|
||||
self.run_command('list --image 1')
|
||||
self.assert_called('GET', '/servers/detail?image=1')
|
||||
|
|
|
@ -1091,6 +1091,11 @@ def do_image_delete(cs, args):
|
|||
metavar='<fields>',
|
||||
help='Comma-separated list of fields to display. '
|
||||
'Use the show command to see which fields are available.')
|
||||
@utils.arg('--minimal',
|
||||
dest='minimal',
|
||||
action="store_true",
|
||||
default=False,
|
||||
help='Get only uuid and name.')
|
||||
def do_list(cs, args):
|
||||
"""List active servers."""
|
||||
imageid = None
|
||||
|
@ -1126,7 +1131,10 @@ def do_list(cs, args):
|
|||
|
||||
id_col = 'ID'
|
||||
|
||||
servers = cs.servers.list(search_opts=search_opts)
|
||||
detailed = not args.minimal
|
||||
|
||||
servers = cs.servers.list(detailed=detailed,
|
||||
search_opts=search_opts)
|
||||
convert = [('OS-EXT-SRV-ATTR:host', 'host'),
|
||||
('OS-EXT-STS:task_state', 'task_state'),
|
||||
('OS-EXT-SRV-ATTR:instance_name', 'instance_name'),
|
||||
|
@ -1134,7 +1142,11 @@ def do_list(cs, args):
|
|||
('hostId', 'host_id')]
|
||||
_translate_keys(servers, convert)
|
||||
_translate_extended_states(servers)
|
||||
if field_titles:
|
||||
if args.minimal:
|
||||
columns = [
|
||||
id_col,
|
||||
'Name']
|
||||
elif field_titles:
|
||||
columns = [id_col] + field_titles
|
||||
else:
|
||||
columns = [
|
||||
|
|
|
@ -975,6 +975,11 @@ def do_image_delete(cs, args):
|
|||
metavar='<fields>',
|
||||
help='Comma-separated list of fields to display. '
|
||||
'Use the show command to see which fields are available.')
|
||||
@utils.arg('--minimal',
|
||||
dest='minimal',
|
||||
action="store_true",
|
||||
default=False,
|
||||
help='Get only uuid and name.')
|
||||
def do_list(cs, args):
|
||||
"""List active servers."""
|
||||
imageid = None
|
||||
|
@ -1010,7 +1015,10 @@ def do_list(cs, args):
|
|||
|
||||
id_col = 'ID'
|
||||
|
||||
servers = cs.servers.list(search_opts=search_opts)
|
||||
detailed = not args.minimal
|
||||
|
||||
servers = cs.servers.list(detailed=detailed,
|
||||
search_opts=search_opts)
|
||||
convert = [('OS-EXT-SRV-ATTR:host', 'host'),
|
||||
('OS-EXT-STS:task_state', 'task_state'),
|
||||
('OS-EXT-SRV-ATTR:instance_name', 'instance_name'),
|
||||
|
@ -1018,7 +1026,11 @@ def do_list(cs, args):
|
|||
('hostId', 'host_id')]
|
||||
_translate_keys(servers, convert)
|
||||
_translate_extended_states(servers)
|
||||
if field_titles:
|
||||
if args.minimal:
|
||||
columns = [
|
||||
id_col,
|
||||
'Name']
|
||||
elif field_titles:
|
||||
columns = [id_col] + field_titles
|
||||
else:
|
||||
columns = [
|
||||
|
|
Loading…
Reference in New Issue