From 1357c49f5ecfa68abd6efbe53b0718924be97996 Mon Sep 17 00:00:00 2001 From: Rajesh Madaka Date: Tue, 23 Jan 2018 18:23:06 +0530 Subject: 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 --- glustolibs-gluster/glustolibs/gluster/uss_ops.py | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/glustolibs-gluster/glustolibs/gluster/uss_ops.py b/glustolibs-gluster/glustolibs/gluster/uss_ops.py index 4a48a2cb0..491481613 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 -- cgit