diff options
| author | Tim <timothyasir@gluster.com> | 2011-07-31 16:17:13 +0530 |
|---|---|---|
| committer | Tim <timothyasir@gluster.com> | 2011-07-31 16:17:13 +0530 |
| commit | 466dd9e94ccc8283da84de69db4173c32949fbb6 (patch) | |
| tree | a71a942097acfbb6f45b59a79496ffca5a78c0ed /src/com.gluster.storage.management.server/WebContent/scripts/delete_user_cifs_all.py | |
| parent | cc38ca499f91b0e788eb992e0bfa438663aa9a31 (diff) | |
Added add_user_cifs_all.py, delete_user_cifs_all.py, grun.py
Removed Common.py. Functions from Common.py are moved to Utils.py
Updated Globals.py with web server url, gluster backend configuration folder
Diffstat (limited to 'src/com.gluster.storage.management.server/WebContent/scripts/delete_user_cifs_all.py')
| -rwxr-xr-x | src/com.gluster.storage.management.server/WebContent/scripts/delete_user_cifs_all.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/com.gluster.storage.management.server/WebContent/scripts/delete_user_cifs_all.py b/src/com.gluster.storage.management.server/WebContent/scripts/delete_user_cifs_all.py new file mode 100755 index 00000000..38dd8109 --- /dev/null +++ b/src/com.gluster.storage.management.server/WebContent/scripts/delete_user_cifs_all.py @@ -0,0 +1,53 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. <http://www.gluster.com> +# This file is part of Gluster Management Gateway. +# + +import os +import sys +import Utils + + +cifsUserFile = "/etc/glustermg/.users.cifs" + + +def removeUser(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 + + try: + fp = open(cifsUserFile, "w") + lines = content.strip().split() + for line in lines: + if line.split(":")[1] == userName: + continue + fp.write("%s\n" % line) + fp.close() + except IOError, e: + Utils.log("failed to write file %s: %s" % (cifsUserFile, str(e))) + return False + return True + + +def main(): + if len(sys.argv) < 3: + sys.stderr.write("usage: %s SERVER_LIST USERNAME\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + serverList = sys.argv[1] + userName = sys.argv[2] + + rv = Utils.runCommand("grun.py %s delete_user_cifs.py %s" % (serverList, userName)) + if rv == 0: + if not removeUser(userName): + sys.exit(10) + sys.exit(rv) + + +if __name__ == "__main__": + main() |
