From eeb68e474a16c73798f8db916aa83af97ead4094 Mon Sep 17 00:00:00 2001 From: Arun Kumar Date: Wed, 24 Jun 2020 22:06:19 +0530 Subject: [Lib] Add library to get the free inodes of bricks Change-Id: I4ef9114a30dfd6fe18c4ba15b0cbbd32b8fc44f3 Signed-off-by: Arun Kumar --- .../openshiftstoragelibs/gluster_ops.py | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'openshift-storage-libs') diff --git a/openshift-storage-libs/openshiftstoragelibs/gluster_ops.py b/openshift-storage-libs/openshiftstoragelibs/gluster_ops.py index d7df73ac..ccc1a055 100644 --- a/openshift-storage-libs/openshiftstoragelibs/gluster_ops.py +++ b/openshift-storage-libs/openshiftstoragelibs/gluster_ops.py @@ -300,3 +300,38 @@ def match_heketi_and_gluster_volumes_by_prefix(heketi_volumes, prefix): "Difference: {}" .format(heketi_volumes, g_volumes, vol_difference)) assert not vol_difference, err_msg + + +@podcmd.GlustoPod() +def get_gluster_vol_free_inodes_with_hosts_of_bricks(vol_name): + """Get the inodes of gluster volume + + Args: + vol_name (str): Name of the gluster volume + Returns: + dict : Host ip mapped with dict of brick processes and free inodes + Example: + >>> get_gluster_vol_free_inodes_with_hosts_of_bricks('testvol') + { node_ip1:{ + 'brick_process1':'free_inodes', + 'brick_process2':'free_inodes'}, + node_ip2:{ + 'brick_process1':'free_inodes', + 'brick_process2':'free_inodes'}, + } + """ + hosts_with_inodes_info = dict() + + # Get the detailed status of volume + vol_status = get_gluster_vol_status(vol_name, is_detail=True) + + # Fetch the node ip, brick processes and free inodes from the status + for g_node, g_node_data in vol_status.items(): + for brick_process, process_data in g_node_data.items(): + if not brick_process.startswith("/var"): + continue + if g_node not in hosts_with_inodes_info: + hosts_with_inodes_info[g_node] = dict() + inodes_info = {brick_process: process_data["inodesFree"]} + hosts_with_inodes_info[g_node].update(inodes_info) + return hosts_with_inodes_info -- cgit