diff options
| author | Bala.FA <bala@gluster.com> | 2011-08-05 12:54:14 +0530 |
|---|---|---|
| committer | Bala.FA <bala@gluster.com> | 2011-08-05 12:56:34 +0530 |
| commit | 5dd40b61a2349da5aa6bc9b9d31149e63d54b8e3 (patch) | |
| tree | b8a2667ead87785135494794e149edab86e729db /src/com.gluster.storage.management.gateway | |
| parent | 8f0fb2e6a8ab08b862b2292da145600a195aac6f (diff) | |
add_user_cifs_all.py and add_user_cifs.py support to ignore existing user on given server list. This enables password reset and adding user to newly added servers on existing storage clusters.
Signed-off-by: Bala.FA <bala@gluster.com>
Diffstat (limited to 'src/com.gluster.storage.management.gateway')
| -rwxr-xr-x | src/com.gluster.storage.management.gateway/WebContent/scripts/add_user_cifs_all.py | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/com.gluster.storage.management.gateway/WebContent/scripts/add_user_cifs_all.py b/src/com.gluster.storage.management.gateway/WebContent/scripts/add_user_cifs_all.py index 02855cd7..f1e899ec 100755 --- a/src/com.gluster.storage.management.gateway/WebContent/scripts/add_user_cifs_all.py +++ b/src/com.gluster.storage.management.gateway/WebContent/scripts/add_user_cifs_all.py @@ -18,6 +18,22 @@ defaultUid = 1024000 cifsUserFile = "/opt/glustermg/etc/users.cifs" +def getUid(userName): + try: + fp = open(cifsUserFile) + content = fp.read() + fp.close() + except IOError, e: + Utils.log("failed to read file %s: %s" % (cifsUserFile, str(e))) + return False + + for line in content.strip().split(): + tokens = line.split(":") + if tokens[1] == UserName: + return int(tokens[0]) + return None + + def getLastUid(): if not os.path.exists(cifsUserFile): return defaultUid @@ -55,13 +71,20 @@ def main(): userName = sys.argv[2] password = sys.argv[3] - uid = getLastUid() + existingUser = False + uid = getUid(userName) if not uid: - sys.exit(10) - - uid += 1 + uid = getLastUid() + if not uid: + sys.exit(10) + uid += 1 + else: + existingUser = True rv = Utils.runCommand("grun.py %s add_user_cifs.py %s %s %s" % (serverFile, uid, userName, password)) + if existingUser: + sys.exit(rv) + if rv == 0: if not setUid(uid, userName): sys.exit(11) |
