summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTim <timothyasir@gluster.com>2011-08-17 17:13:48 +0530
committerTim <timothyasir@gluster.com>2011-08-17 17:13:48 +0530
commita89c4c7d98e41a26431252523b1894a64e598f9b (patch)
treea33f0c1b9992317356d32485b1faad04c5ca3ce8 /src
parent9cebf97c654e3020a5f960ba0eae37379a1909e1 (diff)
Enhanced error handling and added license information to create_volume_directory.py
Diffstat (limited to 'src')
-rwxr-xr-xsrc/com.gluster.storage.management.gateway.scripts/src/backend/create_volume_directory.py46
1 files changed, 12 insertions, 34 deletions
diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/create_volume_directory.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/create_volume_directory.py
index e295f249..66354412 100755
--- a/src/com.gluster.storage.management.gateway.scripts/src/backend/create_volume_directory.py
+++ b/src/com.gluster.storage.management.gateway.scripts/src/backend/create_volume_directory.py
@@ -1,20 +1,8 @@
#!/usr/bin/python
-# Copyright (C) 2010 Gluster, Inc. <http://www.gluster.com>
-# This file is part of Gluster Storage Platform.
+# Copyright (C) 2011 Gluster, Inc. <http://www.gluster.com>
+# This file is part of Gluster Management Gateway.
#
-# Gluster Storage Platform is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 3 of
-# the License, or (at your option) any later version.
-#
-# Gluster Storage Platform is distributed in the hope that it will be
-# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
-# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see
-# <http://www.gnu.org/licenses/>.
+
import os
import sys
p1 = os.path.abspath(os.path.dirname(sys.argv[0]))
@@ -35,7 +23,7 @@ def createDirectory(disk, volumeName):
if not diskUuid:
Utils.log("failed to find disk:%s uuid" % disk)
rs.appendTagRoute("status.code", "-1")
- rs.appendTagRoute("status.message", "Error: Unable to find disk uuid")
+ rs.appendTagRoute("status.message", "Error: Failed to find disk uuid")
return rs.toprettyxml()
# Retrieving disk mount point using disk uuid
@@ -53,27 +41,17 @@ def createDirectory(disk, volumeName):
rs.appendTagRoute("status.code", "-2")
rs.appendTagRoute("status.message", "Volume directory already exists!")
return rs.toprettyxml()
-
- if not os.path.exists(volumeDirectory):
- command = ["sudo", "mkdir", volumeDirectory]
- rv = Utils.runCommandFG(command, stdout=True, root=True)
- message = Utils.stripEmptyLines(rv["Stdout"])
- if rv["Stderr"]:
- error = Utils.stripEmptyLines(rv["Stderr"])
- message += "Error: [%s]" % (error)
- Utils.log("failed to create volume directory %s, %s" % (volumeDirectory, error))
- rs.appendTagRoute("status.code", rv["Status"])
- rs.appendTagRoute("status.message", message)
- return rs.toprettyxml()
-
- if not rv["Status"]:
- rv["Status"] = "0"
- if rv["Status"] == "0":
- message = volumeDirectory
+
+ rv = Utils.runCommand("mkdir %s" % volumeDirectory, output=True, root=True)
+ if rv["Status"] != 0:
rs.appendTagRoute("status.code", rv["Status"])
- rs.appendTagRoute("status.message", message)
+ rs.appendTagRoute("status.message", "Failed to create volume directory")
return rs.toprettyxml()
+ rs.appendTagRoute("status.code", rv["Status"])
+ rs.appendTagRoute("status.message", volumeDirectory)
+ return rs.toprettyxml()
+
def main():
if len(sys.argv) != 3:
sys.stderr.write("usage: %s <disk name> <volume name>\n" % os.path.basename(sys.argv[0]))