diff options
author | Vinayak Papnoi <vpapnoi@redhat.com> | 2019-07-31 16:32:24 +0530 |
---|---|---|
committer | Vinayak Papnoi <vpapnoi@redhat.com> | 2019-07-31 16:47:11 +0530 |
commit | 74b4bab01b504f735e656f855100441afe2a700a (patch) | |
tree | 814d08ffc484885388e632068ec9ff08c5a7ecb3 /glustolibs-gluster | |
parent | 790c20c46dee6053c87f709ea8a38ab6384e591f (diff) |
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 <vpapnoi@redhat.com>
Diffstat (limited to 'glustolibs-gluster')
-rw-r--r-- | glustolibs-gluster/glustolibs/gluster/volume_ops.py | 35 |
1 files changed, 35 insertions, 0 deletions
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 |