summaryrefslogtreecommitdiffstats
path: root/glustolibs-gluster/glustolibs/gluster
diff options
context:
space:
mode:
authorVinayak Papnoi <vpapnoi@redhat.com>2020-01-20 15:51:54 +0530
committerBala Konda Reddy M <bmekala@redhat.com>2020-01-21 07:08:51 +0000
commit1a6c15c9d2721b94ebfa05e399dd3b7719d4843d (patch)
tree5f6f288ecea845ddef0ba58f45cf886d295e5744 /glustolibs-gluster/glustolibs/gluster
parent9496a536ead52af48b5a164f648e67b92c15fad8 (diff)
[lib] Add method to get list of snaps in .snaps
This addition is to aid the test cases which validate the existence of snapshots under the '.snaps' directory. The existing method i.e. 'uss_list_snap' does not help in getting the list of snapshots and instead just recursively performs 'ls' under the .snaps directory. This method will return a list of directory names present under the '.snaps' directory. Change-Id: I808131788df975ca243ac5721713492422af0ab8 Signed-off-by: Vinayak Papnoi <vpapnoi@redhat.com>
Diffstat (limited to 'glustolibs-gluster/glustolibs/gluster')
-rw-r--r--glustolibs-gluster/glustolibs/gluster/uss_ops.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/uss_ops.py b/glustolibs-gluster/glustolibs/gluster/uss_ops.py
index a6f9b8f..2df112d 100644
--- a/glustolibs-gluster/glustolibs/gluster/uss_ops.py
+++ b/glustolibs-gluster/glustolibs/gluster/uss_ops.py
@@ -154,6 +154,7 @@ def uss_list_snaps(client, mount):
Args:
client(str):client on which commands has to be executed
mount(str): Mount points to be executed
+
Returns:
tuple: Tuple containing three elements (ret, out, err).
The first element 'ret' is of type 'int' and is the return value
@@ -167,3 +168,29 @@ def uss_list_snaps(client, mount):
"""
cmd = "ls -R %s/.snaps" % (mount)
return g.run(client, cmd)
+
+
+def get_uss_list_snaps(client, mount):
+ """Fetches the list of snapshots under the .snaps directory
+
+ Args:
+ client(str):client on which commands has to be executed
+ mount(str): Mount points to be executed
+
+ Returns:
+ NoneType: If there are errors
+ list: List of snapshot names present under .snaps directory
+
+ Examples:
+ >>> get_uss_list_snaps('abc.lab.eng.xyz.com', 'mountpoint')
+ ['snap1', 'snap2', 'snap3']
+
+ """
+ cmd = "ls %s/.snaps" % (mount)
+ ret, out, _ = g.run(client, cmd)
+ if ret:
+ g.log.error(".snaps list returned error")
+ return None
+
+ snap_dir_list = out.splitlines()
+ return snap_dir_list