summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArun Kumar <aanand01762@gmail.com>2020-06-24 22:06:19 +0530
committerVaibhav Mahajan <vamahaja@redhat.com>2020-07-06 10:01:13 +0000
commiteeb68e474a16c73798f8db916aa83af97ead4094 (patch)
treeb01e500d2b072f943b0bc6b9e5a351627285d09a
parent83b129f2a9a60ca4ee485ac87da6eca4540d695a (diff)
[Lib] Add library to get the free inodes of bricks
Change-Id: I4ef9114a30dfd6fe18c4ba15b0cbbd32b8fc44f3 Signed-off-by: Arun Kumar <aanand01762@gmail.com>
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/gluster_ops.py35
1 files changed, 35 insertions, 0 deletions
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