summaryrefslogtreecommitdiffstats
path: root/glustolibs-io
diff options
context:
space:
mode:
authorMohit Agrawal <moagrawa@redhat.com>2018-06-27 11:22:27 +0530
committerAkarsha Rai <akrai@redhat.com>2018-06-29 10:37:42 +0000
commit7a6946dcfebddc983df9f154907f832d6c3adf81 (patch)
tree817ade600d01b7ab63868fd38e0f235c32cb91eb /glustolibs-io
parent4a858035af54d9d69ad7dd901ab1d51d59341caf (diff)
Adding test case for change owner, group, permission for directory
1) Create Dir with some file inside dir 2) Verify dir exists on all bricks as well as mount point 3) Compare dir stat with mount-point and brick location path 4) Change the ownership of directory 5) Compare dir stats with mount-point and brick path 6) Try to change pemission with different user for directory 7) Compare dir stat with mount-point and brick path 8) Try to change permission with different user for directory 9) change permission of directory 10) Compare dir stat with mount-point and brick path 11) Try to change permission with different user for same directory Change-Id: I284842be8c7562d4618d4e69e202c4d80945f1c5 Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
Diffstat (limited to 'glustolibs-io')
-rw-r--r--glustolibs-io/glustolibs/io/utils.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/glustolibs-io/glustolibs/io/utils.py b/glustolibs-io/glustolibs/io/utils.py
index 6f9f642..0f68113 100644
--- a/glustolibs-io/glustolibs/io/utils.py
+++ b/glustolibs-io/glustolibs/io/utils.py
@@ -629,3 +629,45 @@ def is_io_procs_fail_with_rofs(self, all_mounts_procs, mounts):
ret = all(io_results.values())
return ret, io_results
+
+
+def compare_dir_structure_mount_with_brick(mnthost, mntloc, brick_list, type):
+ """ Compare directory structure from mount point with brick path along
+ with stat parameter
+
+ Args:
+ mnthost (str): hostname or ip of mnt system
+ mntloc (str) : mount location of gluster file system
+ brick_list (list) : list of all brick ip's with brick path
+ type (int) : 0 represent user permission
+ : 1 represent group permission
+ : 2 represent access permission
+ Returns:
+ True if directory structure are same
+ False if structure is not same
+ """
+
+ statformat = ''
+ if type == 0:
+ statformat = '%U'
+ if type == 1:
+ statformat = '%G'
+ if type == 2:
+ statformat = '%A'
+
+ command = ("find %s -mindepth 1 -type d | xargs -r stat -c '%s'"
+ % (mntloc, statformat))
+ rcode, rout, _ = g.run(mnthost, command)
+ all_dir_mnt_perm = rout.strip().split('\n')
+
+ for brick in brick_list:
+ brick_node, brick_path = brick.split(":")
+ command = ("find %s -mindepth 1 -type d | grep -ve \".glusterfs\" | "
+ "xargs -r stat -c '%s'" % (brick_path, statformat))
+ rcode, rout, _ = g.run(brick_node, command)
+ all_brick_dir_perm = rout.strip().split('\n')
+ retval = cmp(all_dir_mnt_perm, all_brick_dir_perm)
+ if retval != 0:
+ return False
+
+ return True