summaryrefslogtreecommitdiffstats
path: root/openshift-storage-libs/openshiftstoragelibs
diff options
context:
space:
mode:
authorvamahaja <vamahaja@redhat.com>2019-09-25 20:15:46 +0530
committervamahaja <vamahaja@redhat.com>2019-10-17 17:05:42 +0530
commit70ded8d3fbfe0b9962d7b4d83edee25044c5ab9b (patch)
tree4ab10eb5e8d0a3369543fe6aeb4bab725c3ee2f5 /openshift-storage-libs/openshiftstoragelibs
parent22d5a75ea92b555beb6da357dc4f46908b17248e (diff)
Add library to get heketi block volumes by name prefix
This change required due to - 1. Get block volume by prefix is common step which is used in two places for now and will be used in other places too. 2. Hence add library "heketi_blockvolume_list_by_name_prefix" in heketi_ops.py. 3. And use added library and update code from class "GlusterStabilityTestSetup" and "TestGlusterBlockStability". Change-Id: I9e60d58d5c84380104081335745270b3d21ff071 Signed-off-by: vamahaja <vamahaja@redhat.com>
Diffstat (limited to 'openshift-storage-libs/openshiftstoragelibs')
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/heketi_ops.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py b/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py
index 251104d..c28c98d 100644
--- a/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py
+++ b/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py
@@ -1244,6 +1244,38 @@ def heketi_blockvolume_list(heketi_client_node, heketi_server_url, **kwargs):
return out
+def heketi_blockvolume_list_by_name_prefix(
+ heketi_client_node, heketi_server_url, prefix, **kwargs):
+ """Get block volume id, cluster and name by name prefix.
+
+ Args:
+ heketi_client_node (str): Node on which cmd has to be executed.
+ heketi_server_url (str): Heketi server url.
+ prefix (str): Block volume name prefix.
+
+ Kwargs:
+ The keys, values in kwargs are:
+ - secret : (str)|None
+ - user : (str)|None
+
+ Returns:
+ list: tuple of bv id, cluster id and name
+
+ Raises:
+ exceptions.AssertionError: if command fails to execute on
+ heketi server.
+ """
+ # Delete json key from kwargs
+ kwargs.pop("json", None)
+
+ block_vols = heketi_blockvolume_list(
+ heketi_client_node, heketi_server_url, **kwargs)
+
+ block_vol_regex = re.compile(
+ r"Id:(\S+)\s+Cluster:(\S+)\s+Name:(%s_\S+)" % prefix)
+ return block_vol_regex.findall(block_vols.strip())
+
+
def verify_volume_name_prefix(hostname, prefix, namespace, pvc_name,
heketi_server_url, **kwargs):
"""Check whether heketi volume is present with volname prefix or not.