diff options
-rw-r--r-- | plugins/config_generator.py | 9 | ||||
-rwxr-xr-x | plugins/discovery.py | 21 | ||||
-rw-r--r-- | tests/test_config_generator.py | 11 |
3 files changed, 21 insertions, 20 deletions
diff --git a/plugins/config_generator.py b/plugins/config_generator.py index 9254b69..17b5df3 100644 --- a/plugins/config_generator.py +++ b/plugins/config_generator.py @@ -67,7 +67,7 @@ class GlusterNagiosConfManager: checkCommand = 'check_vol_utilization!%s!%s!70!90' % \ (clusterName, volume['name']) volumeService['check_command'] = checkCommand - volumeService['notes'] = "Volume type : %s" % (volume['typeStr']) + volumeService['notes'] = "Volume type : %s" % (volume['type']) return volumeService def __createVolumeStatusService(self, volume, clusterName): @@ -80,7 +80,7 @@ class GlusterNagiosConfManager: checkCommand = 'check_vol_status!%s!%s' % \ (clusterName, volume['name']) volumeService['check_command'] = checkCommand - volumeService['notes'] = "Volume type : %s" % (volume['typeStr']) + volumeService['notes'] = "Volume type : %s" % (volume['type']) return volumeService def __createVolumeQuotaStatusService(self, volume, clusterName): @@ -93,6 +93,7 @@ class GlusterNagiosConfManager: checkCommand = 'check_vol_quota_status!%s!%s' % \ (clusterName, volume['name']) volumeService['check_command'] = checkCommand + volumeService['notes'] = "Volume type : %s" % (volume['type']) return volumeService def createClusterUtilizationService(self, clusterName): @@ -134,6 +135,8 @@ class GlusterNagiosConfManager: brick['brickpath']) brickService['service_description'] = serviceDesc brickService['_BRICK_DIR'] = brick['brickpath'] + brickService['_VOL_NAME'] = brick['volumeName'] + brickService['notes'] = "Volume : %s" % (brick['volumeName']) return brickService def __createBrickStatusService(self, brick, hostName): @@ -143,6 +146,8 @@ class GlusterNagiosConfManager: serviceDesc = "Brick Status - %s:%s" % (hostName, brick['brickpath']) brickService['service_description'] = serviceDesc brickService['_BRICK_DIR'] = brick['brickpath'] + brickService['_VOL_NAME'] = brick['volumeName'] + brickService['notes'] = "Volume : %s" % (brick['volumeName']) return brickService def createBrickServices(self, host): diff --git a/plugins/discovery.py b/plugins/discovery.py index 5794c2e..2cde3d0 100755 --- a/plugins/discovery.py +++ b/plugins/discovery.py @@ -20,13 +20,11 @@ import argparse import commands import json import datetime -import re import sys from config_generator import GlusterNagiosConfManager from glusternagios import utils -#from glusternagios import utils from constants import DEFAULT_AUTO_CONFIG_DIR from constants import HOST_TEMPLATE_DIR from constants import HOST_TEMPLATE_NAME @@ -72,11 +70,6 @@ def discoverlogicalcomponents(host): def discovercluster(args): - """ - - :rtype : None - """ - ipPat = re.compile("^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$") clusterdata = {} #Discover the logical components componentlist = discoverlogicalcomponents(args.hostip) @@ -89,12 +82,14 @@ def discovercluster(args): #to generate the configuration hostlist.append({"hostip": args.hostip}) for host in hostlist: - if(ipPat.match(host['hostip'])): - #host.update(discoverhostdetails(host['hostip'], args)) - #Get the list of bricks for this host and add to dictionary - host['bricks'] = \ - [brick for brick in componentlist['bricks'] - if brick["hostip"] == host['hostip']] + #host.update(discoverhostdetails(host['hostip'], args)) + #Get the list of bricks for this host and add to dictionary + host['bricks'] = [] + for volume in componentlist['volumes']: + for brick in volume['bricks']: + if brick['hostip'] == host['hostip']: + brick['volumeName'] = volume['name'] + host['bricks'].append(brick) clusterdata['hosts'] = hostlist clusterdata['volumes'] = componentlist['volumes'] clusterdata['name'] = args.cluster diff --git a/tests/test_config_generator.py b/tests/test_config_generator.py index 1161eab..891bcbc 100644 --- a/tests/test_config_generator.py +++ b/tests/test_config_generator.py @@ -53,20 +53,21 @@ class TestGlusterNagiosConfManager(TestCaseBase): self.assertEqual(config['check_command'], "") self.assertEqual(config['use'], 'gluster-cluster') - def createBricks(self, count): + def createBricks(self, count, volume): bricks = [] for number in range(count): brickDir = "/mnt/Brick-%s" % (number + 1) - bricks.append({'brickpath': brickDir}) + bricks.append({'brickpath': brickDir, + 'volumeName': volume}) return bricks def __createDummyCluster(self): cluster = {'name': 'Test-Cluster', 'hosts': [], 'volumes': []} cluster['hosts'].append({'hostip': '10.70.43.1', - 'bricks': self.createBricks(1)}) + 'bricks': self.createBricks(1, "Volume1")}) cluster['hosts'].append({'hostip': '10.70.43.2', - 'bricks': self.createBricks(2)}) - cluster['volumes'].append({'name': 'Volume1', "typeStr": "T"}) + 'bricks': self.createBricks(2, "Volume1")}) + cluster['volumes'].append({'name': 'Volume1', "type": "T"}) return cluster def __getGlusterNagiosConfManager(self): |