summaryrefslogtreecommitdiffstats
path: root/glustolibs-gluster/glustolibs/gluster
diff options
context:
space:
mode:
authorRajesh Madaka <rmadaka@redhat.com>2018-01-23 18:23:06 +0530
committerRajesh Madaka <rmadaka@redhat.com>2018-01-25 19:02:38 +0530
commit1357c49f5ecfa68abd6efbe53b0718924be97996 (patch)
tree888917f84bee487fa16c6feb9e1f14faf45b97a7 /glustolibs-gluster/glustolibs/gluster
parent99aedb316e3c9491e4d752d1bbc49b6496a7e627 (diff)
Library for checking snapshot daemon is running or not
Added is_snapd_running function to uss_ops.py file Change-Id: Ib1ff0a16550c94604209588bd5221f9ee6e9db92 Signed-off-by: Rajesh Madaka <rmadaka@redhat.com>
Diffstat (limited to 'glustolibs-gluster/glustolibs/gluster')
-rw-r--r--glustolibs-gluster/glustolibs/gluster/uss_ops.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/uss_ops.py b/glustolibs-gluster/glustolibs/gluster/uss_ops.py
index 4a48a2c..4914816 100644
--- a/glustolibs-gluster/glustolibs/gluster/uss_ops.py
+++ b/glustolibs-gluster/glustolibs/gluster/uss_ops.py
@@ -20,6 +20,7 @@
"""
from glusto.core import Glusto as g
+from glustolibs.gluster.volume_ops import get_volume_status
def enable_uss(mnode, volname):
@@ -113,3 +114,35 @@ def is_uss_disabled(mnode, volname):
return True
else:
return False
+
+
+def is_snapd_running(mnode, volname):
+ """Checks if snapd is running on the given node
+
+ Args:
+ mnode (str): Node on which cmd has to be executed.
+ volname (str): volume name
+
+ Returns:
+ True on success, False otherwise
+
+ Example:
+ is_snapd_running("abc.com", "testvol")
+ """
+ vol_status = get_volume_status(mnode, volname=volname)
+
+ if vol_status is None:
+ g.log.error("Failed to get volume status in is_snapd_running()")
+ return False
+
+ if 'Snapshot Daemon' not in vol_status[volname][mnode]:
+ g.log.error("uss is not enabled in volume %s"
+ % volname)
+ return False
+
+ snapd_status = vol_status[volname][mnode]['Snapshot Daemon']['status']
+ if snapd_status != '1':
+ g.log.error("Snapshot Daemon is not running in node %s"
+ % mnode)
+ return False
+ return True