Skip to content

Commit

Permalink
Fix heat event list sorted order incorrect
Browse files Browse the repository at this point in the history
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
  • Loading branch information
JUN JIE NAN committed Aug 8, 2013
1 parent cf4b5c8 commit 2d1592e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions heatclient/common/utils.py
Expand Up @@ -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)
Expand All @@ -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={}):
Expand Down
2 changes: 1 addition & 1 deletion heatclient/v1/shell.py
Expand Up @@ -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='<NAME or ID>',
Expand Down

0 comments on commit 2d1592e

Please sign in to comment.