summaryrefslogtreecommitdiffstats
path: root/glustolibs-gluster/glustolibs/gluster/lib_utils.py
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-gluster/glustolibs/gluster/lib_utils.py
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-gluster/glustolibs/gluster/lib_utils.py')
-rw-r--r--glustolibs-gluster/glustolibs/gluster/lib_utils.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/lib_utils.py b/glustolibs-gluster/glustolibs/gluster/lib_utils.py
index e4459ee..dcfb297 100644
--- a/glustolibs-gluster/glustolibs/gluster/lib_utils.py
+++ b/glustolibs-gluster/glustolibs/gluster/lib_utils.py
@@ -940,3 +940,38 @@ def get_size_of_mountpoint(node, mount_point):
_, out, _ = g.run(node, cmd)
return out
+
+
+def add_user(host, uname):
+ """
+ Add user with default home directory
+ Args:
+ host (str): hostname/ip of the system
+ uname (str): username
+ Returns always True
+ """
+
+ command = "useradd -m %s -d /home/%s" % (uname, uname)
+ ret, _, err = g.run(host, command)
+ if 'already exists' in err:
+ g.log.warn("User %s is already exists", uname)
+ else:
+ g.log.info("User %s is created successfully", uname)
+ return True
+
+
+def del_user(host, uname):
+ """
+ Delete user with home directory
+ Args:
+ host (str): hostname/ip of the system
+ uname (str): username
+ Return always True
+ """
+ command = "userdel -r %s" % (uname)
+ ret, _, err = g.run(host, command)
+ if 'does not exist' in err:
+ g.log.warn("User %s is already deleted", uname)
+ else:
+ g.log.info("User %s successfully deleted", uname)
+ return True