From 2d1592e934b4313fb0582dba419fcca27819d7e4 Mon Sep 17 00:00:00 2001 From: JUN JIE NAN Date: Thu, 8 Aug 2013 14:27:33 +0800 Subject: [PATCH] Fix heat event list sorted order incorrect The order is correct already if python heat client does not recorder it. Add option to make print_list not to reorder possible, and call it in do_event_list. Change-Id: I3f0990aff27df39371c583d5aae3edd106542ad1 Fixes: bug #1209506 --- heatclient/common/utils.py | 7 +++++-- heatclient/v1/shell.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/heatclient/common/utils.py b/heatclient/common/utils.py index 7a94598e..59a19c7b 100644 --- a/heatclient/common/utils.py +++ b/heatclient/common/utils.py @@ -51,7 +51,7 @@ def newline_list_formatter(r): return '\n'.join(r or []) -def print_list(objs, fields, field_labels=None, formatters={}, sortby=0): +def print_list(objs, fields, field_labels=None, formatters={}, sortby=None): field_labels = field_labels or fields pt = prettytable.PrettyTable([f for f in field_labels], caching=False, print_empty=False) @@ -66,7 +66,10 @@ def print_list(objs, fields, field_labels=None, formatters={}, sortby=0): data = getattr(o, field, None) or '' row.append(data) pt.add_row(row) - print pt.get_string(sortby=field_labels[sortby]) + if sortby is None: + print pt.get_string() + else: + print pt.get_string(sortby=field_labels[sortby]) def print_dict(d, formatters={}): diff --git a/heatclient/v1/shell.py b/heatclient/v1/shell.py index 93ef0ea3..22cae5e0 100644 --- a/heatclient/v1/shell.py +++ b/heatclient/v1/shell.py @@ -400,7 +400,7 @@ def do_event_list(hc, args): else: fields = ['logical_resource_id', 'id', 'resource_status_reason', 'resource_status', 'event_time'] - utils.print_list(events, fields, sortby=4) + utils.print_list(events, fields) @utils.arg('id', metavar='',