diff options
author | Sahina Bose <sabose@redhat.com> | 2014-04-10 15:37:27 +0530 |
---|---|---|
committer | Bala.FA <barumuga@redhat.com> | 2014-04-28 16:20:46 +0530 |
commit | fdcfd605a72fb3c13ddade5dfed4275c929afff5 (patch) | |
tree | 8401775616f03b04e89be9a880ef625f4dd0df9a /glusternagios | |
parent | 38049d133273d0735b8eeb470d3ac08f2f90dd17 (diff) |
common: Added volume quota status
Added volume quota status to glustercli
Change-Id: Iefe0766d652dab7adb5d2514410434fb5c190631
Signed-off-by: Sahina Bose <sabose@redhat.com>
Signed-off-by: Kanagaraj M <kmayilsa@redhat.com>
Diffstat (limited to 'glusternagios')
-rwxr-xr-x | glusternagios/glustercli.py | 30 |
1 files changed, 30 insertions, 0 deletions
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, |