From 9cc77baa3c96fa74afbb3807dd01525e28638934 Mon Sep 17 00:00:00 2001 From: Dhandapani Date: Thu, 7 Apr 2011 10:58:53 +0530 Subject: Volume re-export directory creation task in remote servers --- .../src/nodes/CreateVolumeExportDirectory.py | 51 ++++++++++++++++++++++ .../src/nodes/PeerAgent.py | 2 +- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/com.gluster.storage.management.server.scripts/src/nodes/CreateVolumeExportDirectory.py (limited to 'src/com.gluster.storage.management.server.scripts') 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. +# 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 +# . +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: -- cgit