diff options
-rwxr-xr-x | glusternagios/glustercli.py | 16 | ||||
-rw-r--r-- | tests/test_glustercli.py | 24 |
2 files changed, 26 insertions, 14 deletions
diff --git a/glusternagios/glustercli.py b/glusternagios/glustercli.py index 7aa0bd4..d752173 100755 --- a/glusternagios/glustercli.py +++ b/glusternagios/glustercli.py @@ -506,7 +506,7 @@ def _parseVolumeGeoRepStatus(volumeName, out): nodeline = line.split() node = nodeline[0] brick = nodeline[2] - slave = nodeline[3] + slave = nodeline[3][nodeline[3].find('::') + 2:] if slaves.get(slave) is None: slaves[slave] = {'nodecount': 0, 'faulty': 0, @@ -514,7 +514,8 @@ def _parseVolumeGeoRepStatus(volumeName, out): 'stopped': 0, 'passive': 0, 'detail': '', - 'status': GeoRepStatus.OK + 'status': GeoRepStatus.OK, + 'name': nodeline[3] } slaves[slave]['nodecount'] += 1 if GeoRepStatus.FAULTY in line.upper(): @@ -537,11 +538,17 @@ def _parseVolumeGeoRepStatus(volumeName, out): brick, tempstatus)) volumes = volumeInfo(volumeName) - replicaCount = volumes[volumeName]["brickCount"] + brickCount = volumes[volumeName]["brickCount"] if "REPLICATE" in volumes[volumeName]["volumeType"]: replicaCount = volumes[volumeName]["replicaCount"] + else: + replicaCount = brickCount for slave, count_dict in slaves.iteritems(): + if count_dict['nodecount'] > brickCount: + # There are multiple slave volumes with same name, the output + # may be wrong + slaves[slave]['detail'] += "NOTE:Multiple slave session aggregated" if count_dict['faulty'] > 0: # georep cli status does not give the node name in the same way as # gluster volume info - there's no way to compare and get the @@ -573,7 +580,8 @@ def volumeGeoRepStatus(volumeName, remoteServer=None): 'stopped': COUNT, 'passive':COUNT, 'detail': detailed message, - 'status': GEOREPSTATUS}} + 'status': GEOREPSTATUS, + 'name': SLAVESESSIONNAME}} ]} """ command = _getGlusterVolCmd() + ["geo-replication", volumeName, "status"] diff --git a/tests/test_glustercli.py b/tests/test_glustercli.py index e10a11f..5c71f34 100644 --- a/tests/test_glustercli.py +++ b/tests/test_glustercli.py @@ -1151,7 +1151,7 @@ class GlusterCliTests(TestCaseBase): } } expectedOut = {'test-vol': - {'slaves': {'10.70.43.68::slave-vol': + {'slaves': {'slave-vol': {'faulty': 2, 'nodecount': 2, 'notstarted': 0, @@ -1161,7 +1161,8 @@ class GlusterCliTests(TestCaseBase): '/bricks/b3 - FAULTY;' 'rhs3-2.novalocal:' '/bricks/b3 - FAULTY;', - 'status': gcli.GeoRepStatus.FAULTY} + 'status': gcli.GeoRepStatus.FAULTY, + 'name': '10.70.43.68::slave-vol'} }}} status = gcli.volumeGeoRepStatus("test-vol") print(status) @@ -1186,7 +1187,7 @@ class GlusterCliTests(TestCaseBase): } expectedOut = {'test-vol': {'slaves': - {'10.70.43.68::slave-vol': + {'slave-vol': {'faulty': 1, 'nodecount': 2, 'notstarted': 0, @@ -1196,8 +1197,9 @@ class GlusterCliTests(TestCaseBase): '- PASSIVE;' 'rhs3-2.novalocal:/bricks/b3 ' '- FAULTY;', - 'status': gcli.GeoRepStatus.FAULTY}, - '10.70.43.68::slave-vol2': + 'status': gcli.GeoRepStatus.FAULTY, + 'name': '10.70.43.68::slave-vol'}, + 'slave-vol2': {'faulty': 0, 'nodecount': 2, 'notstarted': 2, @@ -1207,7 +1209,8 @@ class GlusterCliTests(TestCaseBase): '- NOT_STARTED;' 'rhs3-2.novalocal:/bricks/b3 ' '- NOT_STARTED;', - 'status': gcli.GeoRepStatus.NOT_STARTED} + 'status': gcli.GeoRepStatus.NOT_STARTED, + 'name': '10.70.43.68::slave-vol2'} }}} status = gcli.volumeGeoRepStatus("test-vol") print(status) @@ -1217,7 +1220,7 @@ class GlusterCliTests(TestCaseBase): None) expectedOut = {'test-vol': {'slaves': - {'10.70.43.68::slave-vol': + {'slave-vol': {'faulty': 0, 'nodecount': 2, 'notstarted': 1, @@ -1228,7 +1231,8 @@ class GlusterCliTests(TestCaseBase): 'rhs3-2.novalocal:' '/bricks/b3 ' '- NOT_STARTED;', - 'status': gcli.GeoRepStatus.NOT_STARTED + 'status': gcli.GeoRepStatus.NOT_STARTED, + 'name': '10.70.43.68::slave-vol' }}}} status = gcli.volumeGeoRepStatus("test-vol") print(status) @@ -1293,13 +1297,13 @@ class GlusterCliTests(TestCaseBase): "10.70.43.68::slave-vol Passive " "N/A N/A", "rhs3-2.novalocal rep /bricks/b3 " - "10.70.43.68::slave-vol faulty " + "10.70.43.69::slave-vol faulty " "N/A N/A ", "rhs3.novalocal rep /bricks/b3 " "10.70.43.68::slave-vol2 Not Started " "N/A N/A", "rhs3-2.novalocal rep /bricks/b3 " - "10.70.43.68::slave-vol2 Not Started " + "10.70.43.69::slave-vol2 Not Started " "N/A N/A "] def __getGlusterGeoRepStatusResult3(self): |