From 746e741ea2e728383b8591356bac1d7d23140ca1 Mon Sep 17 00:00:00 2001 From: Sri Vignesh Date: Wed, 25 Sep 2019 14:12:51 +0530 Subject: 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 --- .../openshiftstoragelibs/heketi_ops.py | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'openshift-storage-libs') 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 -- cgit