summaryrefslogtreecommitdiffstats
path: root/src/com.gluster.storage.management.gateway/WebContent/scripts
diff options
context:
space:
mode:
authorTim <timothyasir@gluster.com>2011-08-09 17:32:29 +0530
committerTim <timothyasir@gluster.com>2011-08-09 17:32:29 +0530
commit4d5151cceea8d9c1472d235994c2938687f3c869 (patch)
tree48d13e09d8e74c56262a0dfb477fc5afe8480aea /src/com.gluster.storage.management.gateway/WebContent/scripts
parent98bd352e70af80f103e4b2f00848bb612bc72504 (diff)
Enhanced error handling and written appropriate execution error into stderr.
Diffstat (limited to 'src/com.gluster.storage.management.gateway/WebContent/scripts')
-rw-r--r--src/com.gluster.storage.management.gateway/WebContent/scripts/Utils.py2
-rwxr-xr-xsrc/com.gluster.storage.management.gateway/WebContent/scripts/add_user_cifs_all.py1
-rwxr-xr-xsrc/com.gluster.storage.management.gateway/WebContent/scripts/create_volume_cifs_all.py1
-rwxr-xr-xsrc/com.gluster.storage.management.gateway/WebContent/scripts/delete_user_cifs_all.py1
-rwxr-xr-xsrc/com.gluster.storage.management.gateway/WebContent/scripts/delete_volume_cifs_all.py1
-rwxr-xr-xsrc/com.gluster.storage.management.gateway/WebContent/scripts/get_volume_user_cifs.py1
-rwxr-xr-xsrc/com.gluster.storage.management.gateway/WebContent/scripts/grun.py8
-rwxr-xr-xsrc/com.gluster.storage.management.gateway/WebContent/scripts/setup_cifs_config_all.py7
-rwxr-xr-xsrc/com.gluster.storage.management.gateway/WebContent/scripts/update_volume_cifs_all.py1
9 files changed, 18 insertions, 5 deletions
diff --git a/src/com.gluster.storage.management.gateway/WebContent/scripts/Utils.py b/src/com.gluster.storage.management.gateway/WebContent/scripts/Utils.py
index 82f8b7b6..bcc6f177 100644
--- a/src/com.gluster.storage.management.gateway/WebContent/scripts/Utils.py
+++ b/src/com.gluster.storage.management.gateway/WebContent/scripts/Utils.py
@@ -1059,6 +1059,8 @@ def log(priority, message=None):
def stripEmptyLines(content):
+ if not content:
+ return ""
ret = ""
for line in content.split("\n"):
if line.strip() != "":
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 f1e899ec..b9fcaf6d 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
@@ -87,6 +87,7 @@ def main():
if rv == 0:
if not setUid(uid, userName):
+ sys.stderr.write("Failed to update user uid\n")
sys.exit(11)
sys.exit(rv)
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
index 80b6da7c..b327580c 100755
--- 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
@@ -51,6 +51,7 @@ def main():
rv = Utils.runCommand(["grun.py", serverFile, "create_volume_cifs.py", volumeName] + userList)
if rv == 0:
if not addVolumeCifsConf(volumeName, userList):
+ sys.stderr.write("Unable to update volume cifs configuration\n")
sys.exit(11)
sys.exit(rv)
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 d414fc2c..a6bf15dc 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
@@ -51,6 +51,7 @@ def main():
rv = Utils.runCommand("grun.py %s delete_user_cifs.py %s" % (serverList, userName))
if rv == 0:
if not removeUser(userName):
+ sys.stderr.write("Failed to remove user\n")
sys.exit(10)
sys.exit(rv)
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
index b41e3d65..2e2b8db3 100755
--- 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
@@ -49,6 +49,7 @@ def main():
rv = Utils.runCommand(["grun.py", serverFile, "delete_volume_cifs.py", volumeName])
if rv == 0:
if not removeVolumeCifsConf(volumeName):
+ sys.stderr.write("Failed to remove volume cifs config file\n")
sys.exit(11)
sys.exit(rv)
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
index 55821b60..33de3bf1 100755
--- 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
@@ -40,6 +40,7 @@ def main():
sys.exit(0)
except IOError, e:
Utils.log("failed to read file %s: %s" % (cifsVolumeFile, str(e)))
+ sys.stderr.write("Failed to read cifs-volume-file %s: %s\n" % (cifsVolumeFile, str(e)))
sys.exit(2)
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 e09ef5bc..cc00f466 100755
--- a/src/com.gluster.storage.management.gateway/WebContent/scripts/grun.py
+++ b/src/com.gluster.storage.management.gateway/WebContent/scripts/grun.py
@@ -33,13 +33,15 @@ def main():
fp.close()
except IOError, e:
Utils.log("Failed to read server file %s: %s\n" % (serverFile, str(e)))
+ sys.stderr.write("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 "%s: %s" % (serverName, rv)
- if rv != 0:
+ rv = Utils.runCommand(sshCommandPrefix + [serverName.strip()] + command, output=True)
+ if rv["Status"] != 0:
+ sys.stderr.write("%s: %s\nStdout:\n%s\nStderr:%s\n---\n" \
+ % (serverName, rv["Status"], rv["Stdout"], rv["Stderr"]))
status = False
if status:
diff --git a/src/com.gluster.storage.management.gateway/WebContent/scripts/setup_cifs_config_all.py b/src/com.gluster.storage.management.gateway/WebContent/scripts/setup_cifs_config_all.py
index 8dd59c8c..657f05f7 100755
--- a/src/com.gluster.storage.management.gateway/WebContent/scripts/setup_cifs_config_all.py
+++ b/src/com.gluster.storage.management.gateway/WebContent/scripts/setup_cifs_config_all.py
@@ -21,8 +21,11 @@ def main():
serverFile = sys.argv[1]
- rv = Utils.runCommand(["grun.py", serverFile, "setup_cifs_config.py"])
- sys.exit(rv)
+ rv = Utils.runCommand(["grun.py", serverFile, "setup_cifs_config.py"], output=True)
+ if status["Status"] != 0:
+ sys.stderr.write("%s %s\n" % (Utils.stripEmptyLines(rv["Stderr"]), Utils.stripEmptyLines(rv["Stdout"])))
+ sys.exit(-1)
+ sys.exit(0)
if __name__ == "__main__":
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
index a4d424b3..e2ea9ac2 100755
--- 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
@@ -52,6 +52,7 @@ def main():
rv = Utils.runCommand(["grun.py", serverFile, "update_volume_cifs.py", volumeName] + userList)
if rv == 0:
if not updateVolumeCifsConf(volumeName, userList):
+ sys.stderr.write("Unable to update volume cifs configuration\n")
sys.exit(11)
sys.exit(rv)