summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRamesh Nachimuthu <rnachimu@redhat.com>2014-05-01 13:56:52 +0530
committerSahina Bose <sabose@redhat.com>2014-05-02 02:26:37 -0700
commitef5d02a650fa50698a6ddd157250591619e89be6 (patch)
treee7d7270f771f0974b07af9053e6d531aaaa62961
parentd5f6c2145bb37d7607d3f05329c0efca3c398fae (diff)
autoconf: discover volume list and info separately
NRPE doesn't support transfering large junk of data as a result. Hence we have to discover the volume details one by one. First fetch the volume list using 'discover_volume_list' NRPE command then fetch the brick details of volume one by one using 'discover_volume_info' NRPE command Change-Id: I2cd3c2309ffa2f1bf5c271e06dd03ade75bf5d92 Signed-off-by: Ramesh Nachimuthu <rnachimu@redhat.com> Reviewed-on: http://review.gluster.org/7631 Reviewed-by: Sahina Bose <sabose@redhat.com>
-rwxr-xr-xplugins/discovery.py18
-rw-r--r--tests/test_discovery.py41
2 files changed, 46 insertions, 13 deletions
diff --git a/plugins/discovery.py b/plugins/discovery.py
index 4edbe3f..bd60ae1 100755
--- a/plugins/discovery.py
+++ b/plugins/discovery.py
@@ -56,6 +56,20 @@ def excecNRPECommand(host, command, arguments=None, jsonOutput=True):
return output
+#Discovers volumes info one by one.
+#First it fetches the volumes list and then it fetches the bricks
+#details of volume one by one. Its an work around for size limitation issue
+#in NRPE.
+def discoverVolumes(hostip):
+ resultDict = {'volumes': []}
+ volumeList = excecNRPECommand(hostip, "discover_volume_list")
+ for volumeName in volumeList.keys():
+ volumeDetail = excecNRPECommand(hostip, "discover_volume_info",
+ [volumeName])
+ resultDict['volumes'].append(volumeDetail.get(volumeName))
+ return resultDict
+
+
def discoverCluster(hostip, cluster):
"""
This method helps to discover the nodes, volumes and bricks in the given
@@ -72,7 +86,7 @@ def discoverCluster(hostip, cluster):
Returns
---------
- Returns cluster details in the following dictinary format
+ Returns cluster details in the following dictionary format
{
'name': cluster-name,
'volumes': [list-volumes],
@@ -83,7 +97,7 @@ def discoverCluster(hostip, cluster):
clusterdata = {}
#Discover the logical components
- componentlist = excecNRPECommand(hostip, "discoverlogicalcomponents")
+ componentlist = discoverVolumes(hostip)
#Discover the peers
hostlist = excecNRPECommand(hostip, "discoverpeers")
#Add the ip address of the root node given by the user to the peer list
diff --git a/tests/test_discovery.py b/tests/test_discovery.py
index bcb5419..a211167 100644
--- a/tests/test_discovery.py
+++ b/tests/test_discovery.py
@@ -21,9 +21,12 @@ from testrunner import PluginsTestCase as TestCaseBase
class TestDiscovery(TestCaseBase):
- def _mockExcecNRPECommand(self, host, command):
- if command == "discoverlogicalcomponents":
- return self._getLogicalComponents()
+ def _mockExcecNRPECommand(self, host, command, arguments=None,
+ jsonOutput=True):
+ if command == "discover_volume_list":
+ return self._getVolumeNames()
+ elif command == "discover_volume_info":
+ return self._getVolumeInfo(arguments[0])
elif command == "discoverpeers":
return self._getPeers()
elif command == "discoverhostparams":
@@ -32,14 +35,30 @@ class TestDiscovery(TestCaseBase):
def _getLogicalComponents(self):
result = {}
result['volumes'] = []
- result['volumes'].append({"bricks": [{"brickpath": "/bricks/v1-1",
- "hostUuid": "0000-1111",
- "hostip": "172.16.53.1"}],
- "type": "DISTRIBUTE", "name": "V1"})
- result['volumes'].append({"bricks": [{"brickpath": "/bricks/v2-1",
- "hostUuid": "0000-1112",
- "hostip": "172.16.53.2"}],
- "type": "DISTRIBUTE", "name": "V2"})
+ result['volumes'].append(self._getVolumeInfo("V1")['V1'])
+ result['volumes'].append(self._getVolumeInfo("V2")['V2'])
+ return result
+
+ def _getVolumeInfo(self, volumeName):
+ result = {}
+ if volumeName == "V1":
+ volume = {"bricks": [{"brickpath": "/bricks/v1-1",
+ "hostUuid": "0000-1111",
+ "hostip": "172.16.53.1"}],
+ "type": "DISTRIBUTE", "name": "V1"}
+
+ elif volumeName == "V2":
+ volume = {"bricks": [{"brickpath": "/bricks/v2-1",
+ "hostUuid": "0000-1112",
+ "hostip": "172.16.53.2"}],
+ "type": "DISTRIBUTE", "name": "V2"}
+ result[volume['name']] = volume
+ return result
+
+ def _getVolumeNames(self):
+ result = {}
+ result['V1'] = {"type": "DISTRIBUTE", "name": "V1"}
+ result['V2'] = {"type": "DISTRIBUTE", "name": "V2"}
return result
def _getPeers(self):