summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorRamesh Nachimuthu <rnachimu@redhat.com>2014-04-16 10:09:31 +0530
committerBala.FA <barumuga@redhat.com>2014-04-29 10:14:33 +0530
commit666983202013dd3c1e236eb458b75b3a95d74782 (patch)
tree44d96fa3016fed48edfba3aa23de8c97a9f0e8ea /plugins
parente5c38e4d2411d453a769fd5acda2bee97d9237d9 (diff)
autoconf: use glustercli to run volume info command
Using the glustercli.volumeInfo() from common to get the volume info. It makes the discovery logic very simple Change-Id: Iacf319eb3b3b39805a483cbe43b02496802316a7 Signed-off-by: Ramesh Nachimuthu <rnachimu@redhat.com>
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/discoverlogicalcomponents.py52
1 files changed, 15 insertions, 37 deletions
diff --git a/plugins/discoverlogicalcomponents.py b/plugins/discoverlogicalcomponents.py
index 50a259f..9211f42 100755
--- a/plugins/discoverlogicalcomponents.py
+++ b/plugins/discoverlogicalcomponents.py
@@ -17,51 +17,29 @@
# 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 json
import sys
from glusternagios import utils
-
-
-def discoverbricks(vol_info_out):
- bricklist = []
- xmlElemList = utils.parseXml(vol_info_out,
- "./volInfo/volumes/volume/bricks/brick")
- for brick in xmlElemList:
- brickdict = {}
- brickstr = brick.text
- brickproplist = brickstr.split(':')
- brickdict['hostip'] = brickproplist[0]
- brickdict['brickpath'] = brickproplist[1]
- bricklist.append(brickdict)
-
- return bricklist
-
-
-def discovervolumes(vol_info_out):
- vollist = []
-
- #Get the volume info
- xmlElemList = utils.parseXml(vol_info_out, "./volInfo/volumes/volume")
- for volume in xmlElemList:
- voldict = {}
- voldict['name'] = volume.find('name').text
- voldict['typeStr'] = volume.find('typeStr').text
- vollist.append(voldict)
-
- return vollist
+from glusternagios import glustercli
def discoverlogicalelements():
resultlist = {}
- resultstring = ""
- command_vol_info = utils.sudoCmdPath.cmd + " " + \
- utils.glusterCmdPath.cmd + " volume info --xml"
- vol_info_out = commands.getoutput(command_vol_info)
- resultlist['volumes'] = discovervolumes(vol_info_out)
- resultlist['bricks'] = discoverbricks(vol_info_out)
- #convert to string
+ resultlist['volumes'] = []
+
+ volumes = glustercli.volumeInfo()
+ for volume in volumes.values():
+ volDict = {}
+ volDict['name'] = volume['volumeName']
+ volDict['type'] = volume['volumeType']
+ volDict['bricks'] = []
+ for brickstr in volume['bricks']:
+ brickproplist = brickstr.split(':')
+ volDict['bricks'].append({'hostip': brickproplist[0],
+ 'brickpath': brickproplist[1]})
+ resultlist['volumes'].append(volDict)
+
resultstring = json.dumps(resultlist)
print resultstring
sys.exit(utils.PluginStatusCode.OK)