diff options
| author | Dhandapani <dhandapani@gluster.com> | 2011-04-07 10:58:53 +0530 |
|---|---|---|
| committer | Dhandapani <dhandapani@gluster.com> | 2011-04-07 10:58:53 +0530 |
| commit | 9cc77baa3c96fa74afbb3807dd01525e28638934 (patch) | |
| tree | 41fa1ccf522fa8a1b103ee0bdefc0014b621d2ab /src/com.gluster.storage.management.server.scripts | |
| parent | 5c39a47fdd3987bb5eee35f7f7397ce127c8919e (diff) | |
Volume re-export directory creation task in remote servers
Diffstat (limited to 'src/com.gluster.storage.management.server.scripts')
| -rw-r--r-- | src/com.gluster.storage.management.server.scripts/src/nodes/CreateVolumeExportDirectory.py | 51 | ||||
| -rwxr-xr-x | src/com.gluster.storage.management.server.scripts/src/nodes/PeerAgent.py | 2 |
2 files changed, 52 insertions, 1 deletions
diff --git a/src/com.gluster.storage.management.server.scripts/src/nodes/CreateVolumeExportDirectory.py b/src/com.gluster.storage.management.server.scripts/src/nodes/CreateVolumeExportDirectory.py new file mode 100644 index 00000000..611d9695 --- /dev/null +++ b/src/com.gluster.storage.management.server.scripts/src/nodes/CreateVolumeExportDirectory.py @@ -0,0 +1,51 @@ +#!/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 +from XmlHandler import ResponseXml +from optparse import OptionParser +import Utils + +def stripEmptyLines(content): + ret = "" + for line in content.split("\n"): + if line.strip() != "": + ret += line + return ret + +def createDirectory(disk, volumename): + dirname = "/export" + if not os.path.isdir(dirname) or not os.path.isdir(disk): + rs = ResponseXml() + rs.appendTagRoute("code", 1) + rs.appendTagRoute("message", "Disk is not mounted properly") + return rs.toprettyxml() + + + if not os.path.isdir(dirname + "/" + disk + "/" + volumename + "/"): + command = "mkdir " + volumename; + rv = Utils.runCommandFG(command, stdout=True, root=True) + message = stripEmptyLines(rv["Stdout"]) + if rv["Stderr"]: + message += "Error: [" + stripEmptyLines(rv["Stderr"]) + "]" + rs = ResponseXml() + rs.appendTagRoute("status.code", rv["Status"]) + rs.appendTagRoute("status.message", message) + return rs.toprettyxml() + +def main(disk, volumename): + return createDirectory(disk, volumename)
\ No newline at end of file diff --git a/src/com.gluster.storage.management.server.scripts/src/nodes/PeerAgent.py b/src/com.gluster.storage.management.server.scripts/src/nodes/PeerAgent.py index 93c1f002..909d24a3 100755 --- a/src/com.gluster.storage.management.server.scripts/src/nodes/PeerAgent.py +++ b/src/com.gluster.storage.management.server.scripts/src/nodes/PeerAgent.py @@ -77,7 +77,7 @@ def executeCommand(command): rs = ResponseXml() rs.appendTagRoute("status", statusCode); rs.appendTagRoute("output", stripEmptyLines(rv["Stdout"])) - rs.appendTagRoute("error", stripEmptyLines(rv["Stderr"])) + rs.appendTagRoute("message", stripEmptyLines(rv["Stderr"])) print rs.toprettyxml() return rs.toprettyxml() else: |
