From e2629d34a8a8ca7df644a454128261a11857d0ad Mon Sep 17 00:00:00 2001 From: David Boucha Date: Tue, 16 Jul 2013 13:01:53 -0600 Subject: [PATCH] Return proper data structure from member_status --- salt/modules/riak.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/salt/modules/riak.py b/salt/modules/riak.py index f61c9c315b..638f6e8c64 100644 --- a/salt/modules/riak.py +++ b/salt/modules/riak.py @@ -84,4 +84,28 @@ def member_status(): salt '*' riak.member_status ''' - return __salt__['cmd.run']('riak-admin member-status') + ret = {'membership': {}, + 'summary': {'Valid': 0, + 'Leaving': 0, + 'Exiting': 0, + 'Joining': 0, + 'Down': 0, + } + } + cmd = 'riak-admin member-status' + out = __salt__['cmd.run'](cmd).splitlines() + for line in out: + if line.startswith(('=', '-', 'Status')): + continue + if '/' in line: + comps = line.split('/') + for item in comps: + key, val = item.split(':') + ret['summary'][key.strip()] = val.strip() + vals = line.split() + if len(vals) == 4: + ret['membership'][vals[3]] = {'Status': vals[0], + 'Ring': vals[1], + 'Pending': vals[2], + } + return ret