diff options
| author | Tim <timothyasir@gluster.com> | 2011-04-11 16:06:45 +0530 |
|---|---|---|
| committer | Tim <timothyasir@gluster.com> | 2011-04-11 16:06:45 +0530 |
| commit | 5cf991b09c3a04c2d98a2e3e60c6d2797f306038 (patch) | |
| tree | 245d7b7e2c3c7ffaf02a739b51121f3c6f619d46 /src/com.gluster.storage.management.server.scripts | |
| parent | 89211e6eb5996e1f18493d2a48696171b3693811 (diff) | |
Added clear volume directory function and bug fixed.
Added clear_volume_directory.py file
fixed invalid syntax error in create_volume_directory.py file
Renamed CreateVolumeExportDirectory.py into create_volume_directory.py
Diffstat (limited to 'src/com.gluster.storage.management.server.scripts')
| -rwxr-xr-x | src/com.gluster.storage.management.server.scripts/src/nodes/clear_volume_directory.py | 69 | ||||
| -rwxr-xr-x | src/com.gluster.storage.management.server.scripts/src/nodes/create_volume_directory.py (renamed from src/com.gluster.storage.management.server.scripts/src/nodes/CreateVolumeExportDirectory.py) | 2 |
2 files changed, 70 insertions, 1 deletions
diff --git a/src/com.gluster.storage.management.server.scripts/src/nodes/clear_volume_directory.py b/src/com.gluster.storage.management.server.scripts/src/nodes/clear_volume_directory.py new file mode 100755 index 00000000..e9f3ab43 --- /dev/null +++ b/src/com.gluster.storage.management.server.scripts/src/nodes/clear_volume_directory.py @@ -0,0 +1,69 @@ +#!/usr/bin/python +# Copyright (C) 2010 Gluster, Inc. <http://www.gluster.com> +# This file is part of Gluster Storage Platform. +# +# 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 +import syslog +from XmlHandler import ResponseXml +import DiskUtils +import Utils +import Common + +def clearVolumeDirectory(disk, volumeName): + + # Retrieving disk uuid + diskUuid = DiskUtils.getUuidByDiskPartition(DiskUtils.getDevice(disk)) + + rs = ResponseXml() + if not diskUuid: + Common.log(syslog.LOG_ERR, "failed to find disk:%s uuid" % disk) + rs.appendTagRoute("status.code", "-1") + rs.appendTagRoute("status.message", "Error: Unable to find disk uuid") + return rs.toprettyxml() + + # Retrieving disk mount point using disk uuid + diskMountPoint = DiskUtils.getMountPointByUuid(diskUuid) + if not os.path.exists(diskMountPoint): + Common.log(syslog.LOG_ERR, "failed to retrieve disk:%s mount point" % disk) + rs.appendTagRoute("status.code", "-1") + rs.appendTagRoute("status.message", "Error: Failed to retrieve disk details") + return rs.toprettyxml() + + # clear volume directory from the disk + volumeDirectory = "%s/%s" % (diskMountPoint, volumeName) + command = ["sudo", "rm", "-fr", volumeDirectory] + rv = Utils.runCommandFG(command, stdout=True, root=True) + message = Common.stripEmptyLines(rv["Stdout"]) + if rv["Stderr"]: + error = Common.stripEmptyLines(rv["Stderr"]) + message += "Error: [%s]" % (error) + Common.log(syslog.LOG_ERR, "failed to clear volume directory %s, %s" % (volumeDirectory, error)) + rs.appendTagRoute("status.code", rv["Status"]) + rs.appendTagRoute("status.message", message) + return rs.toprettyxml() + +def main(): + if len(sys.argv) != 3: + print >> sys.stderr, "usage: %s <disk name> <volume name>" % sys.argv[0] + sys.exit(-1) + + disk = sys.argv[1] + volumeName = sys.argv[2] + print clearVolumeDirectory(disk, volumeName) + sys.exit(0) + +main() diff --git a/src/com.gluster.storage.management.server.scripts/src/nodes/CreateVolumeExportDirectory.py b/src/com.gluster.storage.management.server.scripts/src/nodes/create_volume_directory.py index 59dc3c19..1b994ab3 100755 --- a/src/com.gluster.storage.management.server.scripts/src/nodes/CreateVolumeExportDirectory.py +++ b/src/com.gluster.storage.management.server.scripts/src/nodes/create_volume_directory.py @@ -52,7 +52,7 @@ def createDirectory(disk, volumeName): if rv["Stderr"]: error = Common.stripEmptyLines(rv["Stderr"]) message += "Error: [%s]" % (error) - Common.log(syslog.LOG_ERR, "failed to create volume directory %s, %s" % (volumeDirectory, error) + Common.log(syslog.LOG_ERR, "failed to create volume directory %s, %s" % (volumeDirectory, error)) rs.appendTagRoute("status.code", rv["Status"]) rs.appendTagRoute("status.message", message) return rs.toprettyxml() |
