Beispiel #1
0
 def doQuery(self):
     """
     function: do query
     input  : NA
     output : NA
     """
     hostName = DefaultValue.GetHostIpOrName()
     sshtool = SshTool(self.context.clusterInfo.getClusterNodeNames())
     cmd = queryCmd()
     if (self.context.g_opts.outFile != ""):
         cmd.outputFile = self.context.g_opts.outFile
     self.context.clusterInfo.queryClsInfo(hostName, sshtool,
                                           self.context.mpprcFile, cmd)
 def distributeFiles(self):
     """
     function: distribute package to every host
     input : NA
     output: NA
     """
     self.logger.debug("Distributing files.")
     try:
         # get the all nodes
         hosts = self.clusterInfo.getClusterNodeNames()
         if DefaultValue.GetHostIpOrName() not in hosts:
             raise Exception(ErrorCode.GAUSS_516["GAUSS_51619"] %
                             DefaultValue.GetHostIpOrName())
         hosts.remove(DefaultValue.GetHostIpOrName())
         # Send xml file to every host
         DefaultValue.distributeXmlConfFile(self.sshTool, self.xmlFile,
                                            hosts, self.mpprcFile)
         # Successfully distributed files
         self.logger.debug("Successfully distributed files.")
     except Exception as e:
         # failed to distribute package to every host
         raise Exception(str(e))
Beispiel #3
0
def is_local_node(host):
    """
    function: check whether is or not local node
    input  : NA
    output : NA
    """
    if (host == DefaultValue.GetHostIpOrName()):
        return True
    allNetworkInfo = g_network.getAllNetworkIp()
    for network in allNetworkInfo:
        if (host == network.ipAddress):
            return True
    return False
Beispiel #4
0
def parseCommandLine():
    """
    function: parseCommandLine
    input: NA
    output: NA
    """
    try:
        paraLine = sys.argv[1]
        paraLine = DefaultValue.encodeParaline(paraLine,
                                               DefaultValue.BASE_DECODE)
        paraLine = paraLine.strip()
        paraList = paraLine.split("*==SYMBOL==*")
        opts, args = getopt.getopt(
            paraList[1:], "U:C:D:T:P:l:hX:",
            ["help", "alarm=", "gucXml", "vc_mode", "dws-mode"])
    except Exception as e:
        usage()
        GaussLog.exitWithError(ErrorCode.GAUSS_500["GAUSS_50000"] % str(e))

    if (len(args) > 0):
        GaussLog.exitWithError(ErrorCode.GAUSS_500["GAUSS_50000"] %
                               str(args[0]))

    global g_opts
    g_opts = CmdOptions()

    for (key, value) in opts:
        if (key == "-h" or key == "--help"):
            usage()
            sys.exit(0)
        elif (key == "-U"):
            g_opts.clusterUser = value
        elif (key == "-D"):
            g_opts.dataGucParams.append(value)
        elif (key == "-T"):
            g_opts.configType = value
        elif (key == "-P"):
            g_opts.clusterStaticConfigFile = value
        elif (key == "-l"):
            g_opts.logFile = os.path.realpath(value)
        elif (key == "--alarm"):
            g_opts.alarmComponent = value
        elif (key == "--gucXml"):
            g_opts.gucXml = True
        elif (key == "--vc_mode"):
            g_opts.vcMode = True
        elif (key == "--dws-mode"):
            g_opts.dws_mode = True
        elif key == "-X":
            g_opts.clusterConf = os.path.realpath(value)
        Parameter.checkParaVaild(key, value)
Beispiel #5
0
    def cleanLocalOsUser(self):
        """
        function: Clean local os user
        input : NA
        output: NA
        """
        if (not self.deleteUser):
            if (self.localMode):
                cmd = "rm -rf '%s'" % self.clusterInfo.appPath
                DefaultValue.execCommandWithMode(cmd,
                                                 "delete install directory",
                                                 self.sshTool, self.localMode,
                                                 self.mpprcFile)
            return

        group = grp.getgrgid(pwd.getpwnam(self.user).pw_gid).gr_name

        # clean local user
        self.logger.log("Deleting local OS user.")
        cmd = "%s -U %s -l %s" % (OMCommand.getLocalScript(
            "Local_Clean_OsUser"), self.user, self.localLog)
        self.logger.debug("Command for deleting local OS user: %s" % cmd)
        (status, output) = subprocess.getstatusoutput(cmd)
        if (status != 0):
            self.logger.logExit(output)
        self.logger.log("Successfully deleted local OS user.")

        if (self.deleteGroup):
            # clean local user group
            self.logger.debug("Deleting local OS group.")
            cmd = "%s -t %s -u %s -l '%s' -X '%s'" % (
                OMCommand.getLocalScript("Local_UnPreInstall"),
                ACTION_DELETE_GROUP, group, self.localLog, self.xmlFile)
            self.logger.debug("Command for deleting local OS group: %s" % cmd)
            (status, output) = subprocess.getstatusoutput(cmd)
            if (status != 0):
                self.logger.log(output.strip())
            self.logger.debug("Deleting local group is completed.")
    def check_cluster_version_consistency(self, clusterNodes, newNodes=None):
        """
        """
        self.logger.log("Check cluster version consistency.")
        if newNodes is None:
            newNodes = []
        dic_version_info = {}
        # check version.cfg on every node.
        gp_home = DefaultValue.getEnv("GPHOME")
        gauss_home = DefaultValue.getEnv("GAUSSHOME")
        if not (os.path.exists(gp_home) and os.path.exists(gauss_home)):
            GaussLog.exitWithError(ErrorCode.GAUSS_502["GAUSS_50201"] %
                                   ("%s", "or %s") % (gp_home, gauss_home))
        for ip in clusterNodes:
            if ip in newNodes:
                cmd = "pssh -s -H %s 'cat %s/version.cfg'" % \
                      (ip, DefaultValue.getEnv("GPHOME"))
            else:
                cmd = "pssh -s -H %s 'cat %s/bin/upgrade_version'" % \
                      (ip, DefaultValue.getEnv("GAUSSHOME"))
            status, output = subprocess.getstatusoutput(cmd)
            if (status != 0):
                raise Exception(ErrorCode.GAUSS_514["GAUSS_51400"] % cmd +
                                " Error:\n%s" % str(output))
            if len(output.strip().split()) < 3:
                raise Exception(ErrorCode.GAUSS_516["GAUSS_51623"])
            dic_version_info[ip] = ",".join(output.strip().split()[1:])

        self.logger.debug("The cluster version on every node.")
        for check_ip, version_info in dic_version_info.items():
            self.logger.debug("%s : %s" % (check_ip, version_info))
        if len(set(dic_version_info.values())) != 1:
            L_inconsistent = list(set(dic_version_info.values()))
            self.logger.debug("The package version on some nodes are "
                              "inconsistent\n%s" % str(L_inconsistent))
            raise Exception("The package version on some nodes are "
                            "inconsistent,%s" % str(L_inconsistent))
        self.logger.log("Successfully checked cluster version.")
 def managerOperateStepDir(self, action='create', nodes=None):
     """
     function: manager operate step directory 
     input : NA
     output: currentStep
     """
     if nodes is None:
         nodes = []
     try:
         # Creating the backup directory
         if (action == "create"):
             cmd = "(if [ ! -d '%s' ];then mkdir -p '%s' -m %s;fi)" % (
                 self.operateStepDir, self.operateStepDir,
                 DefaultValue.KEY_DIRECTORY_MODE)
         else:
             cmd = "(if [ -d '%s' ];then rm -rf '%s';fi)" % (
                 self.operateStepDir, self.operateStepDir)
         DefaultValue.execCommandWithMode(cmd,
                                          "%s temporary directory" % action,
                                          self.sshTool, self.localMode
                                          or self.isSingle, "", nodes)
     except Exception as e:
         raise Exception(str(e))
    def checkRemoteFileExist(self, filepath):
        """
        funciton:check file exist on remote node
        input:filepath
        output:dictionary
        """
        existNodes = []
        for nodeName in self.context.clusterInfo.getClusterNodeNames():
            if (nodeName == DefaultValue.GetHostIpOrName()):
                continue
            if (self.sshTool.checkRemoteFileExist(nodeName, filepath, "")):
                existNodes.append(nodeName)

        return existNodes
    def perCheck(self):
        """
        function: 1.Check instance port  
                  2.Check instance IP
        input : NA
        output: NA
        """
        ipList = self.instInfo.listenIps
        ipList.extend(self.instInfo.haIps)
        portList = []
        portList.append(self.instInfo.port)
        portList.append(self.instInfo.haPort)

        ipList = DefaultValue.Deduplication(ipList)
        portList = DefaultValue.Deduplication(portList)
        # check port
        for port in portList:
            self.__checkport(port, ipList)
        # check ip
        failIps = g_network.checkIpAddressList(ipList)
        if (len(failIps) > 0):
            raise Exception(ErrorCode.GAUSS_506["GAUSS_50600"] +
                            " The IP is %s." % ",".join(failIps))
    def installClusterApp(self):
        """
        function: install cluster instance
        input : NA
        output: NA
        """
        self.context.logger.log("Installing applications on all nodes.")
        # Installing applications
        cmd = "source %s;" % self.context.mpprcFile
        cmd += "%s -t %s -U %s -X %s -R %s -c %s -l %s %s" % (
            OMCommand.getLocalScript("Local_Install"), ACTION_INSTALL_CLUSTER,
            self.context.user + ":" + self.context.group, self.context.xmlFile,
            self.context.clusterInfo.appPath, self.context.clusterInfo.name,
            self.context.localLog, self.getCommandOptions())
        self.context.logger.debug("Command for installing application: %s" %
                                  cmd)

        # exec the cmd for install application on all nodes
        DefaultValue.execCommandWithMode(cmd, "Install applications",
                                         self.context.sshTool,
                                         self.context.isSingle,
                                         self.context.mpprcFile)
        self.context.logger.log("Successfully installed APP.")
Beispiel #11
0
    def CleanInstanceDir(self):
        """
        function: Clean instance directory
        input : NA
        output: NA
        """
        self.logger.log("Deleting the instance's directory.")
        cmd = "%s -U %s -l '%s' -X '%s'" % (OMCommand.getLocalScript(
            "Local_Clean_Instance"), self.user, self.localLog, self.xmlFile)
        self.logger.debug("Command for deleting the instance: %s" % cmd)
        DefaultValue.execCommandWithMode(cmd, "delete the instances data",
                                         self.sshTool, self.localMode,
                                         self.mpprcFile)

        # clean upgrade temp backup path
        cmd = "rm -rf '%s'" % DefaultValue.getBackupDir("upgrade")
        self.logger.debug(
            "Command for deleting the upgrade temp backup path: %s" % cmd)
        DefaultValue.execCommandWithMode(
            cmd, "delete backup directory for upgrade", self.sshTool,
            self.localMode, self.mpprcFile)

        self.logger.log("Successfully deleted the instance's directory.")
 def checkNode(self):
     """
     function: check if the current node is to be uninstalled
     input : NA
     output: NA
     """
     if (len(
             self.context.g_opts.nodeInfo) != 0
             and self.context.g_opts.hostname ==
             DefaultValue.GetHostIpOrName()):
         raise Exception(
             ErrorCode.GAUSS_516["GAUSS_51631"] % "coordinate"
             + "\nPlease perform this operation on other nodes "
               "because this node will be deleted.")
 def doStart(self):
     """
     function:start cluster
     input : NA
     output: NA
     """
     self.context.logger.debug("Start the cluster.", "addStep")
     try:
         tmpGucFile = ""
         tmpGucPath = DefaultValue.getTmpDirFromEnv(self.context.user)
         tmpGucFile = "%s/tmp_guc" % tmpGucPath
         cmd = g_file.SHELL_CMD_DICT["deleteFile"] % (tmpGucFile,
                                                      tmpGucFile)
         DefaultValue.execCommandWithMode(cmd, "Install applications",
                                          self.context.sshTool,
                                          self.context.isSingle,
                                          self.context.mpprcFile)
         # start cluster in non-native mode
         self.startCluster()
     except Exception as e:
         self.context.logger.logExit(str(e))
     self.context.logger.debug("Successfully started the cluster.",
                               "constant")
 def getOmStatus(user):
     """
     function : Get om status from file
     input : String
     output : NA
     """
     # check status file
     statFile = os.path.join(DefaultValue.getTmpDirFromEnv(),
                             DbClusterStatus.OM_STATUS_FILE)
     if (not os.path.isfile(statFile)):
         return DbClusterStatus.OM_STATUS_NORMAL
     # get om status from file
     status = DbClusterStatus.OM_STATUS_NORMAL
     return status
 def doConfig(self):
     """
     function: Do config action
     input : NA
     output: NA
     """
     self.context.logger.log("Configuring.", "addStep")
     try:
         # prepared config cluster
         # AP: clean instance directory and check node config
         self.prepareConfigCluster()
         self.initNodeInstance()
         self.configInstance()
         self.distributeRackInfo()
         DefaultValue.enableWhiteList(
             self.context.sshTool, self.context.mpprcFile,
             self.context.clusterInfo.getClusterNodeNames(),
             self.context.logger)
     except Exception as e:
         # failed to clear the backup directory
         self.context.logger.logExit(str(e))
     # Configuration is completed
     self.context.logger.log("Configuration is completed.", "constant")
 def genCipherAndRandFile(self, hostList=None, initPwd=None):
     self.logger.debug("Encrypting cipher and rand files.")
     if hostList is None:
         hostList = []
     appPath = DefaultValue.getInstallDir(self.user)
     binPath = os.path.join(appPath, "bin")
     retry = 0
     while True:
         if not initPwd:
             sshpwd = getpass.getpass("Please enter password for database:")
             sshpwd_check = getpass.getpass("Please repeat for database:")
         else:
             sshpwd = sshpwd_check = initPwd
         if sshpwd_check != sshpwd:
             sshpwd = ""
             sshpwd_check = ""
             self.logger.error(ErrorCode.GAUSS_503["GAUSS_50306"] %
                               "database" +
                               "The two passwords are different, "
                               "please enter password again.")
         else:
             cmd = "%s/gs_guc encrypt -M server -K %s -D %s " % (
                 binPath, sshpwd, binPath)
             (status, output) = subprocess.getstatusoutput(cmd)
             sshpwd = ""
             sshpwd_check = ""
             initPwd = ""
             if status != 0:
                 self.logger.error(ErrorCode.GAUSS_503["GAUSS_50322"] %
                                   "database" + "Error:\n %s" % output)
             else:
                 break
         if retry >= 2:
             raise Exception(ErrorCode.GAUSS_503["GAUSS_50322"] %
                             "database")
         retry += 1
     g_file.changeMode(DefaultValue.KEY_FILE_MODE,
                       "'%s'/server.key.cipher" % binPath)
     g_file.changeMode(DefaultValue.KEY_FILE_MODE,
                       "'%s'/server.key.rand" % binPath)
     if len(hostList) == 0:
         for dbNode in self.clusterInfo.dbNodes:
             hostList.append(dbNode.name)
     if not self.isSingle:
         # localhost no need scp files
         for certFile in DefaultValue.BIN_CERT_LIST:
             scpFile = os.path.join(binPath, "%s" % certFile)
             self.sshTool.scpFiles(scpFile, binPath, hostList)
     self.logger.debug("Successfully encrypted cipher and rand files.")
Beispiel #17
0
    def doCheck(self):

        parRes = ""
        flag = "Normal"
        cmd = "ls -l /lib/modules/`uname -r`/kernel/net/sctp/sctp.ko*"
        (status, output) = subprocess.getstatusoutput(cmd)
        if (status != 0 or output == "" or output.find(
                "No such file or directory") > 0):
            if DefaultValue.checkDockerEnv():
                return
            flag = "Error"
            parRes += "There is no sctp service."
        else:
            cmd = "modprobe sctp;"
            cmd += "lsmod |grep sctp"
            (status, output) = subprocess.getstatusoutput(cmd)
            if (output == ""):
                flag = "Error"
                parRes += "sctp service is not loaded."

        cmd = "cat %s | grep '^insmod.*sctp.ko'" % DefaultValue.getOSInitFile()
        (status, output) = subprocess.getstatusoutput(cmd)
        if (status != 0 or output == ""):
            if (flag == "Normal"):
                flag = "Warning"
            parRes += "Sctp service is not set to boot from power on."

        self.result.val = parRes
        self.result.raw = output
        if (flag == "Error"):
            self.result.rst = ResultStatus.NG
        elif (flag == "Warning"):
            self.result.rst = ResultStatus.WARNING
        else:
            self.result.rst = ResultStatus.OK
            self.result.val = "Sctp service is Normal."
Beispiel #18
0
 def checkSpecialChar(self):
     outputList = []
     failList = []
     pathList = []
     paths = self.getDiskPath()
     for path in paths:
         if (not path or not os.path.isdir(path)):
             continue
         else:
             pathList.append(path)
     pool = ThreadPool(DefaultValue.getCpuSet())
     results = pool.map(self.checkSingleSpecialChar, pathList)
     pool.close()
     pool.join()
     for outlist, flist in results:
         if (outlist):
             outputList.extend(outlist)
         if (flist):
             failList.extend(flist)
     if (len(outputList) > 0):
         outputList = DefaultValue.Deduplication(outputList)
     if (failList):
         failList = DefaultValue.Deduplication(failList)
     return outputList, failList
Beispiel #19
0
 def readConfigInfoByXML(self):
     """
     function: Read config from xml config file
     input : NA
     output: NA
     """
     try:
         if (self.clusterConfig is None):
             self.logger.logExit(ErrorCode.GAUSS_502["GAUSS_50201"] %
                                 "XML configuration file")
         static_config_file = "%s/bin/cluster_static_config" % \
                              DefaultValue.getInstallDir(self.user)
         self.clusterInfo = dbClusterInfo()
         self.clusterInfo.initFromXml(self.clusterConfig,
                                      static_config_file)
         hostName = DefaultValue.GetHostIpOrName()
         self.dbNodeInfo = self.clusterInfo.getDbNodeByName(hostName)
         if (self.dbNodeInfo is None):
             self.logger.logExit(ErrorCode.GAUSS_516["GAUSS_51619"] %
                                 hostName)
     except Exception as e:
         self.logger.logExit(str(e))
     self.logger.debug("Instance information on local node:\n%s" %
                       str(self.dbNodeInfo))
    def setEnvParameter(self):
        """
        function: setting DBA environmental variables
        input: NA
        output: NA
        """
        self.context.logger.log("Setting user environmental variables.",
                                "addStep")

        try:
            # Setting DBA environmental variables
            cmdParam = ""
            # get then envParams
            for param in self.context.envParams:
                cmdParam += " -e \\\"%s\\\"" % param

            # set the environmental variables on all nodes
            cmd = "%s -t %s -u %s %s -l %s" % (OMCommand.getLocalScript(
                "Local_PreInstall"), ACTION_SET_USER_ENV, self.context.user,
                                               cmdParam, self.context.localLog)
            # check the mpprcFile
            if (self.context.mpprcFile != ""):
                cmd += " -s '%s'" % self.context.mpprcFile
            self.context.logger.debug(
                "Command for setting user's environmental variables: %s" % cmd)

            # set user's environmental variables
            DefaultValue.execCommandWithMode(
                cmd, "set user's environmental variables.",
                self.context.sshTool, self.context.localMode
                or self.context.isSingle, self.context.mpprcFile)
        except Exception as e:
            raise Exception(str(e))

        self.context.logger.log(
            "Successfully set user environmental variables.", "constant")
    def __init__(self, dropnode):
        """
        """
        self.context = dropnode
        self.user = self.context.user
        self.userProfile = self.context.userProfile
        self.group = self.context.group
        self.backupFilePrimary = ''
        self.localhostname = DefaultValue.GetHostIpOrName()
        self.logger = self.context.logger
        self.resultDictOfPrimary = []
        self.replSlot = ''
        envFile = DefaultValue.getEnv("MPPDB_ENV_SEPARATE_PATH")
        if envFile:
            self.envFile = envFile
        else:
            self.envFile = "/etc/profile"
        gphomepath = DefaultValue.getEnv("GPHOME")
        if gphomepath:
            self.gphomepath = gphomepath
        else:
            (status, output) = subprocess.getstatusoutput("which gs_om")
            if "no gs_om in" in output:
                raise Exception(ErrorCode.GAUSS_518["GAUSS_51800"] % "$GPHOME")
            self.gphomepath = os.path.normpath(
                output.replace("/script/gs_om", ""))
        self.appPath = self.context.clusterInfo.appPath
        self.gsqlPath = "source %s;%s/bin/gsql" % (self.userProfile,
                                                   self.appPath)

        currentTime = str(datetime.datetime.now()).replace(" ", "_").replace(
            ".", "_")
        self.dnIdForDel = []
        for hostDelName in self.context.hostMapForDel.keys():
            self.dnIdForDel += self.context.hostMapForDel[hostDelName]['dn_id']
        self.commonOper = OperCommon(dropnode)
Beispiel #22
0
    def getLockFiles(self):
        """
        function: Get lock files 
        input : NA
        output: NA
        """
        fileList = []
        # the static file must be exists
        tmpDir = os.path.realpath(DefaultValue.getTmpDirFromEnv())

        pgsql = ".s.PGSQL.%d" % self.instInfo.port
        pgsqlLock = ".s.PGSQL.%d.lock" % self.instInfo.port
        fileList.append(os.path.join(tmpDir, pgsql))
        fileList.append(os.path.join(tmpDir, pgsqlLock))
        return fileList
Beispiel #23
0
    def CleanLog(self):
        """
        function: Clean default log
        input : NA
        output: NA
        """
        self.logger.debug("Deleting log.", "addStep")
        # check if need delete instance
        if (not self.cleanInstance):
            self.logger.debug("No need to delete data.", "constant")
            return

        try:
            # clean log
            userLogDir = DefaultValue.getUserLogDirWithUser(self.user)
            cmd = g_file.SHELL_CMD_DICT["cleanDir"] % (userLogDir, userLogDir,
                                                       userLogDir)
            # delete log dir
            DefaultValue.execCommandWithMode(cmd, "delete user log directory",
                                             self.sshTool, self.localMode,
                                             self.mpprcFile)
        except Exception as e:
            self.logger.exitWithError(str(e))
        self.logger.debug("Successfully deleted log.", "constant")
def checkParameter():
    """
    function: check parameter for different action
    input : NA
    output: NA
    """

    # check if user exist and is the right user
    if (g_opts.user != ''):
        DefaultValue.checkUser(g_opts.user)
        tmpDir = DefaultValue.getTmpDirFromEnv(g_opts.user)
        if (not os.path.exists(tmpDir)):
            GaussLog.exitWithError(ErrorCode.GAUSS_502["GAUSS_50201"]
                                   % ("temporary directory[" + tmpDir + "]"))

    # check the -t parameter
    if (g_opts.action == ""):
        GaussLog.exitWithError(ErrorCode.GAUSS_500["GAUSS_50001"] % 't' + '.')
    if (g_opts.action not in list(actioItemMap.keys())):
        GaussLog.exitWithError(ErrorCode.GAUSS_500["GAUSS_50004"] % "t")

    if (g_opts.logFile == ""):
        dirName = os.path.dirname(os.path.realpath(__file__))
        g_opts.logFile = os.path.join(dirName, "gaussdb_localcheck.log")
 def checkTmpDir(self, hostName):
     """
     if the tmp dir id not exist, create it.
     """
     tmpDir = os.path.realpath(DefaultValue.getTmpDirFromEnv())
     checkCmd = 'if [ ! -d "%s" ]; then exit 1;fi;' % (tmpDir)
     sshTool = SshTool([hostName])
     resultMap, outputCollect = sshTool.getSshStatusOutput(
         checkCmd, [hostName], self.envFile)
     ret = resultMap[hostName]
     if ret == STATUS_FAIL:
         self.logger.debug("Node [%s] does not have tmp dir. need to fix.")
         fixCmd = "mkdir -p %s" % (tmpDir)
         sshTool.getSshStatusOutput(fixCmd, [hostName], self.envFile)
     self.cleanSshToolFile(sshTool)
Beispiel #26
0
 def checkHostnameMapping(clusterInfo, logFile):
     """
     function: check host name mapping
     input: NA
     output: NA 
     """
     nodes = clusterInfo.getClusterNodeNames()
     if (len(nodes) > 0):
         try:
             pool = ThreadPool(DefaultValue.getCpuSet())
             results = pool.map(OMCommand.checkHostname, nodes)
             pool.close()
             pool.join()
         except Exception as e:
             raise Exception(str(e))
 def del_remote_pkgpath(self):
     """
     delete remote package path om scripts, lib and version.cfg
     :return:
     """
     if not self.context.is_new_root_path:
         current_path = self.get_package_path()
         script = os.path.join(current_path, "script")
         hostList = self.context.clusterInfo.getClusterNodeNames()
         hostList.remove(DefaultValue.GetHostIpOrName())
         if not self.context.localMode and hostList:
             cmd = "rm -f %s/gs_*" % script
             self.context.sshTool.executeCommand(cmd, "",
                                                 DefaultValue.SUCCESS,
                                                 hostList,
                                                 self.context.mpprcFile)
 def __bakInstallPackage(self):
     """
     function: backup install package for replace
     input : NA
     output: NA
     """
     dirName = os.path.dirname(os.path.realpath(__file__))
     packageFile = "%s/%s" % (os.path.join(dirName, "./../../"),
                              DefaultValue.get_package_back_name())
     # Check if MPPDB package exist
     if not os.path.exists(packageFile):
         self.logger.logExit(ErrorCode.GAUSS_502["GAUSS_50201"]
                             % 'MPPDB package' + " Can not back up.")
     # Save MPPDB package to bin path
     destPath = "'%s'/bin/" % self.installPath
     g_file.cpFile(packageFile, destPath)
 def doRefreshConf(self):
     """
     function: do refresh conf
     input  : NA
     output : NA
     """
     if self.context.clusterInfo.isSingleNode():
         self.logger.log(
             "No need to generate dynamic configuration file for one node.")
         return
     self.logger.log("Generating dynamic configuration file for all nodes.")
     hostName = DefaultValue.GetHostIpOrName()
     sshtool = SshTool(self.context.clusterInfo.getClusterNodeNames())
     self.context.clusterInfo.createDynamicConfig(self.context.user,
                                                  hostName, sshtool)
     self.logger.log("Successfully generated dynamic configuration file.")
Beispiel #30
0
    def __checkOSVersion(self):
        """
        function: Check operator system version, install binary file version.
        input : NA
        output: NA
        """
        self.logger.log("Checking OS version.")
        try:
            if (not DefaultValue.checkOsVersion()):
                raise Exception(ErrorCode.GAUSS_519["GAUSS_51900"] +
                                "The current system is: %s." %
                                platform.platform())
        except Exception as e:
            raise Exception(str(e))

        self.logger.log("Successfully checked OS version.")