diff options
| author | Tim <timothyasir@gluster.com> | 2011-04-28 14:08:22 +0530 |
|---|---|---|
| committer | Tim <timothyasir@gluster.com> | 2011-04-28 14:08:22 +0530 |
| commit | 1500ca7e13074b2bc394ac4feb73e596d1203283 (patch) | |
| tree | daa526804f0fab4ad01191c944926102d61b64b7 /src/com.gluster.storage.management.server.scripts | |
| parent | e201155bb0e6b34c3974ff66f0911081dbbb355b (diff) | |
Added function to get disk name by the given directory path
Renamed get-disk-mount-point.py into get_disk_mount_point.py
Diffstat (limited to 'src/com.gluster.storage.management.server.scripts')
| -rwxr-xr-x | src/com.gluster.storage.management.server.scripts/src/nodes/get_disk_mount_point.py (renamed from src/com.gluster.storage.management.server.scripts/src/nodes/get-disk-mount-point.py) | 0 | ||||
| -rwxr-xr-x | src/com.gluster.storage.management.server.scripts/src/nodes/get_disk_name_by_path.py | 69 |
2 files changed, 69 insertions, 0 deletions
diff --git a/src/com.gluster.storage.management.server.scripts/src/nodes/get-disk-mount-point.py b/src/com.gluster.storage.management.server.scripts/src/nodes/get_disk_mount_point.py index b2274b4d..b2274b4d 100755 --- a/src/com.gluster.storage.management.server.scripts/src/nodes/get-disk-mount-point.py +++ b/src/com.gluster.storage.management.server.scripts/src/nodes/get_disk_mount_point.py diff --git a/src/com.gluster.storage.management.server.scripts/src/nodes/get_disk_name_by_path.py b/src/com.gluster.storage.management.server.scripts/src/nodes/get_disk_name_by_path.py new file mode 100755 index 00000000..72eb80dd --- /dev/null +++ b/src/com.gluster.storage.management.server.scripts/src/nodes/get_disk_name_by_path.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 syslog +import Common +from DiskUtils import * +from XmlHandler import ResponseXml + + +def getmountpoint(path): + if not path: + Common.log(syslog.LOG_ERR, "Not a valid path:%s" % path) + rs.appendTagRoute("status.code", "-1") + rs.appendTagRoute("status.message", "Error: given path name is empty") + return rs.toprettyxml() + + rs = ResponseXml() + mountPoint = None + fsTabEntry = None + for line in readFsTab(): + if path.startswith(line['MountPoint']): + if not mountPoint: + mountPoint = line['MountPoint'] + fsTabEntry = line + if len(line['MountPoint']) > len(mountPoint): + mountPoint = line['MountPoint'] + fsTabEntry = line + + if "/" == mountPoint or not mountPoint: + Common.log(syslog.LOG_ERR, "failed to find mount point of the given path:%s" % path) + rs.appendTagRoute("status.code", "-1") + rs.appendTagRoute("status.message", "Error: Unable to find disk mount point") + return rs.toprettyxml() + + rs.appendTagRoute("status.code", "0") + if fsTabEntry["Device"].startswith("UUID="): + rs.appendTagRoute("status.message", getDiskPartitionByUuid(fsTabEntry["Device"].split("UUID=")[-1])) + else: + rs.appendTagRoute("status.message", "Unable to find disk name") + return rs.toprettyxml() + +def main(): + if len(sys.argv) != 2: + print >> sys.stderr, "usage: %s <path>" % sys.argv[0] + sys.exit(-1) + + path = sys.argv[1] + print getmountpoint(path) + sys.exit(0) + +if __name__ == "__main__": + main() + |
