diff --git a/heatclient/common/utils.py b/heatclient/common/utils.py index 32464bcf..3052d687 100644 --- a/heatclient/common/utils.py +++ b/heatclient/common/utils.py @@ -39,7 +39,8 @@ def pretty_choice_list(l): return ', '.join("'%s'" % i for i in l) -def print_list(objs, fields, field_labels, formatters={}, sortby=0): +def print_list(objs, fields, field_labels=None, formatters={}, sortby=0): + field_labels = field_labels or fields pt = prettytable.PrettyTable([f for f in field_labels], caching=False) pt.align = 'l' diff --git a/heatclient/v1/shell.py b/heatclient/v1/shell.py index 056020ac..82e86b7f 100644 --- a/heatclient/v1/shell.py +++ b/heatclient/v1/shell.py @@ -182,9 +182,8 @@ def do_stack_list(hc, args={}): '''List the user's stacks''' kwargs = {} stacks = hc.stacks.list(**kwargs) - field_labels = ['ID', 'Name', 'Status', 'Created'] fields = ['id', 'stack_name', 'stack_status', 'creation_time'] - utils.print_list(stacks, fields, field_labels, sortby=3) + utils.print_list(stacks, fields, sortby=3) @utils.arg('id', metavar='', @@ -247,11 +246,9 @@ def do_resource_list(hc, args): except exc.HTTPNotFound: raise exc.CommandError('Stack not found: %s' % args.id) else: - field_labels = ['Name', 'Type', - 'Status', 'Updated'] fields = ['logical_resource_id', 'resource_type', 'resource_status', 'updated_time'] - utils.print_list(resources, fields, field_labels, sortby=3) + utils.print_list(resources, fields, sortby=3) @utils.arg('id', metavar='', @@ -316,11 +313,9 @@ def do_event_list(hc, args): except exc.HTTPNotFound: raise exc.CommandError('Stack not found: %s' % args.id) else: - field_labels = ['Resource', 'ID', 'Reason', - 'Status', 'Event time'] fields = ['logical_resource_id', 'id', 'resource_status_reason', 'resource_status', 'event_time'] - utils.print_list(events, fields, field_labels, sortby=4) + utils.print_list(events, fields, sortby=4) @utils.arg('id', metavar='', diff --git a/tests/test_shell.py b/tests/test_shell.py index 1ff603fc..9d0dac94 100644 --- a/tests/test_shell.py +++ b/tests/test_shell.py @@ -215,9 +215,9 @@ class ShellTest(TestCase): list_text = self.shell('list') required = [ - 'ID', - 'Status', - 'Created', + 'id', + 'stack_status', + 'creation_time', 'teststack', '1', 'CREATE_COMPLETE', @@ -282,8 +282,8 @@ class ShellTest(TestCase): 'LinuxDistribution=F17"' % template_file) required = [ - 'Name', - 'ID', + 'stack_name', + 'id', 'teststack', '1' ] @@ -313,8 +313,8 @@ class ShellTest(TestCase): 'LinuxDistribution=F17"') required = [ - 'Name', - 'ID', + 'stack_name', + 'id', 'teststack2', '2' ] @@ -350,8 +350,8 @@ class ShellTest(TestCase): 'LinuxDistribution=F17"') required = [ - 'Name', - 'ID', + 'stack_name', + 'id', 'teststack2', '2' ] @@ -380,8 +380,8 @@ class ShellTest(TestCase): 'LinuxDistribution=F17"' % template_file) required = [ - 'Name', - 'ID', + 'stack_name', + 'id', 'teststack2', '1' ] @@ -405,8 +405,8 @@ class ShellTest(TestCase): create_text = self.shell('delete teststack2/2') required = [ - 'Name', - 'ID', + 'stack_name', + 'id', 'teststack', '1' ]