summaryrefslogtreecommitdiffstats
path: root/src/com.gluster.storage.management.gateway/WebContent/scripts/update_volume_cifs_all.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/com.gluster.storage.management.gateway/WebContent/scripts/update_volume_cifs_all.py')
-rwxr-xr-xsrc/com.gluster.storage.management.gateway/WebContent/scripts/update_volume_cifs_all.py69
1 files changed, 0 insertions, 69 deletions
diff --git a/src/com.gluster.storage.management.gateway/WebContent/scripts/update_volume_cifs_all.py b/src/com.gluster.storage.management.gateway/WebContent/scripts/update_volume_cifs_all.py
deleted file mode 100755
index c5c9d1ef..00000000
--- a/src/com.gluster.storage.management.gateway/WebContent/scripts/update_volume_cifs_all.py
+++ /dev/null
@@ -1,69 +0,0 @@
-#!/usr/bin/python
-# Copyright (C) 2011 Gluster, Inc. <http://www.gluster.com>
-# This file is part of Gluster Management Gateway.
-#
-
-import os
-import sys
-p1 = os.path.abspath(os.path.dirname(sys.argv[0]))
-p2 = "%s/common" % os.path.dirname(p1)
-if not p1 in sys.path:
- sys.path.append(p1)
-if not p2 in sys.path:
- sys.path.append(p2)
-import Globals
-import Utils
-
-
-def updateVolumeCifsConf(volumeName, userList):
- try:
- fp = open(Globals.CIFS_VOLUME_FILE)
- content = fp.read()
- fp.close()
- except IOError, e:
- Utils.log("failed to read file %s: %s" % (Globals.CIFS_VOLUME_FILE, str(e)))
- return False
-
- try:
- fp = open(Globals.CIFS_VOLUME_FILE, "w")
- for line in content.split():
- if line.split(":")[0] == volumeName:
- fp.write("%s:%s\n" % (volumeName, ":".join(userList)))
- else:
- fp.write("%s\n" % line)
- fp.close()
- except IOError, e:
- Utils.log("failed to write file %s: %s" % (Globals.CIFS_VOLUME_FILE, str(e)))
- return False
- return True
-
-
-def main():
- if len(sys.argv) < 4:
- sys.stderr.write("usage: %s SERVER_FILE VOLUME_NAME USER1 USER2 ...\n" % os.path.basename(sys.argv[0]))
- sys.exit(-1)
-
- serverFile = sys.argv[1]
- volumeName = sys.argv[2]
- userList = sys.argv[3:]
-
- missingUserList = []
- for userName in userList:
- if not Utils.getCifsUserUid(userName):
- missingUserList.append(userName)
-
- if missingUserList:
- sys.stderr.write("User %s does not exists\n" % missingUserList)
- sys.exit(1)
-
-
- rv = Utils.runCommand(["grun.py", serverFile, "update_volume_cifs.py", volumeName] + userList)
- if rv == 0:
- if not updateVolumeCifsConf(volumeName, userList):
- sys.stderr.write("Failed to update volume %s and user-list %s in cifs volume configuration\n" % (volumeName, userList))
- sys.exit(11)
- sys.exit(rv)
-
-
-if __name__ == "__main__":
- main()