From d78297c6b3881510fe2f331f00a95e8113e395fe Mon Sep 17 00:00:00 2001 From: Chris MacNaughton Date: Thu, 13 Dec 2018 09:06:40 +0100 Subject: [PATCH] Set action output for get_health Change-Id: I23287bd153f1e61a94593734b1de43ef6abad36a Closes-Bug: 1808189 --- actions/ceph_ops.py | 2 +- actions/get-health | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/actions/ceph_ops.py b/actions/ceph_ops.py index 86765dd0..47eb5c8d 100755 --- a/actions/ceph_ops.py +++ b/actions/ceph_ops.py @@ -66,7 +66,7 @@ def get_health(): On error, 'unknown' is returned. """ try: - value = check_output(['ceph', 'health']) + value = check_output(['ceph', 'health']).decode('utf-8') return value except CalledProcessError as e: action_fail(e.message) diff --git a/actions/get-health b/actions/get-health index 09cf08c2..60e8a333 100755 --- a/actions/get-health +++ b/actions/get-health @@ -1,6 +1,12 @@ #!/usr/bin/python from ceph_ops import get_health +from charmhelpers.core.hookenv import log, action_set, action_fail if __name__ == '__main__': - get_health() + try: + action_set({'message': get_health()}) + except CalledProcessError as e: + log(e) + action_fail( + "ceph health failed with message: {}".format(str(e))) \ No newline at end of file