diff options
author | Vinayak Papnoi <vpapnoi@redhat.com> | 2020-01-20 17:46:14 +0530 |
---|---|---|
committer | Bala Konda Reddy M <bmekala@redhat.com> | 2020-01-29 12:04:22 +0000 |
commit | 462fea68593f384a417ee45d655f333bc68ed75f (patch) | |
tree | 617c3aeb4c5d24e4367dec721eee9fc55e53132c /glustolibs-gluster | |
parent | 38ba8b796bda281144bf21a40cab1ea27341d57b (diff) |
[libfix] Fix get_snap_list in snap_ops.py
The existing method does not have an option to use the volume name
to get the list of snapshots. Without the option to provide the
volume name, it is not possible to get the snapshots specific to a
volume.
With this fix, there is an addition of a kwarg 'volname' for the
method 'get_snap_list' with which the snapshots of a particular
volume can be listed. This option is necessary in some test cases
where the user needs to get the list of snapshots specific to a
particular volume.
This fix also includes a small typo error in the description of
a method.
Change-Id: Ib0aeaf417a37142ebe36847e27bcd60683f325e7
Signed-off-by: Vinayak Papnoi <vpapnoi@redhat.com>
Diffstat (limited to 'glustolibs-gluster')
-rw-r--r-- | glustolibs-gluster/glustolibs/gluster/snap_ops.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/snap_ops.py b/glustolibs-gluster/glustolibs/gluster/snap_ops.py index 114366320..1e792ada7 100644 --- a/glustolibs-gluster/glustolibs/gluster/snap_ops.py +++ b/glustolibs-gluster/glustolibs/gluster/snap_ops.py @@ -461,7 +461,7 @@ def get_snap_info_by_volname(mnode, volname): Args: mnode (str): Node on which command has to be executed. - volname (str): snapshot name + volname (str): volume name Returns: NoneType: None if command execution fails, parse errors. @@ -552,12 +552,17 @@ def snap_list(mnode): return g.run(mnode, cmd) -def get_snap_list(mnode): +def get_snap_list(mnode, volname=""): """Parse the output of 'gluster snapshot list' command. + If a volname is provided then the output will be specific + to that volume. Args: mnode (str): Node on which command has to be executed. + Kwargs: + volname (str): volume name + Returns: NoneType: None if command execution fails, parse errors. list: list of snapshots on success. @@ -567,7 +572,8 @@ def get_snap_list(mnode): ['snap1', 'snap2'] """ - ret, out, _ = g.run(mnode, "gluster snapshot list --xml") + cmd = "gluster snapshot list %s --xml" % volname + ret, out, _ = g.run(mnode, cmd) if ret != 0: g.log.error("Failed to execute 'snapshot list' on node %s. " "Hence failed to get the snapshot list.", mnode) |