From 9917bb904e6e8e392b4857e73320e834854d16b8 Mon Sep 17 00:00:00 2001 From: Kotresh HR Date: Wed, 20 Jun 2018 14:12:22 -0400 Subject: geo-rep: Set passwd for the given user The API to set passwd for the given user and group in all the slave nodes. Change-Id: I69dc150c598c9101be825f159f037f4ad43706ed Signed-off-by: Kotresh HR --- .../glustolibs/gluster/geo_rep_ops.py | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/glustolibs-gluster/glustolibs/gluster/geo_rep_ops.py b/glustolibs-gluster/glustolibs/gluster/geo_rep_ops.py index e87090d0f..3e9978be2 100644 --- a/glustolibs-gluster/glustolibs/gluster/geo_rep_ops.py +++ b/glustolibs-gluster/glustolibs/gluster/geo_rep_ops.py @@ -123,6 +123,37 @@ def georep_geoaccount(servers, groupname, groupaccount): return True +def georep_geoaccount_setpasswd(servers, groupname, groupaccount, passwd): + """ 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 + passwd (str): Specifies password for they groupaccount + + Returns: + bool : True if password set is successful on all servers. + False otherwise. + + """ + cmd = "echo %s:%s | chpasswd" % (groupaccount, passwd) + results = g.run_parallel(servers, cmd) + + _rc = True + for server, ret_value in results.iteritems(): + retcode, _, err = ret_value + if retcode != 0: + g.log.error("Unable to set passwd for user %s on %s", + groupaccount, server) + _rc = False + if not _rc: + return False + + return True + + def georep_mountbroker_setup(mnode, groupname, directory): """ Sets up mountbroker root directory and group -- cgit