summaryrefslogtreecommitdiffstats
path: root/glustolibs-gluster
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2018-06-18 03:51:02 -0400
committerNigel Babu <nigelb@redhat.com>2018-06-21 05:18:52 +0000
commit26d7971f17a8c2965b7f3b9850b3998b34494af3 (patch)
tree224ada0f4ec8ace40a060cd0f7a57e2b61993b36 /glustolibs-gluster
parent144e2a1bfe80211fe02775da2386f57122001710 (diff)
Geo-rep: Creating group and user
Contains ops for restarting glusterd (used for slave nodes in non-root), adding a group as well as a user to set up a non-root geo-rep session Change-Id: Iec0990e86fbb5a92a70f26820d43529c21e1742f Signed-off-by: Kotresh HR <khiremat@redhat.com> Signed-off-by: rallan <rallan@redhat.com>
Diffstat (limited to 'glustolibs-gluster')
-rw-r--r--glustolibs-gluster/glustolibs/gluster/geo_rep_ops.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/geo_rep_ops.py b/glustolibs-gluster/glustolibs/gluster/geo_rep_ops.py
index 88ad8ae80..faf818746 100644
--- a/glustolibs-gluster/glustolibs/gluster/geo_rep_ops.py
+++ b/glustolibs-gluster/glustolibs/gluster/geo_rep_ops.py
@@ -65,6 +65,64 @@ def georep_createpem(mnode):
return g.run(mnode, cmd)
+def georep_groupadd(servers, groupname):
+ """ Creates a group in all the slave nodes where a user will be added
+ to set up a non-root session
+
+ Args:
+ servers (list): list of nodes on which cmd is to be executed
+ groupname (str): Specifies a groupname
+
+ Returns:
+ bool : True if add group is successful on all servers.
+ False otherwise.
+
+ """
+ cmd = "groupadd %s" % groupname
+ results = g.run_parallel(servers, cmd)
+
+ _rc = True
+ for server, ret_value in results.iteritems():
+ retcode, _, err = ret_value
+ if retcode != 0 and "already exists" not in err:
+ g.log.error("Unable to add group %s on server %s",
+ groupname, server)
+ _rc = False
+ if not _rc:
+ return False
+
+ return True
+
+
+def georep_geoaccount(servers, groupname, groupaccount):
+ """ Creates a user account with which the geo-rep session can be securely
+ set up
+
+ Args:
+ servers (list): list of nodes on which cmd is to be executed
+ groupname (str): Specifies a groupname
+ groupaccount (str): Specifies the user account to set up geo-rep
+
+ Returns:
+ bool : True if user add is successful on all servers.
+ False otherwise.
+
+ """
+ cmd = "useradd -G %s %s" % (groupname, groupaccount)
+ results = g.run_parallel(servers, cmd)
+
+ _rc = True
+ for server, ret_value in results.iteritems():
+ retcode, _, err = ret_value
+ if retcode != 0 and "already exists" not in err:
+ g.log.error("Unable to add user on %s", server)
+ _rc = False
+ if not _rc:
+ return False
+
+ return True
+
+
def georep_status(mnode, mastervol, slaveip, slavevol, user=None):
"""Shows the status of the geo-replication session
Args: