diff options
author | kasturiNarra <knarra@redhat.com> | 2019-01-25 17:56:40 +0530 |
---|---|---|
committer | vponomar <vponomar@redhat.com> | 2019-07-19 12:34:03 +0000 |
commit | 13ae8998a1338dad74337762af0db069b9ddc3d0 (patch) | |
tree | 7f71af291e59be096301ddc30976e5e11d81654d /openshift-storage-libs | |
parent | 2e0e0d67cb285c7e9f8b2113dfa9fd51015d2f12 (diff) |
Add test case where BHV and BV are created and deleted
Change-Id: I7ead23c46a472fee70d684c45f32f5e4efb0674f
Signed-off-by: kasturiNarra <knarra@redhat.com>
Diffstat (limited to 'openshift-storage-libs')
-rw-r--r-- | openshift-storage-libs/openshiftstoragelibs/heketi_ops.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py b/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py index 7266445a..0021e79b 100644 --- a/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py +++ b/openshift-storage-libs/openshiftstoragelibs/heketi_ops.py @@ -1416,3 +1416,33 @@ def get_block_hosting_volume_list( BHV[volume[0]] = {'Cluster': volume[1], 'Name': volume[2]} return BHV + + +def get_total_free_space(heketi_client_node, heketi_server_url): + """ + Calculates free space across devices which are online + and skips the ones which are offline. + Args: + - heketi_client_node (str): Node where we want to run our commands. + - heketi_server_url (str): This is a heketi server url. + + Returns: + int: if successful + + """ + device_free_spaces = [] + heketi_node_id_list = heketi_node_list( + heketi_client_node, heketi_server_url) + for node_id in heketi_node_id_list: + total_device_free_space = 0 + node_info_dict = heketi_node_info( + heketi_client_node, heketi_server_url, + node_id, json=True) + if (node_info_dict["state"].strip().lower() != "online"): + continue + for device in node_info_dict["devices"]: + if (device["state"].strip().lower() != "online"): + continue + total_device_free_space += (device["storage"]["free"]) + device_free_spaces.append(total_device_free_space / 1024 ** 2) + return int(sum(device_free_spaces)), len(device_free_spaces) |