From 6d9d04248ea574ffbe94edec9e552232924eb8ff Mon Sep 17 00:00:00 2001 From: Ramesh Nachimuthu Date: Thu, 24 Apr 2014 17:45:25 +0530 Subject: autoconf: use host uuid to indentity bricks Using host UUIDs to bricks in host Change-Id: Ie5467b05391f709e292644f00495b41af8213b42 Signed-off-by: Ramesh Nachimuthu --- plugins/config_generator.py | 2 +- plugins/discovery.py | 4 ++-- tests/test_discovery.py | 9 ++++----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/plugins/config_generator.py b/plugins/config_generator.py index 2bfffdf..6ba1631 100644 --- a/plugins/config_generator.py +++ b/plugins/config_generator.py @@ -171,7 +171,7 @@ class GlusterNagiosConfManager: clusterServices.append(self.createClusterUtilizationService( cluster['name'])) clusterServices.append(self.createClusterAutoConfigService( - cluster['name'], cluster['hosts'][-1]['hostip'])) + cluster['name'], cluster['hosts'][0]['hostip'])) clusterHostConfig = self.createHost( cluster['name'], cluster['name'], "gluster-cluster", cluster['name'], None, None, clusterServices) diff --git a/plugins/discovery.py b/plugins/discovery.py index 3818a84..b2cc21a 100755 --- a/plugins/discovery.py +++ b/plugins/discovery.py @@ -55,7 +55,7 @@ def discoverCluster(hostip, cluster): hostlist = excecNRPECommand(hostip, "discoverpeers") #Add the ip address of the root node to the peer list #to generate the configuration - hostlist.append({"hostip": hostip}) + hostlist[0]['hostip'] = hostip for host in hostlist: #Get host names hostDetails = excecNRPECommand(host['hostip'], "discoverhostparams") @@ -64,7 +64,7 @@ def discoverCluster(hostip, cluster): host['bricks'] = [] for volume in componentlist['volumes']: for brick in volume['bricks']: - if brick['hostip'] == host['hostip']: + if brick['hostUuid'] == host['uuid']: brick['volumeName'] = volume['name'] host['bricks'].append(brick) clusterdata['hosts'] = hostlist diff --git a/tests/test_discovery.py b/tests/test_discovery.py index 0443cde..bcb5419 100644 --- a/tests/test_discovery.py +++ b/tests/test_discovery.py @@ -16,7 +16,6 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA # -import mock from plugins import discovery from testrunner import PluginsTestCase as TestCaseBase @@ -45,7 +44,8 @@ class TestDiscovery(TestCaseBase): def _getPeers(self): result = [] - result.append({"hostip": "172.16.53.2"}) + result.append({"hostip": "lo", "uuid": "0000-1111"}) + result.append({"hostip": "172.16.53.2", "uuid": "0000-1112"}) return result def _getHostParams(self, hostip): @@ -56,9 +56,8 @@ class TestDiscovery(TestCaseBase): def _verifyClusterData(self, clusterdata, clusterName, host): - self.assertEqual(clusterdata['hosts'][0]['hostip'], - self._getPeers()[0]['hostip']) - self.assertEqual(clusterdata['hosts'][1]['hostip'], host) + self.assertEqual(clusterdata['name'], clusterName) + self.assertEqual(clusterdata['hosts'][0]['hostip'], host) for host in clusterdata['hosts']: hostDetails = self._getHostParams(host['hostip']) self.assertEqual(host['hostname'], hostDetails['hostname']) -- cgit