summaryrefslogtreecommitdiffstats
path: root/glustolibs-gluster/glustolibs/gluster/brick_ops.py
diff options
context:
space:
mode:
authorShwetha Panduranga <spandura@redhat.com>2017-03-20 14:39:05 +0530
committerShwethaHP <spandura@redhat.com>2017-05-31 11:13:04 +0530
commit8f09d6d30b5745bd2abf8b73b5d8df8c63b79f63 (patch)
tree307695e58c28c553ad7eed5ec1a5ffb34119ac87 /glustolibs-gluster/glustolibs/gluster/brick_ops.py
parent2ab855127567488373e0fd78f64d8f5f4f26b042 (diff)
Adding a sanity case to test shrinking volume. i.e remove-brick
Remove brick Sanity case covers testing of remove-brick of a subvolume, waiting for rebalance to complete, commiting the operation and validate IO is successful on the mount. Change-Id: I5912f62b3df5dfb5bf5339de036967f83b6a5117 Signed-off-by: Shwetha Panduranga <spandura@redhat.com>
Diffstat (limited to 'glustolibs-gluster/glustolibs/gluster/brick_ops.py')
-rw-r--r--glustolibs-gluster/glustolibs/gluster/brick_ops.py30
1 files changed, 20 insertions, 10 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/brick_ops.py b/glustolibs-gluster/glustolibs/gluster/brick_ops.py
index 016569f15..0e99b955e 100644
--- a/glustolibs-gluster/glustolibs/gluster/brick_ops.py
+++ b/glustolibs-gluster/glustolibs/gluster/brick_ops.py
@@ -74,7 +74,7 @@ def add_brick(mnode, volname, bricks_list, force=False, **kwargs):
return g.run(mnode, cmd)
-def remove_brick(mnode, volname, bricks_list, option, replica=None):
+def remove_brick(mnode, volname, bricks_list, option, xml=False, **kwargs):
"""Remove bricks specified in the bricks_list from the volume.
Args:
@@ -84,8 +84,10 @@ def remove_brick(mnode, volname, bricks_list, option, replica=None):
option (str): Remove brick options: <start|stop|status|commit|force>
Kwargs:
- replica (int): Replica count to increase the replica count of
- the volume.
+ xml (bool): if xml is True, get xml output of command execution.
+ **kwargs
+ The keys, values in kwargs are:
+ - replica_count : (int)|None
Returns:
tuple: Tuple containing three elements (ret, out, err).
@@ -101,13 +103,21 @@ def remove_brick(mnode, volname, bricks_list, option, replica=None):
if option == "commit" or option == "force":
option = option + " --mode=script"
- if replica is None:
- cmd = ("gluster volume remove-brick %s %s %s" %
- (volname, ' '.join(bricks_list), option))
- else:
- cmd = ("gluster volume remove-brick %s replica %d %s force "
- "--mode=script" % (volname, int(replica),
- ' '.join(bricks_list)))
+ replica_count = None
+ replica = ''
+
+ if 'replica_count' in kwargs:
+ replica_count = int(kwargs['replica_count'])
+
+ if replica_count is not None:
+ replica = "replica %d" % replica_count
+
+ xml_str = ''
+ if xml:
+ xml_str = "--xml"
+
+ cmd = ("gluster volume remove-brick %s %s %s %s %s" %
+ (volname, replica, ' '.join(bricks_list), option, xml_str))
return g.run(mnode, cmd)