diff --git a/novaclient/tests/v1_1/test_shell.py b/novaclient/tests/v1_1/test_shell.py index d7a5e0d38..48b08d9b1 100644 --- a/novaclient/tests/v1_1/test_shell.py +++ b/novaclient/tests/v1_1/test_shell.py @@ -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') diff --git a/novaclient/v1_1/shell.py b/novaclient/v1_1/shell.py index d74c0b04c..66eb742af 100644 --- a/novaclient/v1_1/shell.py +++ b/novaclient/v1_1/shell.py @@ -1091,6 +1091,11 @@ def do_image_delete(cs, args): metavar='', 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 = [ diff --git a/novaclient/v3/shell.py b/novaclient/v3/shell.py index 8debf1151..7b478c79e 100644 --- a/novaclient/v3/shell.py +++ b/novaclient/v3/shell.py @@ -975,6 +975,11 @@ def do_image_delete(cs, args): metavar='', 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 = [