From b95657fd15e8e1880978a130c4faa45b290397a8 Mon Sep 17 00:00:00 2001 From: Swann Croiset Date: Thu, 29 Aug 2013 15:47:22 +0200 Subject: [PATCH] Be backward compatible after a renaming in API The need was introduced with the renaming of field logical_resource_id to resource_name, so let heatclient display the good one for the two Heat versions. Fixes bug #1216903 Change-Id: I3e86f482a1b814a27b15be3c102727c44153221f --- heatclient/v1/shell.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/heatclient/v1/shell.py b/heatclient/v1/shell.py index e0f1188c..23bbff7b 100644 --- a/heatclient/v1/shell.py +++ b/heatclient/v1/shell.py @@ -333,8 +333,13 @@ def do_resource_list(hc, args): except exc.HTTPNotFound: raise exc.CommandError('Stack not found: %s' % args.id) else: - fields = ['resource_name', 'resource_type', - 'resource_status', 'updated_time'] + fields = ['resource_type', 'resource_status', 'updated_time'] + if len(resources) >= 1: + if hasattr(resources[0], 'resource_name'): + fields.insert(0, 'resource_name') + else: + fields.insert(0, 'logical_resource_id') + utils.print_list(resources, fields, sortby=3) @@ -416,8 +421,13 @@ def do_event_list(hc, args): except exc.HTTPNotFound: raise exc.CommandError('Stack not found: %s' % args.id) else: - fields = ['resource_name', 'id', 'resource_status_reason', + fields = ['id', 'resource_status_reason', 'resource_status', 'event_time'] + if len(events) >= 1: + if hasattr(events[0], 'resource_name'): + fields.insert(0, 'resource_name') + else: + fields.insert(0, 'logical_resource_id') utils.print_list(events, fields)