From 3cce71403b424fb9d37e3a2f381426bb43a06b24 Mon Sep 17 00:00:00 2001 From: Ramesh Nachimuthu Date: Wed, 23 Apr 2014 18:15:16 +0530 Subject: autoconf: use host uuid to identity bricks Currently host IP/Name is used to indetify the bricks in host. But it breaks when we use fqdn names in peer probe. So changing the auto conf to use Host UUIDs to identify the bricks Change-Id: Id28ac7a47a4ce5beb1fc8f91cdb136bca17f071f Signed-off-by: Ramesh Nachimuthu --- plugins/discoverlogicalcomponents.py | 7 ++++--- plugins/discoverpeers.py | 27 +++++++++++---------------- 2 files changed, 15 insertions(+), 19 deletions(-) (limited to 'plugins') 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) -- cgit