From 6dbbf73befc14da2a794e7233c357691b5f5e982 Mon Sep 17 00:00:00 2001 From: "Bala.FA" Date: Wed, 3 Aug 2011 14:56:32 +0530 Subject: Fixed - Bug 3300 - Format_device.py is not working. Added current and previous/common directories in sys.path. Flipped DOS to Unix file format in all python scripts. Signed-off-by: Bala.FA --- .../src/Common.py | 40 +- .../src/GetServerNetworkConfig.py | 7 + .../src/NetworkUtils.py | 7 + .../src/Utils.py | 8 +- .../src/XmlHandler.py | 692 ++++++++++----------- .../src/add_user_cifs.py | 6 + .../src/clear_volume_directory.py | 6 + .../src/create_volume_cifs.py | 6 + .../src/create_volume_directory.py | 6 + .../src/delete_user_cifs.py | 6 + .../src/delete_volume_cifs.py | 6 + .../src/format_device.py | 12 +- .../src/get_brick_status.py | 6 + .../src/get_format_device_status.py | 6 + .../src/get_rrd_cpu_details.py | 6 + .../src/get_rrd_memory_details.py | 6 + .../src/get_rrd_net_details.py | 6 + .../src/get_server_details.py | 7 + .../src/get_server_status.py | 6 + .../src/get_volume_brick_log.py | 6 + .../src/get_volume_log.py | 9 +- .../src/gluster_provision_block_wrapper.py | 6 + .../src/modify_volume_cifs.py | 6 + .../src/rrd_update_cpu_details.py | 6 + .../src/rrd_update_memory_details.py | 6 + .../src/setup_cifs_config.py | 6 + .../src/start_volume_cifs.py | 6 + .../src/stop_volume_cifs.py | 6 + 28 files changed, 531 insertions(+), 371 deletions(-) (limited to 'src/com.gluster.storage.management.gateway.scripts') diff --git a/src/com.gluster.storage.management.gateway.scripts/src/Common.py b/src/com.gluster.storage.management.gateway.scripts/src/Common.py index c85e9a2b..70b2157a 100644 --- a/src/com.gluster.storage.management.gateway.scripts/src/Common.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/Common.py @@ -1,20 +1,20 @@ -# Copyright (c) 2009 Gluster, Inc. -# This file is part of GlusterSP. -# -# GlusterSP 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. -# -# GlusterSP 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 sys -import syslog - +# Copyright (c) 2009 Gluster, Inc. +# This file is part of GlusterSP. +# +# GlusterSP 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. +# +# GlusterSP 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 sys +import syslog + diff --git a/src/com.gluster.storage.management.gateway.scripts/src/GetServerNetworkConfig.py b/src/com.gluster.storage.management.gateway.scripts/src/GetServerNetworkConfig.py index 3311eb56..54f68caf 100644 --- a/src/com.gluster.storage.management.gateway.scripts/src/GetServerNetworkConfig.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/GetServerNetworkConfig.py @@ -15,7 +15,14 @@ # along with this program. If not, see # . +import os import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) import syslog import Globals import Commands diff --git a/src/com.gluster.storage.management.gateway.scripts/src/NetworkUtils.py b/src/com.gluster.storage.management.gateway.scripts/src/NetworkUtils.py index 42e9892c..9f5687e4 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/NetworkUtils.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/NetworkUtils.py @@ -15,7 +15,14 @@ # along with this program. If not, see # . +import os import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) if not "/usr/share/system-config-network/" in sys.path: sys.path.append("/usr/share/system-config-network") diff --git a/src/com.gluster.storage.management.gateway.scripts/src/Utils.py b/src/com.gluster.storage.management.gateway.scripts/src/Utils.py index 391a2bb3..980e7937 100644 --- a/src/com.gluster.storage.management.gateway.scripts/src/Utils.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/Utils.py @@ -15,8 +15,14 @@ # along with this program. If not, see # . -import sys import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) import re import socket import struct diff --git a/src/com.gluster.storage.management.gateway.scripts/src/XmlHandler.py b/src/com.gluster.storage.management.gateway.scripts/src/XmlHandler.py index 72164ffb..b9db15c8 100644 --- a/src/com.gluster.storage.management.gateway.scripts/src/XmlHandler.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/XmlHandler.py @@ -1,346 +1,346 @@ -# Copyright (C) 2009 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 xml -import xml.parsers.expat -import xml.dom.minidom as MDOM -import os -import Globals -import copy -import Utils - -XML_STRING = 0 -XML_FILE = 1 - -class XDOM: - _domObj = None - - def __init__(self): - self._domObj = MDOM.Document() - return - - @classmethod - def getText(self, nodeList): - rc = "" - for node in nodeList: - if node.nodeType == node.TEXT_NODE: - rc = rc + node.data - return rc - - def parseString(self, requestString): - try: - self._domObj = MDOM.parseString(requestString) - except xml.parsers.expat.ExpatError, e: - Utils.log("XML string parse error: %s" % str(e)) - return False - return True - - def parseFile(self, fileName): - try: - self._domObj = MDOM.parse(fileName) - except IOError, e: - Utils.log("error reading file: %s" % str(e)) - return False - except xml.parsers.expat.ExpatError, e: - Utils.log("XML file %s parse error: %s" % (fileName, str(e))) - return False - return True - - def setDomObj(self, dom): - if dom and type(dom) != type([]): - self._domObj = dom - return True - return False - - def createTag(self, tag, text=None): - if not self._domObj: - return None - if tag == None: - return None - - tagE = self._domObj.createElement(str(tag)) - if text: - tagEText = self._domObj.createTextNode(str(text)) - tagE.appendChild(tagEText) - return tagE - - def addTag(self, tag): - if not self._domObj: - return False - if not tag: - return False - - self._domObj.appendChild(tag) - return True - - def createTagRoute(self, tagRoute, text=None): - if not tagRoute: - return False - - tagList = tagRoute.split(".") - tag = None - previousTag = None - for tagName in tagList[:-1]: - newTag = self.createTag(tagName, None) - if not tag: - tag = newTag - previousTag = newTag - continue - previousTag.appendChild(newTag) - previousTag = newTag - - if previousTag: - previousTag.appendChild(self.createTag(tagList[-1], text)) - else: - tag = self.createTag(tagList[-1], text) - return tag - - def appendTagRoute(self, tagRoute, value=None): - if not self._domObj: - return False - if not tagRoute: - return False - - parentTagE = self._domObj - - tagNameList = tagRoute.split(".") - newTagRoute = tagNameList.pop(-1) - - for i in range(len(tagNameList), 0, -1): - tagE = self.getElementsByTagRoute(".".join(tagNameList[:i])) - if tagE: - parentTagE = tagE[0] - break - newTagRoute = tagNameList[i-1] + "." + newTagRoute - - newTagE = self.createTagRoute(newTagRoute, value) - if not newTagE: - return False - try: - parentTagE.appendChild(newTagE) - except xml.dom.HierarchyRequestErr, e: - Utils.log("error occured. %s" + str(e)) - return False - return True - - def setTextByTagRoute(self, tagRoute, tagValue): - if not self._domObj: - return None - - if not tagRoute: - return None - - tagE = self.getElementsByTagRoute(tagRoute) - if not tagE: - return False - - parentTagE = self.getElementsByTagRoute(".".join(tagRoute.split(".")[:-1])) - if not parentTagE: - return False - - parentTagE[0].childNodes.remove(tagE[0]) - parentTagE[0].appendChild(self.createTag(tagRoute.split(".")[-1], tagValue)) - return True - - def getElementsByTagRoute(self, tagRoute): - if not self._domObj: - return None - - if not tagRoute: - return None - - x = None - for tag in tagRoute.split("."): - if x is None: - x = self._domObj.getElementsByTagName(tag) - continue - if x == []: - break - x = x[0].getElementsByTagName(tag) - return x - - def getTextByTagRoute(self, tagRoute): - if not self._domObj: - return None - - x = self.getElementsByTagRoute(tagRoute) - if x: - return self.getText(x[0].childNodes) - return None - - def getElementsByTagName(self, name): - if not self._domObj: - return None - return self._domObj.getElementsByTagName(name) - - def writexml(self, fileName, indent="", addindent="", newl=""): - if not self._domObj: - return None - try: - fp = open(fileName, "w") - self._domObj.writexml(fp, indent, addindent, newl) - fp.close() - return True - except IOError: - return False - - def toString(self, indent=" ", newl="\n", encoding = None): - if not self._domObj: - return None - return self._domObj.toprettyxml(indent, newl, encoding) - - def toxml(self, encoding = None): - if not self._domObj: - return None - return self._domObj.toxml(encoding) - - def toprettyxml(self, indent=" ", newl="\n", encoding = None): - return self.toString(indent, newl, encoding) - - def createResponseTag(self): - responseTag = self._domObj.createElement("response") - return responseTag -##--end of XDOM - -class RequestXml(XDOM): - def __init__(self, requestString, type=None): - if None == requestString: - XDOM.__init__(self) - return - try: - if None == type: - if os.path.isfile(requestString): - self._domObj = MDOM.parse(requestString) - else: - self._domObj = MDOM.parseString(requestString) - elif XML_FILE == type: - self._domObj = MDOM.parse(requestString) - elif XML_STRING == type: - self._domObj = MDOM.parseString(requestString) - except IOError: - XDOM.__init__(self) - except xml.parsers.expat.ExpatError: - XDOM.__init__(self) - -##--end of RequestXML - - -class ResponseXml(XDOM): - _responseTag = None - def __init__(self): - XDOM.__init__(self) - self._responseTag = self.createResponseTag() - self._domObj.appendChild(self._responseTag) - - @classmethod - def errorResponse(self, message): - if not self.responseTag: - return False - self.appendTagRoute("status.code", "-1"); - self.appendTagRoute("status.message", message) - - def append(self, tagName, tagValue=None): - if not self._responseTag: - return False - tag = self.createTag(tagName, tagValue) - if tag: - self._responseTag.appendChild(tag) - return True - return False - - def appendTag(self, tag): - if not tag: - return False - if not self._responseTag: - return False - self._responseTag.appendChild(tag) - return True - - def appendTagRoute(self, tagRoute, value=None): - if not self._responseTag: - return None - if not tagRoute: - return None - - parentTagE = self._responseTag - - tagNameList = tagRoute.split(".") - newTagRoute = tagNameList.pop(-1) - - for i in range(len(tagNameList), 0, -1): - tagE = self.getElementsByTagRoute(".".join(["response"] + tagNameList[:i])) - if tagE: - parentTagE = tagE[0] - break - newTagRoute = tagNameList[i-1] + "." + newTagRoute - - newTagE = self.createTagRoute(newTagRoute, value) - if not newTagE: - return None - try: - parentTagE.appendChild(newTagE) - except xml.dom.HierarchyRequestErr, e: - Utils.log("error occured. %s" + str(e)) - return None - return newTagE - - def appendTagRouteOld(self, tagRoute, value=None): - if not self._responseTag: - return False - if not tagRoute: - return False - - parentTagE = self._responseTag - - tagNameList = tagRoute.split(".") - newTagRoute = tagNameList.pop(-1) - - for i in range(len(tagNameList), 0, -1): - tagE = self.getElementsByTagRoute(".".join(["response"] + tagNameList[:i])) - if tagE: - parentTagE = tagE[0] - break - newTagRoute = tagNameList[i-1] + "." + newTagRoute - - newTagE = self.createTagRoute(newTagRoute, value) - if not newTagE: - return False - try: - parentTagE.appendChild(newTagE) - except xml.dom.HierarchyRequestErr, e: - Utils.log("error occured. %s" + str(e)) - return False - return True -##--end of ResponseXml - -def test(): - rs = ResponseXml() - rs.appendTagRoute("status.code", "0"); - rs.appendTagRoute("status.message", "SUCCESS") - serverTag = rs.appendTagRoute("server.name", "Server1") - networkInterfaces = rs.appendTagRoute("server.networkInterfaces", None) - networkTag = rs.createTag("networkInterface", None) - networkTag.appendChild(rs.createTag("name", "interface1")) - networkTag.appendChild(rs.createTag("ipaddress", "192.168.1.40")) - networkInterfaces.appendChild(networkTag) - networkTag = rs.createTag("networkInterface", None) - networkTag.appendChild(rs.createTag("name", "interface2")) - networkTag.appendChild(rs.createTag("ipaddress", "192.168.1.41")) - networkInterfaces.appendChild(networkTag) - print rs.toprettyxml() - -#test() +# Copyright (C) 2009 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 xml +import xml.parsers.expat +import xml.dom.minidom as MDOM +import os +import Globals +import copy +import Utils + +XML_STRING = 0 +XML_FILE = 1 + +class XDOM: + _domObj = None + + def __init__(self): + self._domObj = MDOM.Document() + return + + @classmethod + def getText(self, nodeList): + rc = "" + for node in nodeList: + if node.nodeType == node.TEXT_NODE: + rc = rc + node.data + return rc + + def parseString(self, requestString): + try: + self._domObj = MDOM.parseString(requestString) + except xml.parsers.expat.ExpatError, e: + Utils.log("XML string parse error: %s" % str(e)) + return False + return True + + def parseFile(self, fileName): + try: + self._domObj = MDOM.parse(fileName) + except IOError, e: + Utils.log("error reading file: %s" % str(e)) + return False + except xml.parsers.expat.ExpatError, e: + Utils.log("XML file %s parse error: %s" % (fileName, str(e))) + return False + return True + + def setDomObj(self, dom): + if dom and type(dom) != type([]): + self._domObj = dom + return True + return False + + def createTag(self, tag, text=None): + if not self._domObj: + return None + if tag == None: + return None + + tagE = self._domObj.createElement(str(tag)) + if text: + tagEText = self._domObj.createTextNode(str(text)) + tagE.appendChild(tagEText) + return tagE + + def addTag(self, tag): + if not self._domObj: + return False + if not tag: + return False + + self._domObj.appendChild(tag) + return True + + def createTagRoute(self, tagRoute, text=None): + if not tagRoute: + return False + + tagList = tagRoute.split(".") + tag = None + previousTag = None + for tagName in tagList[:-1]: + newTag = self.createTag(tagName, None) + if not tag: + tag = newTag + previousTag = newTag + continue + previousTag.appendChild(newTag) + previousTag = newTag + + if previousTag: + previousTag.appendChild(self.createTag(tagList[-1], text)) + else: + tag = self.createTag(tagList[-1], text) + return tag + + def appendTagRoute(self, tagRoute, value=None): + if not self._domObj: + return False + if not tagRoute: + return False + + parentTagE = self._domObj + + tagNameList = tagRoute.split(".") + newTagRoute = tagNameList.pop(-1) + + for i in range(len(tagNameList), 0, -1): + tagE = self.getElementsByTagRoute(".".join(tagNameList[:i])) + if tagE: + parentTagE = tagE[0] + break + newTagRoute = tagNameList[i-1] + "." + newTagRoute + + newTagE = self.createTagRoute(newTagRoute, value) + if not newTagE: + return False + try: + parentTagE.appendChild(newTagE) + except xml.dom.HierarchyRequestErr, e: + Utils.log("error occured. %s" + str(e)) + return False + return True + + def setTextByTagRoute(self, tagRoute, tagValue): + if not self._domObj: + return None + + if not tagRoute: + return None + + tagE = self.getElementsByTagRoute(tagRoute) + if not tagE: + return False + + parentTagE = self.getElementsByTagRoute(".".join(tagRoute.split(".")[:-1])) + if not parentTagE: + return False + + parentTagE[0].childNodes.remove(tagE[0]) + parentTagE[0].appendChild(self.createTag(tagRoute.split(".")[-1], tagValue)) + return True + + def getElementsByTagRoute(self, tagRoute): + if not self._domObj: + return None + + if not tagRoute: + return None + + x = None + for tag in tagRoute.split("."): + if x is None: + x = self._domObj.getElementsByTagName(tag) + continue + if x == []: + break + x = x[0].getElementsByTagName(tag) + return x + + def getTextByTagRoute(self, tagRoute): + if not self._domObj: + return None + + x = self.getElementsByTagRoute(tagRoute) + if x: + return self.getText(x[0].childNodes) + return None + + def getElementsByTagName(self, name): + if not self._domObj: + return None + return self._domObj.getElementsByTagName(name) + + def writexml(self, fileName, indent="", addindent="", newl=""): + if not self._domObj: + return None + try: + fp = open(fileName, "w") + self._domObj.writexml(fp, indent, addindent, newl) + fp.close() + return True + except IOError: + return False + + def toString(self, indent=" ", newl="\n", encoding = None): + if not self._domObj: + return None + return self._domObj.toprettyxml(indent, newl, encoding) + + def toxml(self, encoding = None): + if not self._domObj: + return None + return self._domObj.toxml(encoding) + + def toprettyxml(self, indent=" ", newl="\n", encoding = None): + return self.toString(indent, newl, encoding) + + def createResponseTag(self): + responseTag = self._domObj.createElement("response") + return responseTag +##--end of XDOM + +class RequestXml(XDOM): + def __init__(self, requestString, type=None): + if None == requestString: + XDOM.__init__(self) + return + try: + if None == type: + if os.path.isfile(requestString): + self._domObj = MDOM.parse(requestString) + else: + self._domObj = MDOM.parseString(requestString) + elif XML_FILE == type: + self._domObj = MDOM.parse(requestString) + elif XML_STRING == type: + self._domObj = MDOM.parseString(requestString) + except IOError: + XDOM.__init__(self) + except xml.parsers.expat.ExpatError: + XDOM.__init__(self) + +##--end of RequestXML + + +class ResponseXml(XDOM): + _responseTag = None + def __init__(self): + XDOM.__init__(self) + self._responseTag = self.createResponseTag() + self._domObj.appendChild(self._responseTag) + + @classmethod + def errorResponse(self, message): + if not self.responseTag: + return False + self.appendTagRoute("status.code", "-1"); + self.appendTagRoute("status.message", message) + + def append(self, tagName, tagValue=None): + if not self._responseTag: + return False + tag = self.createTag(tagName, tagValue) + if tag: + self._responseTag.appendChild(tag) + return True + return False + + def appendTag(self, tag): + if not tag: + return False + if not self._responseTag: + return False + self._responseTag.appendChild(tag) + return True + + def appendTagRoute(self, tagRoute, value=None): + if not self._responseTag: + return None + if not tagRoute: + return None + + parentTagE = self._responseTag + + tagNameList = tagRoute.split(".") + newTagRoute = tagNameList.pop(-1) + + for i in range(len(tagNameList), 0, -1): + tagE = self.getElementsByTagRoute(".".join(["response"] + tagNameList[:i])) + if tagE: + parentTagE = tagE[0] + break + newTagRoute = tagNameList[i-1] + "." + newTagRoute + + newTagE = self.createTagRoute(newTagRoute, value) + if not newTagE: + return None + try: + parentTagE.appendChild(newTagE) + except xml.dom.HierarchyRequestErr, e: + Utils.log("error occured. %s" + str(e)) + return None + return newTagE + + def appendTagRouteOld(self, tagRoute, value=None): + if not self._responseTag: + return False + if not tagRoute: + return False + + parentTagE = self._responseTag + + tagNameList = tagRoute.split(".") + newTagRoute = tagNameList.pop(-1) + + for i in range(len(tagNameList), 0, -1): + tagE = self.getElementsByTagRoute(".".join(["response"] + tagNameList[:i])) + if tagE: + parentTagE = tagE[0] + break + newTagRoute = tagNameList[i-1] + "." + newTagRoute + + newTagE = self.createTagRoute(newTagRoute, value) + if not newTagE: + return False + try: + parentTagE.appendChild(newTagE) + except xml.dom.HierarchyRequestErr, e: + Utils.log("error occured. %s" + str(e)) + return False + return True +##--end of ResponseXml + +def test(): + rs = ResponseXml() + rs.appendTagRoute("status.code", "0"); + rs.appendTagRoute("status.message", "SUCCESS") + serverTag = rs.appendTagRoute("server.name", "Server1") + networkInterfaces = rs.appendTagRoute("server.networkInterfaces", None) + networkTag = rs.createTag("networkInterface", None) + networkTag.appendChild(rs.createTag("name", "interface1")) + networkTag.appendChild(rs.createTag("ipaddress", "192.168.1.40")) + networkInterfaces.appendChild(networkTag) + networkTag = rs.createTag("networkInterface", None) + networkTag.appendChild(rs.createTag("name", "interface2")) + networkTag.appendChild(rs.createTag("ipaddress", "192.168.1.41")) + networkInterfaces.appendChild(networkTag) + print rs.toprettyxml() + +#test() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/add_user_cifs.py b/src/com.gluster.storage.management.gateway.scripts/src/add_user_cifs.py index 7b9650d1..48888744 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/add_user_cifs.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/add_user_cifs.py @@ -5,6 +5,12 @@ import os import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) import Globals import Utils diff --git a/src/com.gluster.storage.management.gateway.scripts/src/clear_volume_directory.py b/src/com.gluster.storage.management.gateway.scripts/src/clear_volume_directory.py index 6b6d453e..029787e5 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/clear_volume_directory.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/clear_volume_directory.py @@ -5,6 +5,12 @@ import os import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) import syslog import time from XmlHandler import ResponseXml diff --git a/src/com.gluster.storage.management.gateway.scripts/src/create_volume_cifs.py b/src/com.gluster.storage.management.gateway.scripts/src/create_volume_cifs.py index a81b165b..1ef8192e 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/create_volume_cifs.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/create_volume_cifs.py @@ -5,6 +5,12 @@ import os import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) import Globals import Utils import VolumeUtils diff --git a/src/com.gluster.storage.management.gateway.scripts/src/create_volume_directory.py b/src/com.gluster.storage.management.gateway.scripts/src/create_volume_directory.py index 3e633697..e295f249 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/create_volume_directory.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/create_volume_directory.py @@ -17,6 +17,12 @@ # . import os import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) from XmlHandler import ResponseXml import DiskUtils import Utils diff --git a/src/com.gluster.storage.management.gateway.scripts/src/delete_user_cifs.py b/src/com.gluster.storage.management.gateway.scripts/src/delete_user_cifs.py index e5cda957..76eb55d9 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/delete_user_cifs.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/delete_user_cifs.py @@ -5,6 +5,12 @@ import os import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) import Utils def main(): diff --git a/src/com.gluster.storage.management.gateway.scripts/src/delete_volume_cifs.py b/src/com.gluster.storage.management.gateway.scripts/src/delete_volume_cifs.py index fd1febc9..8bd9e7c2 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/delete_volume_cifs.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/delete_volume_cifs.py @@ -5,6 +5,12 @@ import os import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) import Globals import Utils import VolumeUtils diff --git a/src/com.gluster.storage.management.gateway.scripts/src/format_device.py b/src/com.gluster.storage.management.gateway.scripts/src/format_device.py index 3bc70532..a3099e59 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/format_device.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/format_device.py @@ -18,6 +18,12 @@ import os import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) import Globals import Utils import DiskUtils @@ -69,9 +75,9 @@ def main(): sys.exit(5) if options.fstype: - command = ["gluster_provision_block_wrapper.py", "-t", "%s" % (options.fstype), "%s" % (device)] + command = ["%s/gluster_provision_block_wrapper.py" % p1, "-t", "%s" % (options.fstype), "%s" % (device)] else: - command = ["gluster_provision_block_wrapper.py", "%s" % (device)] + command = ["%s/gluster_provision_block_wrapper.py" % p1, "%s" % (device)] try: pid = os.fork() @@ -79,7 +85,7 @@ def main(): Utils.log("failed to fork a child process: %s" % str(e)) sys.exit(6) if pid == 0: - os.execv("/usr/sbin/gluster_provision_block_wrapper.py", command) + os.execv(command[0], command) sys.exit(0) diff --git a/src/com.gluster.storage.management.gateway.scripts/src/get_brick_status.py b/src/com.gluster.storage.management.gateway.scripts/src/get_brick_status.py index cf84080b..afc15f3a 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/get_brick_status.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/get_brick_status.py @@ -5,6 +5,12 @@ import os import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) import Utils def main(): diff --git a/src/com.gluster.storage.management.gateway.scripts/src/get_format_device_status.py b/src/com.gluster.storage.management.gateway.scripts/src/get_format_device_status.py index 57fc0455..39bfe01c 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/get_format_device_status.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/get_format_device_status.py @@ -18,6 +18,12 @@ import os import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) import time import Utils import DiskUtils diff --git a/src/com.gluster.storage.management.gateway.scripts/src/get_rrd_cpu_details.py b/src/com.gluster.storage.management.gateway.scripts/src/get_rrd_cpu_details.py index 546aec31..57ab4025 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/get_rrd_cpu_details.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/get_rrd_cpu_details.py @@ -17,6 +17,12 @@ # . import os import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) from XmlHandler import ResponseXml import Utils diff --git a/src/com.gluster.storage.management.gateway.scripts/src/get_rrd_memory_details.py b/src/com.gluster.storage.management.gateway.scripts/src/get_rrd_memory_details.py index f7c3031b..a6dd4987 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/get_rrd_memory_details.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/get_rrd_memory_details.py @@ -44,6 +44,12 @@ import os import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) import syslog from XmlHandler import ResponseXml import Utils diff --git a/src/com.gluster.storage.management.gateway.scripts/src/get_rrd_net_details.py b/src/com.gluster.storage.management.gateway.scripts/src/get_rrd_net_details.py index 6a31cde8..c319c888 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/get_rrd_net_details.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/get_rrd_net_details.py @@ -17,6 +17,12 @@ # . import os import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) from XmlHandler import ResponseXml import Utils diff --git a/src/com.gluster.storage.management.gateway.scripts/src/get_server_details.py b/src/com.gluster.storage.management.gateway.scripts/src/get_server_details.py index ba735892..f9c1652f 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/get_server_details.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/get_server_details.py @@ -16,7 +16,14 @@ # along with this program. If not, see # . +import os import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) import socket import re import Utils diff --git a/src/com.gluster.storage.management.gateway.scripts/src/get_server_status.py b/src/com.gluster.storage.management.gateway.scripts/src/get_server_status.py index a57428b6..2814f10f 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/get_server_status.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/get_server_status.py @@ -5,6 +5,12 @@ import os import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) import Utils def main(): diff --git a/src/com.gluster.storage.management.gateway.scripts/src/get_volume_brick_log.py b/src/com.gluster.storage.management.gateway.scripts/src/get_volume_brick_log.py index fd7361da..ff4a4b9a 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/get_volume_brick_log.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/get_volume_brick_log.py @@ -19,6 +19,12 @@ import re import os import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) from XmlHandler import XDOM def enumLogType(logCode): diff --git a/src/com.gluster.storage.management.gateway.scripts/src/get_volume_log.py b/src/com.gluster.storage.management.gateway.scripts/src/get_volume_log.py index b906c002..f388aa4e 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/get_volume_log.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/get_volume_log.py @@ -15,8 +15,15 @@ # along with this program. If not, see # . +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) import Globals -import syslog import Utils from VolumeUtils import * from XmlHandler import ResponseXml diff --git a/src/com.gluster.storage.management.gateway.scripts/src/gluster_provision_block_wrapper.py b/src/com.gluster.storage.management.gateway.scripts/src/gluster_provision_block_wrapper.py index a3b2776d..849bce3f 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/gluster_provision_block_wrapper.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/gluster_provision_block_wrapper.py @@ -18,6 +18,12 @@ import os import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) import subprocess import Utils import DiskUtils diff --git a/src/com.gluster.storage.management.gateway.scripts/src/modify_volume_cifs.py b/src/com.gluster.storage.management.gateway.scripts/src/modify_volume_cifs.py index f6bacfc4..0254e2ba 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/modify_volume_cifs.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/modify_volume_cifs.py @@ -5,6 +5,12 @@ import os import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) import Utils import VolumeUtils diff --git a/src/com.gluster.storage.management.gateway.scripts/src/rrd_update_cpu_details.py b/src/com.gluster.storage.management.gateway.scripts/src/rrd_update_cpu_details.py index 73982971..6ec6a1e3 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/rrd_update_cpu_details.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/rrd_update_cpu_details.py @@ -17,6 +17,12 @@ # . import os import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) from XmlHandler import ResponseXml import Utils diff --git a/src/com.gluster.storage.management.gateway.scripts/src/rrd_update_memory_details.py b/src/com.gluster.storage.management.gateway.scripts/src/rrd_update_memory_details.py index fe4fcce6..0a30d248 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/rrd_update_memory_details.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/rrd_update_memory_details.py @@ -17,6 +17,12 @@ # . import os import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) from XmlHandler import ResponseXml import Utils diff --git a/src/com.gluster.storage.management.gateway.scripts/src/setup_cifs_config.py b/src/com.gluster.storage.management.gateway.scripts/src/setup_cifs_config.py index 2cc35acc..7f9ed612 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/setup_cifs_config.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/setup_cifs_config.py @@ -5,6 +5,12 @@ import os import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) import Globals import Utils diff --git a/src/com.gluster.storage.management.gateway.scripts/src/start_volume_cifs.py b/src/com.gluster.storage.management.gateway.scripts/src/start_volume_cifs.py index 239216c3..d05c9644 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/start_volume_cifs.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/start_volume_cifs.py @@ -5,6 +5,12 @@ import os import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) import Globals import Utils import VolumeUtils diff --git a/src/com.gluster.storage.management.gateway.scripts/src/stop_volume_cifs.py b/src/com.gluster.storage.management.gateway.scripts/src/stop_volume_cifs.py index 99ac4750..d6e17e3f 100755 --- a/src/com.gluster.storage.management.gateway.scripts/src/stop_volume_cifs.py +++ b/src/com.gluster.storage.management.gateway.scripts/src/stop_volume_cifs.py @@ -5,6 +5,12 @@ import os import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) import Globals import Utils import VolumeUtils -- cgit