summaryrefslogtreecommitdiffstats
path: root/glustolibs-gluster/glustolibs/gluster/brick_ops.py
diff options
context:
space:
mode:
authorubansal <ubansal@redhat.com>2018-06-13 14:48:27 +0530
committerNigel Babu <nigelb@redhat.com>2018-06-15 07:17:27 +0000
commit36a1f2ac5fd04042c179e60da546b83a4f7e64f8 (patch)
treef1ad1816b9c2e38000e5a9fdddc40203760e8b67 /glustolibs-gluster/glustolibs/gluster/brick_ops.py
parent6583686527c62d88d678c9d4040eaa9fe728efeb (diff)
Function for reset brick added in the brick_ops
Change-Id: I01ad84cc2e35873b985d5d86d3cbacd226b42ae1 Signed-off-by: ubansal <ubansal@redhat.com>
Diffstat (limited to 'glustolibs-gluster/glustolibs/gluster/brick_ops.py')
-rw-r--r--glustolibs-gluster/glustolibs/gluster/brick_ops.py53
1 files changed, 52 insertions, 1 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/brick_ops.py b/glustolibs-gluster/glustolibs/gluster/brick_ops.py
index db4074c..9c0f3dd 100644
--- a/glustolibs-gluster/glustolibs/gluster/brick_ops.py
+++ b/glustolibs-gluster/glustolibs/gluster/brick_ops.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2015-2016 Red Hat, Inc. <http://www.redhat.com>
+# Copyright (C) 2017-2018 Red Hat, Inc. <http://www.redhat.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -16,6 +16,7 @@
""" Description: Module for gluster brick operations """
+
from glusto.core import Glusto as g
@@ -147,3 +148,53 @@ def replace_brick(mnode, volname, src_brick, dst_brick):
cmd = ("gluster volume replace-brick %s %s %s commit force" %
(volname, src_brick, dst_brick))
return g.run(mnode, cmd)
+
+
+def reset_brick(mnode, volname, src_brick, option, dst_brick=None,
+ force=False):
+ """Reset brick in a volume
+
+ Args:
+ mnode (str): Node on which the commands are executed.
+ volname (str): Name of the volume
+ src_brick (str): Source brick name
+ dst_brick (str): Destination brick name
+ option (str): Reset brick options: <start|commit|force>
+
+ Kwargs:
+ force (bool): If this option is set to True, then reset brick
+ will get executed with force option. If it is set to False,
+ then reset brick will get executed without force option
+
+ 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.
+ """
+ # pylint: disable=too-many-arguments
+ if option == "start":
+ cmd = ("gluster volume reset-brick %s %s start" % (volname, src_brick))
+
+ elif option == "commit":
+ if dst_brick is None:
+ dst_brick = src_brick
+ if force:
+ cmd = ("gluster volume reset-brick %s %s %s %s "
+ "force" % (volname, src_brick, dst_brick, option))
+ else:
+ cmd = ("gluster volume reset-brick %s %s %s %s"
+ % (volname, src_brick, dst_brick, option))
+ else:
+ if force:
+ cmd = ("gluster volume reset-brick %s %s %s %s force"
+ % (volname, src_brick, dst_brick, option))
+ else:
+ cmd = ("gluster volume reset-brick %s %s %s %s"
+ % (volname, src_brick, dst_brick, option))
+ return g.run(mnode, cmd)