From 74b4bab01b504f735e656f855100441afe2a700a Mon Sep 17 00:00:00 2001 From: Vinayak Papnoi Date: Wed, 31 Jul 2019 16:32:24 +0530 Subject: Add library to reset particular volume option Currently there is a library to reset the volume entirely. There needs to be a library to reset a particular volume option because if a user has set a lot of other volume options then it becomes a tedious job to reset and set the other options explicitly. The library function 'reset_volume_option' takes particular volume options as a string and resets it. Change-Id: I2049ea4a49d321d921d940f34e124d1f34bfa068 Signed-off-by: Vinayak Papnoi --- .../glustolibs/gluster/volume_ops.py | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'glustolibs-gluster/glustolibs/gluster') diff --git a/glustolibs-gluster/glustolibs/gluster/volume_ops.py b/glustolibs-gluster/glustolibs/gluster/volume_ops.py index e478ed979..0b3c94b07 100644 --- a/glustolibs-gluster/glustolibs/gluster/volume_ops.py +++ b/glustolibs-gluster/glustolibs/gluster/volume_ops.py @@ -594,6 +594,41 @@ def set_volume_options(mnode, volname, options): return _rc +def reset_volume_option(mnode, volname, option, force=False): + """Resets the volume option + + Args: + mnode (str): Node on which cmd has to be executed + volname (str): volume name + option (str): volume option + + Kwargs: + force (bool): If this option is set to True, then reset volume + will get executed with force option. If it is set to False, + then reset volume 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. + + Example: + reset_volume_option("abc.xyz.com", "testvol", "option") + """ + if force: + cmd = ("gluster volume reset %s %s force --mode=script" + % (volname, option)) + else: + cmd = "gluster volume reset %s %s --mode=script" % (volname, option) + return g.run(mnode, cmd) + + def volume_info(mnode, volname='all'): """Executes gluster volume info cli command -- cgit