summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBala.FA <bala@gluster.com>2011-08-04 16:23:51 +0530
committerBala.FA <bala@gluster.com>2011-08-04 17:28:24 +0530
commita959e24bab6bc6ded12f4e3920cc1000ec69c923 (patch)
tree62fb7449f290319a6e5275aba7e460094526341e /src
parent7055799dde7237db01d9e168d4ba93d89fdcd1e9 (diff)
Added create_volume_cifs_all.py, delete_volume_cifs_all.py and get_volume_user_cifs.py used to do cifs volume operations.
Signed-off-by: Bala.FA <bala@gluster.com>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/com.gluster.storage.management.gateway/WebContent/scripts/add_user_cifs_all.py2
-rwxr-xr-xsrc/com.gluster.storage.management.gateway/WebContent/scripts/create_volume_cifs_all.py59
-rwxr-xr-xsrc/com.gluster.storage.management.gateway/WebContent/scripts/delete_user_cifs_all.py2
-rwxr-xr-xsrc/com.gluster.storage.management.gateway/WebContent/scripts/delete_volume_cifs_all.py57
-rwxr-xr-xsrc/com.gluster.storage.management.gateway/WebContent/scripts/get_volume_user_cifs.py43
-rwxr-xr-xsrc/com.gluster.storage.management.gateway/WebContent/scripts/grun.py12
6 files changed, 170 insertions, 5 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 fd952cff..02855cd7 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
@@ -15,7 +15,7 @@ import Utils
defaultUid = 1024000
-cifsUserFile = "/etc/glustermg/.users.cifs"
+cifsUserFile = "/opt/glustermg/etc/users.cifs"
def getLastUid():
diff --git a/src/com.gluster.storage.management.gateway/WebContent/scripts/create_volume_cifs_all.py b/src/com.gluster.storage.management.gateway/WebContent/scripts/create_volume_cifs_all.py
new file mode 100755
index 00000000..80b6da7c
--- /dev/null
+++ b/src/com.gluster.storage.management.gateway/WebContent/scripts/create_volume_cifs_all.py
@@ -0,0 +1,59 @@
+#!/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 Utils
+
+
+cifsVolumeFile = "/opt/glustermg/etc/volumes.cifs"
+
+
+def addVolumeCifsConf(volumeName, userList):
+ try:
+ fp = open(cifsVolumeFile)
+ content = fp.read()
+ fp.close()
+ except IOError, e:
+ Utils.log("failed to read file %s: %s" % (cifsVolumeFile, str(e)))
+ content = ""
+
+ try:
+ fp = open(cifsVolumeFile, "w")
+ for line in content.split():
+ if line.split(":")[0] != volumeName:
+ fp.write("%s\n" % line)
+ fp.write("%s:%s\n" % (volumeName, ":".join(userList)))
+ fp.close()
+ except IOError, e:
+ Utils.log("failed to write file %s: %s" % (cifsVolumeFile, 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:]
+
+ rv = Utils.runCommand(["grun.py", serverFile, "create_volume_cifs.py", volumeName] + userList)
+ if rv == 0:
+ if not addVolumeCifsConf(volumeName, userList):
+ sys.exit(11)
+ sys.exit(rv)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/src/com.gluster.storage.management.gateway/WebContent/scripts/delete_user_cifs_all.py b/src/com.gluster.storage.management.gateway/WebContent/scripts/delete_user_cifs_all.py
index ad8ce46c..d414fc2c 100755
--- a/src/com.gluster.storage.management.gateway/WebContent/scripts/delete_user_cifs_all.py
+++ b/src/com.gluster.storage.management.gateway/WebContent/scripts/delete_user_cifs_all.py
@@ -14,7 +14,7 @@ if not p2 in sys.path:
import Utils
-cifsUserFile = "/etc/glustermg/.users.cifs"
+cifsUserFile = "/opt/glustermg/etc/users.cifs"
def removeUser(userName):
diff --git a/src/com.gluster.storage.management.gateway/WebContent/scripts/delete_volume_cifs_all.py b/src/com.gluster.storage.management.gateway/WebContent/scripts/delete_volume_cifs_all.py
new file mode 100755
index 00000000..b41e3d65
--- /dev/null
+++ b/src/com.gluster.storage.management.gateway/WebContent/scripts/delete_volume_cifs_all.py
@@ -0,0 +1,57 @@
+#!/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 Utils
+
+
+cifsVolumeFile = "/opt/glustermg/etc/volumes.cifs"
+
+
+def removeVolumeCifsConf(volumeName):
+ try:
+ fp = open(cifsVolumeFile)
+ content = fp.read()
+ fp.close()
+ except IOError, e:
+ Utils.log("failed to read file %s: %s" % (cifsVolumeFile, str(e)))
+ content = ""
+
+ try:
+ fp = open(cifsVolumeFile, "w")
+ for line in content.split():
+ if line.split(":")[0] != volumeName:
+ fp.write("%s\n" % line)
+ fp.close()
+ except IOError, e:
+ Utils.log("failed to write file %s: %s" % (cifsVolumeFile, str(e)))
+ return False
+ return True
+
+
+def main():
+ if len(sys.argv) < 3:
+ sys.stderr.write("usage: %s SERVER_FILE VOLUME_NAME\n" % os.path.basename(sys.argv[0]))
+ sys.exit(-1)
+
+ serverFile = sys.argv[1]
+ volumeName = sys.argv[2]
+
+ rv = Utils.runCommand(["grun.py", serverFile, "delete_volume_cifs.py", volumeName])
+ if rv == 0:
+ if not removeVolumeCifsConf(volumeName):
+ sys.exit(11)
+ sys.exit(rv)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/src/com.gluster.storage.management.gateway/WebContent/scripts/get_volume_user_cifs.py b/src/com.gluster.storage.management.gateway/WebContent/scripts/get_volume_user_cifs.py
new file mode 100755
index 00000000..0593257b
--- /dev/null
+++ b/src/com.gluster.storage.management.gateway/WebContent/scripts/get_volume_user_cifs.py
@@ -0,0 +1,43 @@
+#!/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 Utils
+
+
+cifsVolumeFile = "/opt/glustermg/etc/volumes.cifs"
+
+
+def main():
+ if len(sys.argv) < 2:
+ sys.stderr.write("usage: %s VOLUME_NAME\n" % os.path.basename(sys.argv[0]))
+ sys.exit(-1)
+
+ volumeName = sys.argv[2]
+
+ try:
+ fp = open(cifsVolumeFile)
+ content = fp.read()
+ fp.close()
+ for line in content.split():
+ tokens = line.split(":")
+ if tokens[0] == volumeName:
+ print "\n".join(tokens[1:])
+ sys.exit(0)
+ sys.exit(1)
+ except IOError, e:
+ Utils.log("failed to read file %s: %s" % (cifsVolumeFile, str(e)))
+ sys.exit(2)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/src/com.gluster.storage.management.gateway/WebContent/scripts/grun.py b/src/com.gluster.storage.management.gateway/WebContent/scripts/grun.py
index 459265ce..f5ef1568 100755
--- a/src/com.gluster.storage.management.gateway/WebContent/scripts/grun.py
+++ b/src/com.gluster.storage.management.gateway/WebContent/scripts/grun.py
@@ -35,11 +35,17 @@ def main():
Utils.log("Failed to read server file %s: %s\n" % (serverFile, str(e)))
sys.exit(1)
+ status = True
for serverName in serverNameList:
rv = Utils.runCommand(sshCommandPrefix + [serverName.strip()] + command)
- print rv
-
- sys.exit(0)
+ print "%s: %s" % (serverName, rv)
+ if rv != 0:
+ status = False
+
+ if status:
+ sys.exit(0)
+ else:
+ sys.exit(2)
if __name__ == "__main__":