summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xplugins/discoverlogicalcomponents.py7
-rwxr-xr-xplugins/discoverpeers.py27
2 files changed, 15 insertions, 19 deletions
diff --git a/plugins/discoverlogicalcomponents.py b/plugins/discoverlogicalcomponents.py
index 9211f42..0d826ff 100755
--- a/plugins/discoverlogicalcomponents.py
+++ b/plugins/discoverlogicalcomponents.py
@@ -34,10 +34,11 @@ def discoverlogicalelements():
volDict['name'] = volume['volumeName']
volDict['type'] = volume['volumeType']
volDict['bricks'] = []
- for brickstr in volume['bricks']:
- brickproplist = brickstr.split(':')
+ for brick in volume['bricksInfo']:
+ brickproplist = brick['name'].split(':')
volDict['bricks'].append({'hostip': brickproplist[0],
- 'brickpath': brickproplist[1]})
+ 'brickpath': brickproplist[1],
+ 'hostUuid': brick['hostUuid']})
resultlist['volumes'].append(volDict)
resultstring = json.dumps(resultlist)
diff --git a/plugins/discoverpeers.py b/plugins/discoverpeers.py
index c7ff8fe..6683a84 100755
--- a/plugins/discoverpeers.py
+++ b/plugins/discoverpeers.py
@@ -16,29 +16,24 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-import commands
import sys
import json
from glusternagios import utils
+from glusternagios import glustercli
+from glusternagios.glustercli import HostStatus
def discoverhosts():
- xmlElemList = []
- nrpe_out_list = []
- resultstring = ""
-
- command_peer_status = utils.sudoCmdPath.cmd + " " \
- + utils.glusterCmdPath.cmd + " peer status --xml"
- peer_status_out = commands.getoutput(command_peer_status)
-
- xmlElemList = utils.parseXml(peer_status_out, "./peerStatus/peer")
- for peer in xmlElemList:
- if (peer.find('connected').text == "1"):
- resltdict = {}
- resltdict['hostip'] = peer.find('hostname').text
- nrpe_out_list.append(resltdict)
- resultstring = json.dumps(nrpe_out_list)
+ resultlist = []
+ peers = glustercli.peerStatus()
+ for peer in peers:
+ if peer['status'] == HostStatus.CONNECTED:
+ peerDict = {}
+ peerDict['hostip'] = peer['hostname']
+ peerDict['uuid'] = peer['uuid']
+ resultlist.append(peerDict)
+ resultstring = json.dumps(resultlist)
print resultstring
sys.exit(utils.PluginStatusCode.OK)