summaryrefslogtreecommitdiff
path: root/ceilometerclient/common/utils.py
diff options
context:
space:
mode:
authorMehdi Abaakouk <mehdi.abaakouk@enovance.com>2013-09-24 11:09:05 +0200
committerMehdi Abaakouk <mehdi.abaakouk@enovance.com>2013-09-25 09:42:21 +0200
commitce01f564651bee07f91be8dc7f6dfca561216625 (patch)
tree69a614b537510fecc8392ded5dc2d701d18e48bd /ceilometerclient/common/utils.py
parent2610d6c144e0d81cd94a6f18eb899443ce7d64fb (diff)
downloadpython-ceilometerclient-ce01f564651bee07f91be8dc7f6dfca561216625.tar.gz
Improve the CM shell client alarm visualisation
This change aim to get a better alarm representation in shell. In alarm-list: * it add a short sentence to describe the alarm rule * it remove project_id/user_id because it always show the same id for all alarm for end-user In alarm-show, it show alarm rule attributes as alarm properties instead of a unparsable json in the rule property. example of short sentence for column 'Alarm condition': * combinated states (AND) of 8babd6a2-c457-42d0-9eb5-cdfb3cb50203, d0e11a94-8f59-48a9-8f6d-b0d68aaac8d0 * cpu_util >= 50.0 during 1 x 60s Change-Id: If4df2dc08f9f4cb7796fd98308c7d62e311d1138
Diffstat (limited to 'ceilometerclient/common/utils.py')
-rw-r--r--ceilometerclient/common/utils.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/ceilometerclient/common/utils.py b/ceilometerclient/common/utils.py
index ea79dbf..eac860f 100644
--- a/ceilometerclient/common/utils.py
+++ b/ceilometerclient/common/utils.py
@@ -63,17 +63,19 @@ def print_dict(d, dict_property="Property", wrap=0):
# convert dict to str to check length
if isinstance(v, dict):
v = str(v)
- if wrap > 0:
- v = textwrap.fill(str(v), wrap)
# if value has a newline, add in multiple rows
# e.g. fault with stacktrace
if v and isinstance(v, basestring) and r'\n' in v:
lines = v.strip().split(r'\n')
col1 = k
for line in lines:
+ if wrap > 0:
+ line = textwrap.fill(str(line), wrap)
pt.add_row([col1, line])
col1 = ''
else:
+ if wrap > 0:
+ v = textwrap.fill(str(v), wrap)
pt.add_row([k, v])
print pt.get_string()