From fdcfd605a72fb3c13ddade5dfed4275c929afff5 Mon Sep 17 00:00:00 2001 From: Sahina Bose Date: Thu, 10 Apr 2014 15:37:27 +0530 Subject: common: Added volume quota status Added volume quota status to glustercli Change-Id: Iefe0766d652dab7adb5d2514410434fb5c190631 Signed-off-by: Sahina Bose Signed-off-by: Kanagaraj M --- glusternagios/glustercli.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'glusternagios') diff --git a/glusternagios/glustercli.py b/glusternagios/glustercli.py index 0a126e7..03ea806 100755 --- a/glusternagios/glustercli.py +++ b/glusternagios/glustercli.py @@ -82,6 +82,12 @@ class VolumeStatus: OFFLINE = 'OFFLINE' +class VolumeQuotaStatus: + DISABLED = 'DISABLED' + OK = 'OK' + EXCEEDED = 'EXCEEDED' + + class TransportType: TCP = 'TCP' RDMA = 'RDMA' @@ -432,6 +438,30 @@ def volumeInfo(volumeName=None, remoteServer=None): raise GlusterCmdFailedException(err=[etree.tostring(xmltree)]) +def _parseVolumeQuotaStatus(out): + for line in out: + if line.startswith('quota: No quota') or line.find('not enabled') > -1: + return VolumeQuotaStatus.DISABLED + if line.find('Yes') > -1: + return VolumeQuotaStatus.EXCEEDED + return VolumeQuotaStatus.OK + + +def volumeQuotaStatus(volumeName, remoteServer=None): + """ + Returns: + STATUS + """ + command = _getGlusterVolCmd() + ["quota", volumeName, "list"] + if remoteServer: + command += ['--remote-host=%s' % remoteServer] + + rc, out, err = _execGluster(command) + if rc == 0: + return _parseVolumeQuotaStatus(out) + raise GlusterCmdFailedException(rc, err) + + def _parsePeerStatus(tree, gHostName, gUuid, gStatus): hostList = [{'hostname': gHostName, 'uuid': gUuid, -- cgit