diff options
| author | Shireesh Anjal <shireesh@gluster.com> | 2011-04-28 20:43:34 +0530 |
|---|---|---|
| committer | Shireesh Anjal <shireesh@gluster.com> | 2011-04-28 20:43:34 +0530 |
| commit | e6433daabe87fec1ae58273114b8862b82de4da2 (patch) | |
| tree | 2fef8ce385a6c92de0666bf8216d2527fa5e2d5b /src/com.gluster.storage.management.server.scripts | |
| parent | 636888037a6fced0753e0095b61edf5fde771a2a (diff) | |
| parent | 53267cf30fd175a48584de9402e121deadec008c (diff) | |
Merge branch 'master' of github.com:gluster/console
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() + |
