diff options
author | Sunny Kumar <sunkumar@redhat.com> | 2018-06-11 18:27:14 +0530 |
---|---|---|
committer | Nigel Babu <nigelb@redhat.com> | 2018-06-18 04:17:58 +0000 |
commit | af39d1e53e73a65d4a6b0773dd5eafa362ec1f9b (patch) | |
tree | 5dc3d15323498059c0d7a316c071c10495702100 /glustolibs-gluster/glustolibs/gluster/snap_scheduler.py | |
parent | 5fc68f6725671bf329609d05b029b4610f1d4f16 (diff) |
snapshot:: Modification in library for snap scheduler
Following modifications has been made -
1. Added function for snap scheduler initialization.
2. Snap scheduler initialization should not be combined with snap
schedule enable.
3. Snap scheduler enable/disable should be issued for a node instead
for every node in cluster.
Change-Id: I23650f48b152debdfb4d7bc8af6f65ecb2bcddfb
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
Diffstat (limited to 'glustolibs-gluster/glustolibs/gluster/snap_scheduler.py')
-rw-r--r-- | glustolibs-gluster/glustolibs/gluster/snap_scheduler.py | 88 |
1 files changed, 50 insertions, 38 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/snap_scheduler.py b/glustolibs-gluster/glustolibs/gluster/snap_scheduler.py index cbc159aa6..4493cf40f 100644 --- a/glustolibs-gluster/glustolibs/gluster/snap_scheduler.py +++ b/glustolibs-gluster/glustolibs/gluster/snap_scheduler.py @@ -24,60 +24,72 @@ from glusto.core import Glusto as g """ -def scheduler_enable(servers): - """Initialises snapshot scheduler on given node - Args: - servers (str): list of servers on which cmd has to be executed. - - Example: - scheduler_enable("abc.com") +def scheduler_init(servers): + """Initialises snapshot scheduler + Args: + servers(str): List of servers on which cmd has to be executed. + + Returns: + True - Success + False - Failure + Example: + scheduler_init("abc.com") + """ - Returns: - True on success. - False on failure. - """ if isinstance(servers, str): servers = [servers] - cmd1 = "snap_scheduler.py init" - cmd2 = "snap_scheduler.py enable" - _rc = True + cmd = "snap_scheduler.py init" for server in servers: - ret1, _, _ = g.run(server, cmd1) - if ret1 != 0: - g.log.error("snap scheduler is not running on" - "the server %s", server) + ret, _, _ = g.run(server, cmd) + if ret != 0: + g.log.error("Unable to initialize scheduler on %s", server) return False + return True + - ret2, _, _ = g.run(servers[0], cmd2) - if ret2 != 0: - g.log.error("Failed to enable snap scheduler") - _rc = False - return _rc +def scheduler_enable(mnode): + """Enables snapshot scheduler on given node + Args: + mnode (str): Node on which cmd has to be executed. + Returns: + tuple: Tuple containing three elements (ret, out, err). + The first element 'ret' is of type 'int' and is the return value + of command execution. + The second element 'out' is of type 'str' and is the stdout value + of the command execution. + The third element 'err' is of type 'str' and is the stderr value + of the command execution. -def scheduler_disable(servers): - """Initialises snapshot scheduler on given node + Example: + scheduler_enable("abc.com") + """ + + cmd = "snap_scheduler.py enable" + return g.run(mnode, cmd) + + +def scheduler_disable(mnode): + """Disables snapshot scheduler on given node Args: servers (str): servers on which cmd has to be executed. + Returns: + tuple: Tuple containing three elements (ret, out, err). + The first element 'ret' is of type 'int' and is the return value + of command execution. + The second element 'out' is of type 'str' and is the stdout value + of the command execution. + The third element 'err' is of type 'str' and is the stderr value + of the command execution. + Example: scheduler_disable("abc.com") - - Returns: - True on success. - False on failure. - """ - if isinstance(servers, str): - servers = [servers] + """ cmd = "snap_scheduler.py disable" - _rc = True - ret, _, _ = g.run(servers[0], cmd) - if ret != 0: - g.log.error("Failed to disable snap scheduler") - _rc = False - return _rc + return g.run(mnode, cmd) def scheduler_add_jobs(mnode, jobname, scheduler, volname): |