summaryrefslogtreecommitdiffstats
path: root/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py
diff options
context:
space:
mode:
authorSri Vignesh <sselvan@redhat.com>2019-09-25 14:12:51 +0530
committerSri Vignesh <sselvan@redhat.com>2019-11-21 12:49:19 +0530
commit746e741ea2e728383b8591356bac1d7d23140ca1 (patch)
tree0d9465b6ef5c34568331da22ef78c3e1adfca2fd /openshift-storage-libs/openshiftstoragelibs/heketi_ops.py
parente7264123e6463f418df8c6d7b75f91e504294ecb (diff)
Modify and move 'topology_volumes_with_bricks' func to 'heketi_ops.py'
Move 'topology_volumes_with_bricks' func to the "heketi_ops" module to be able to use it in other test cases. Change-Id: I7cca884a4f3fb34ec15bb947d3c39d9226e294d0 Signed-off-by: Sri Vignesh <sselvan@redhat.com>
Diffstat (limited to 'openshift-storage-libs/openshiftstoragelibs/heketi_ops.py')
-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 7cb04784..f2c8196b 100644
--- a/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py
+++ b/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py
@@ -1778,3 +1778,35 @@ def heketi_volume_endpoint_patch(
out = heketi_cmd_run(heketi_client_node, cmd)
return json.loads(out)
+
+
+def get_heketi_volume_and_brick_count_list(
+ heketi_client_node, heketi_server_url, **kwargs):
+ """Calculate amount of volumes and bricks.
+
+ Args:
+ heketi_client_node (str): Node on which cmd has to be executed.
+ heketi_server_url (str): Heketi server url
+
+ Kwargs:
+ The keys, values in kwargs are:
+ - secret : (str)|None
+ - user : (str)|None
+
+ Returns:
+ list of tuples containing volume name and brick count
+
+ example:
+ [('heketidbstorage', 3), ('vol_dcedb64fae938d8a72d0749c2159fcdb', 6)]
+
+ Raises:
+ AssertionError: if command fails.
+
+ """
+ topology_info = heketi_topology_info(
+ heketi_client_node, heketi_server_url, json=True, **kwargs)
+ volume_name_brick_count = []
+ for c in topology_info['clusters']:
+ volume_name_brick_count = [
+ (v['name'], len(v['bricks'])) for v in c['volumes']]
+ return volume_name_brick_count