summaryrefslogtreecommitdiffstats
path: root/openshift-storage-libs/openshiftstoragelibs/gluster_ops.py
diff options
context:
space:
mode:
authorSushilG96 <guptarahul201010@gmail.com>2020-01-14 19:10:33 +0530
committerVaibhav Mahajan <vamahaja@redhat.com>2020-01-24 09:47:41 +0000
commit1269e4fe3ac8c8ee3f19f94141675b8c71dbc81b (patch)
tree4ccf6b07a60c692302792d51ff873f85b9686342 /openshift-storage-libs/openshiftstoragelibs/gluster_ops.py
parent85b1c8a2cb07071bcfd1ed1405ba9e7d5d66e483 (diff)
[lib] Add lib to match PV, Heketi and get gluster vols by name prefix
This contains libraries - 1. match_pv_and_heketi_volumes - library for matching heketi volumes and PVCs. 2. heketi_volume_list_by_name_prefix - library to getvolume id and cluster id. 3. match_heketi_and_gluster_volumes_by_prefix - library for matching heketi and gluster volumes. Change-Id: I02af31405a9836000d758a2ffac932be13e52a03
Diffstat (limited to 'openshift-storage-libs/openshiftstoragelibs/gluster_ops.py')
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/gluster_ops.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/gluster_ops.py b/openshift-storage-libs/openshiftstoragelibs/gluster_ops.py
index b80c587d..422c8a01 100644
--- a/openshift-storage-libs/openshiftstoragelibs/gluster_ops.py
+++ b/openshift-storage-libs/openshiftstoragelibs/gluster_ops.py
@@ -267,3 +267,25 @@ def get_block_hosting_volume_name(heketi_client_node, heketi_server_url,
for vol in gluster_vol_list:
if block_hosting_vol_match.group(1).strip() in vol:
return vol
+
+
+@podcmd.GlustoPod()
+def match_heketi_and_gluster_volumes_by_prefix(heketi_volumes, prefix):
+ """Match volumes from heketi and gluster using given volume name prefix
+
+ Args:
+ heketi_volumes (list): List of heketi volumes with which gluster
+ volumes need to be matched
+ prefix (str): Volume prefix by which the volumes needs to be filtered
+ """
+ g_vol_list = get_volume_list("auto_get_gluster_endpoint")
+ g_volumes = [
+ g_vol.replace(prefix, "")
+ for g_vol in g_vol_list if g_vol.startswith(prefix)]
+
+ vol_difference = set(heketi_volumes) ^ set(g_volumes)
+ err_msg = ("Heketi and Gluster volume list match failed"
+ "Heketi volumes: {}, Gluster Volumes: {},"
+ "Difference: {}"
+ .format(heketi_volumes, g_volumes, vol_difference))
+ assert not vol_difference, err_msg