summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSahina Bose <sabose@redhat.com>2014-04-16 09:36:09 +0530
committerBala.FA <barumuga@redhat.com>2014-04-29 10:14:33 +0530
commite77dc4c7ba3506a8ca23210d5fc7ef568ef4c31c (patch)
tree5996267e2fb125cbf9387d772398ba2cd1246d83
parentf3b8194e9c851a8cfb32e670493881fd5c406c4a (diff)
plugins: Added volume info as part of volume status
The volume status also needs to look at the brick statuses Changed the plugin to return the volume info in case the volume is UP Change-Id: Iee0b2ad84c7a3c5d5ebdc7e0616fb6d987cfb25a Signed-off-by: Sahina Bose <sabose@redhat.com>
-rwxr-xr-xplugins/check_volume_status.py7
-rw-r--r--tests/test_check_volume_status.py26
2 files changed, 31 insertions, 2 deletions
diff --git a/plugins/check_volume_status.py b/plugins/check_volume_status.py
index df68657..7c72ef9 100755
--- a/plugins/check_volume_status.py
+++ b/plugins/check_volume_status.py
@@ -17,6 +17,8 @@
#
import argparse
+import json
+
from glusternagios import utils
from glusternagios import glustercli
@@ -32,8 +34,11 @@ def getVolumeStatus(args):
return exitstatus, message
elif volumes[args.volume]["volumeStatus"] == (glustercli.
VolumeStatus.ONLINE):
+ ret_volumes = {}
+ ret_volumes[args.volume] = volumes.get(args.volume)
+ ret_volumes[args.volume]['options'] = {}
exitstatus = utils.PluginStatusCode.OK
- message = "OK: Volume is up"
+ message = ("OK: Volume is up \n%s" % json.dumps(ret_volumes))
elif volumes[args.volume]["volumeStatus"] == (glustercli.
VolumeStatus.OFFLINE):
exitstatus = utils.PluginStatusCode.CRITICAL
diff --git a/tests/test_check_volume_status.py b/tests/test_check_volume_status.py
index 6b0be67..68c5a9b 100644
--- a/tests/test_check_volume_status.py
+++ b/tests/test_check_volume_status.py
@@ -17,6 +17,7 @@
#
# Refer to the README and COPYING files for full details of the license
#
+import json
import mock
from testrunner import PluginsTestCase as TestCaseBase
@@ -41,6 +42,9 @@ class TestCheckVolumeStatus(TestCaseBase):
args = ArgParseMock('test-cluster', 'test-vol')
exitStatusCode, exitStatusMsg = (check_volume_status
.getVolumeStatus(args))
+ print exitStatusMsg
+ print _expectedVolume()
+ assert exitStatusMsg == ("OK: Volume is up \n%s" % _expectedVolume())
assert exitStatusCode == utils.PluginStatusCode.OK
# Method to test volume status when no volume
@@ -70,9 +74,29 @@ def _getVolume():
'uuid': '0000-0000-0000-1111',
'volumeName': 'test-vol',
'volumeStatus': 'ONLINE',
- 'volumeType': 'DISTRIBUTED'}}
+ 'volumeType': 'DISTRIBUTED'},
+ 'test-vol2': {'brickCount': 2,
+ 'bricks': ['server1:/path1', 'server2:/path2'],
+ 'options': {'option': 'val'},
+ 'transportType': ['tcp'],
+ 'uuid': '0000-0000-0000-1111',
+ 'volumeName': 'test-vol',
+ 'volumeStatus': 'ONLINE',
+ 'volumeType': 'DISTRIBUTED'}}
return vol
+def _expectedVolume():
+ vol = {'test-vol': {'brickCount': 2,
+ 'bricks': ['server1:/path1', 'server2:/path2'],
+ 'options': {},
+ 'transportType': ['tcp'],
+ 'uuid': '0000-0000-0000-1111',
+ 'volumeName': 'test-vol',
+ 'volumeStatus': 'ONLINE',
+ 'volumeType': 'DISTRIBUTED'}}
+ return json.dumps(vol)
+
+
def _getEmptyVolume():
return {}