summaryrefslogtreecommitdiff
path: root/heatclient/common/utils.py
diff options
context:
space:
mode:
authorSteven Hardy <shardy@redhat.com>2015-04-15 05:20:22 -0400
committerSteven Hardy <shardy@redhat.com>2015-04-16 18:02:28 +0100
commit0eb7f78c488eba8baa56edccc7dd99104166412e (patch)
tree53aec23a0ab3ead56bb405039e42661ebbbf90db /heatclient/common/utils.py
parent7d7460cfb64dff00679a93721dd8d347c861b471 (diff)
downloadpython-heatclient-0eb7f78c488eba8baa56edccc7dd99104166412e.tar.gz
Add --nested-depth option to event-list
Adds logic to mimic the resource-list nested-depth option for events. Note that this is pretty inefficient, and in future we should add an API for nested_depth to the events API, but I want this to work for kilo heat, so this interim implementation will work for kilo, then I'll look at an alternative (faster) API-side implementation for Liberty, which will maintain the same CLI interfaces. Change-Id: I76c60ab5b79af9c477af07d5690b8ca6ca4da388
Diffstat (limited to 'heatclient/common/utils.py')
-rw-r--r--heatclient/common/utils.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/heatclient/common/utils.py b/heatclient/common/utils.py
index 0afdd81..840641f 100644
--- a/heatclient/common/utils.py
+++ b/heatclient/common/utils.py
@@ -50,6 +50,15 @@ def link_formatter(links):
return '\n'.join(format_link(l) for l in links or [])
+def resource_nested_identifier(rsrc):
+ nested_link = [l for l in rsrc.links or []
+ if l.get('rel') == 'nested']
+ if nested_link:
+ nested_href = nested_link[0].get('href')
+ nested_identifier = nested_href.split("/")[-2:]
+ return "/".join(nested_identifier)
+
+
def json_formatter(js):
return jsonutils.dumps(js, indent=2, ensure_ascii=False,
separators=(', ', ': '))