def checkNodeInstall(self, nodes=None, checkParams=None, strictUserCheck=True): """ function: Check node install input : nodes, checkParams, strictUserCheck output: NA """ if nodes is None: nodes = [] if checkParams is None: checkParams = [] validParam = ["shared_buffers", "max_connections"] cooGucParam = "" for param in checkParams: entry = param.split("=") if (len(entry) != 2): raise Exception(ErrorCode.GAUSS_500["GAUSS_50009"]) if (entry[0].strip() in validParam): cooGucParam += " -C \\\"%s\\\"" % param self.logger.log("Checking installation environment on all nodes.") cmd = "%s -U %s:%s -R %s %s -l %s -X '%s'" % ( OMCommand.getLocalScript("Local_Check_Install"), self.user, self.group, self.clusterInfo.appPath, cooGucParam, self.localLog, self.xmlFile) if (not strictUserCheck): cmd += " -O" self.logger.debug("Checking the install command: %s." % cmd) DefaultValue.execCommandWithMode(cmd, "check installation environment", self.sshTool, self.localMode or self.isSingle, "", nodes)
def StopCluster(self): """ function: Stopping the cluster input : NA output: NA """ self.logger.log("Stopping the cluster.", "addStep") # get the static config static_config = \ "%s/bin/cluster_static_config" % self.clusterInfo.appPath static_config_bak = \ "%s/bin/cluster_static_config_bak" % self.clusterInfo.appPath # if cluster_static_config_bak exists # and static_config does not exists, mv it to static_config if (not os.path.exists(static_config) and os.path.exists(static_config_bak)): cmd = "mv %s %s" % (static_config_bak, static_config) (status, output) = subprocess.getstatusoutput(cmd) if (status != 0): self.logger.debug("The cmd is %s " % cmd) self.logger.error("rename cluster_static_config_bak failed") self.logger.debug("Error:\n%s" % output) # if path not exits, can not stop cluster if (not os.path.exists(static_config)): self.logger.debug("Failed to stop the cluster.", "constant") return # Stop cluster applications cmd = "source %s; %s -U %s -R %s -l %s" % ( self.mpprcFile, OMCommand.getLocalScript("Local_StopInstance"), self.user, self.clusterInfo.appPath, self.localLog) self.logger.debug("Command for stop cluster: %s" % cmd) DefaultValue.execCommandWithMode(cmd, "Stop cluster", self.sshTool, self.localMode, self.mpprcFile) self.logger.log("Successfully stopped cluster.")
def writeOperateStep(self, stepName, nodes=None): """ function: write operate step signal input : step output: NA """ if nodes is None: nodes = [] try: # write the step into INSTALL_STEP # open the INSTALL_STEP with open(self.operateStepFile, "w") as g_DB: # write the INSTALL_STEP g_DB.write(stepName) g_DB.write(os.linesep) g_DB.flush() # change the INSTALL_STEP permissions g_file.changeMode(DefaultValue.KEY_FILE_MODE, self.operateStepFile) # distribute file to all nodes cmd = "mkdir -p -m %s '%s'" % (DefaultValue.KEY_DIRECTORY_MODE, self.operateStepDir) DefaultValue.execCommandWithMode( cmd, "create backup directory " "on all nodes", self.sshTool, self.localMode or self.isSingle, "", nodes) if not self.localMode and not self.isSingle: self.sshTool.scpFiles(self.operateStepFile, self.operateStepDir, nodes) except Exception as e: # failed to write the step into INSTALL_STEP raise Exception(str(e))
def startCluster(self): """ function: start cluster input : NA output: NA """ # Start cluster 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_START_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 start cluster: %s" % cmd) DefaultValue.execCommandWithMode( cmd, "Start cluster", self.context.sshTool, self.context.isSingle or self.context.localMode, self.context.mpprcFile) # build stand by 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_BUILD_STANDBY, 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 build standby: %s" % cmd) DefaultValue.execCommandWithMode( cmd, "Build standby", self.context.sshTool, self.context.isSingle or self.context.localMode, self.context.mpprcFile) self.context.logger.log("Successfully started cluster.")
def setArmOptimization(self): """ function: setting ARM Optimization input: NA output: NA """ self.context.logger.log("Set ARM Optimization.", "addStep") cmd = "python3 -c 'import platform;print(platform.machine())'" (status, output) = subprocess.getstatusoutput(cmd) if status != 0: self.context.logger.logExit("Command for set platform ARM:" "%s" % cmd + " Error: \n%s" % output) if str(output) == "aarch64": pass else: self.context.logger.log("No need to set ARM Optimization.", "constant") return try: # exec cmd for set platform ARM cmd = "%s -t %s -u %s -l %s -Q %s" % ( OMCommand.getLocalScript("Local_PreInstall"), ACTION_SET_ARM_OPTIMIZATION, self.context.user, self.context.localLog, self.context.clusterToolPath) self.context.logger.debug("Command for set platform ARM: %s" % cmd) DefaultValue.execCommandWithMode( cmd, "set platform ARM", self.context.sshTool, self.context.localMode or self.context.isSingle, self.context.mpprcFile) except Exception as e: raise Exception(str(e)) # Successfully set ARM Optimization self.context.logger.log("Successfully set ARM Optimization.", "constant")
def setCorePath(self): """ function: set file size and path with core file :return: NA """ self.context.clusterInfo.corePath = \ self.context.clusterInfo.readClustercorePath(self.context.xmlFile) if not self.context.clusterInfo.corePath: return self.context.logger.log("Setting Core file", "addStep") try: # this is used to fix the newly created path owner later ownerPath = self.context.clusterInfo.corePath if not os.path.exists(self.context.clusterInfo.corePath): ownerPath = DefaultValue.getTopPathNotExist(ownerPath) cmd = "ulimit -c unlimited; ulimit -c unlimited -S" DefaultValue.execCommandWithMode( cmd, "set core file size.", self.context.sshTool, self.context.localMode or self.context.isSingle) cmd = "echo 1 > /proc/sys/kernel/core_uses_pid && " cmd += "echo '%s" % self.context.clusterInfo.corePath cmd += "/core-%e-%p-%t' > /proc/sys/kernel/core_pattern " cmd += "&& if [ ! -d '%s' ]; then mkdir %s -p -m %d;fi" % ( self.context.clusterInfo.corePath, self.context.clusterInfo.corePath, DefaultValue.DIRECTORY_MODE) cmd += " && chown %s:%s %s -R" % (self.context.user, self.context.group, ownerPath) DefaultValue.execCommandWithMode( cmd, "set core file path.", self.context.sshTool, self.context.localMode or self.context.isSingle) except Exception as e: raise Exception(str(e)) self.context.logger.log("Successfully set core path.", "constant")
def cleanOtherNodesLog(self): """ function: clean other nodes log input : NA output: NA """ # check if local mode if self.localMode: return self.logger.log("Deleting logs of other nodes.") try: # get other nodes hostName = DefaultValue.GetHostIpOrName() otherNodes = self.clusterInfo.getClusterNodeNames() for otherNode in otherNodes: if (otherNode == hostName): otherNodes.remove(otherNode) # clean log cmd = "rm -rf '%s/%s'; rm -rf /tmp/gauss_*;" % ( self.clusterInfo.logPath, self.user) cmd += "rm -rf '%s/Python-2.7.9'" \ % DefaultValue.getClusterToolPath() self.logger.debug("Command for deleting logs of other nodes: %s" % cmd) DefaultValue.execCommandWithMode(cmd, "delete user log directory", self.sshTool, self.localMode, self.mpprcFile, otherNodes) self.logger.debug("Successfully deleted logs of the nodes: %s." % otherNodes) except Exception as e: self.logger.logExit(ErrorCode.GAUSS_502["GAUSS_50207"] % "other nodes log" + " Error: \n%s." % str(e)) self.logger.log("Successfully deleted logs of other nodes.")
def CleanTmpFiles(self): """ function: clean temp files input : NA output: NA """ self.logger.debug("Deleting temporary files.", "addStep") try: # copy record_app_directory file tmpDir = DefaultValue.getTmpDirFromEnv(self.user) if tmpDir == "": raise Exception(ErrorCode.GAUSS_518["GAUSS_51800"] % "$PGHOST") upgradeBackupPath = os.path.join(tmpDir, "binary_upgrade") copyPath = os.path.join(upgradeBackupPath, "record_app_directory") appPath = DefaultValue.getInstallDir(self.user) if appPath == "": raise Exception(ErrorCode.GAUSS_518["GAUSS_51800"] % "$PGHOST") if copyPath != "": copyCmd = "(if [ -f '%s' ];then cp -f -p '%s' '%s/';fi)" % ( copyPath, copyPath, appPath) DefaultValue.execCommandWithMode( copyCmd, "copy record_app_directory file", self.sshTool, self.localMode, self.mpprcFile) cmd = g_file.SHELL_CMD_DICT["cleanDir"] % ( self.tmpDir, self.tmpDir, self.tmpDir) # clean dir of PGHOST DefaultValue.execCommandWithMode(cmd, "delete temporary files", self.sshTool, self.localMode, self.mpprcFile) except Exception as e: self.logger.logExit(str(e)) self.logger.debug("Successfully deleted temporary files.", "constant")
def cleanSyslogConfig(self): """ function: clean syslog config input : NA output: NA """ try: # only suse11/suse12 can support it distname = g_Platform.dist()[0] if (distname.upper() != "SUSE"): return # clean syslog-ng/rsyslog config cmd = "%s -t %s -u %s -l '%s' -X '%s'" % ( OMCommand.getLocalScript("Local_UnPreInstall"), ACTION_CLEAN_SYSLOG_CONFIG, self.user, self.localLog, self.xmlFile) self.logger.debug( "Command for clean syslog-ng/rsyslog config: %s" % cmd) DefaultValue.execCommandWithMode( cmd, "clean syslog-ng/rsyslog config", self.sshTool, self.localMode, self.mpprcFile, self.clusterInfo.getClusterNodeNames()) except Exception as e: self.logger.logExit(str(e))
def checkNodeConfig(self): """ function: Check node config on all nodes input : NA output: NA """ self.context.logger.log("Checking node configuration on all nodes.") # Check node config on all nodes cmdParam = "" for param in self.context.dataGucParam: cmdParam += " -D \\\"%s\\\"" % param cmd = "source %s;" % self.context.mpprcFile cmd += "%s -U %s -l %s %s" % ( OMCommand.getLocalScript("Local_Check_Config"), self.context.user, self.context.localLog, cmdParam) self.context.logger.debug( "Command for checking node configuration: %s." % cmd) cmd = self.singleCmd(cmd) DefaultValue.execCommandWithMode(cmd, "check node configuration", self.context.sshTool, self.context.isSingle) self.context.logger.debug("Successfully checked node configuration.")
def initNodeInstance(self): """ function: init instance applications input : NA output: NA """ self.context.logger.log("Initializing instances on all nodes.") # init instance applications cmdParam = "" # get the --gsinit-parameter parameter values for param in self.context.dbInitParam: cmdParam += " -P \\\"%s\\\"" % param cmd = "source %s;" % self.context.mpprcFile # init instances on all nodes cmd += "%s -U %s %s -l %s" % ( OMCommand.getLocalScript("Local_Init_Instance"), self.context.user, cmdParam, self.context.localLog) self.context.logger.debug("Command for initializing instances: %s" % cmd) cmd = self.singleCmd(cmd) DefaultValue.execCommandWithMode(cmd, "initialize instances", self.context.sshTool, self.context.isSingle) self.context.logger.debug("Successfully initialized node instance.")
def checkNodeInstall(self): """ function: check node install input: NA output: NA """ self.context.logger.debug("Checking node's installation.", "constant") # Checking node's installation self.context.logger.log( "Checking the installation environment on all nodes.", "constant") # Checking the installation environment cmd = "source %s;" % self.context.mpprcFile cmd += "%s -U %s -R %s -l %s -X %s" % ( OMCommand.getLocalScript("Local_Check_Install"), self.context.user + ":" + self.context.group, self.context.clusterInfo.appPath, self.context.localLog, self.context.xmlFile) self.context.logger.debug("Command for checking installation: %s." % cmd) cmd = self.singleCmd(cmd) DefaultValue.execCommandWithMode(cmd, "check installation environment", self.context.sshTool, self.context.isSingle) self.context.logger.debug("Successfully checked node's installation.", "constant")
def fixServerPackageOwner(self): """ function: fix server package. when distribute server package, the os user has not been created, so we should fix server package Owner here after user create. input: NA output: NA """ self.context.logger.log("Fixing server package owner.", "addStep") try: # fix server package owner for oltp cmd = ("%s -t %s -u %s -g %s -X %s -Q %s -l %s" % (OMCommand.getLocalScript("Local_PreInstall"), ACTION_FIX_SERVER_PACKAGE_OWNER, self.context.user, self.context.group, self.context.xmlFile, self.context.clusterToolPath, self.context.localLog)) # check the env file if self.context.mpprcFile != "": cmd += " -s %s" % self.context.mpprcFile self.context.logger.debug("Fix server pkg cmd: %s" % cmd) # exec the cmd DefaultValue.execCommandWithMode(cmd, "fix server package owner", self.context.sshTool, self.context.localMode, self.context.mpprcFile) self.del_remote_pkgpath() except Exception as e: raise Exception(str(e))
def CleanInstance(self): """ function: clean instance input : NA output : NA """ self.logger.debug("Deleting instance.", "addStep") # check if need delete instance if (not self.cleanInstance): self.logger.debug("No need to delete data.", "constant") return # Clean instance data cmd = "%s -U %s -l %s" % (OMCommand.getLocalScript( "Local_Clean_Instance"), self.user, self.localLog) self.logger.debug("Command for deleting instance: %s" % cmd) DefaultValue.execCommandWithMode(cmd, "delete instances data.", self.sshTool, self.localMode, self.mpprcFile) # clean upgrade temp backup path upgrade_bak_dir = DefaultValue.getBackupDir(self.user, "upgrade") cmd = g_file.SHELL_CMD_DICT["cleanDir"] % ( upgrade_bak_dir, upgrade_bak_dir, upgrade_bak_dir) DefaultValue.execCommandWithMode( cmd, "delete backup directory for upgrade", self.sshTool, self.localMode, self.mpprcFile) self.logger.log("Successfully deleted instances.", "constant")
def cleanScript(self): """ clean script directory """ self.logger.debug("Clean script path") cmd = "%s -t %s -u %s -Q %s" % ( OMCommand.getLocalScript("Local_UnPreInstall"), ACTION_CLEAN_DEPENDENCY, self.user, self.clusterToolPath) if self.deleteUser: cmd += " -P %s" % self.userHome DefaultValue.execCommandWithMode(cmd, "clean script", self.sshTool, self.localMode, self.mpprcFile) self.logger.debug("Clean script path successfully.")
def cleanRemoteOsUser(self): """ function: Clean remote os user input : NA output: NA """ # check if local mode if (self.localMode): return if (not self.deleteUser): # clean static config file 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 # get other nodes hostName = DefaultValue.GetHostIpOrName() otherNodes = self.clusterInfo.getClusterNodeNames() for otherNode in otherNodes: if (otherNode == hostName): otherNodes.remove(otherNode) # clean remote user self.logger.log("Deleting remote OS user.") cmd = "%s -U %s -l %s" % (OMCommand.getLocalScript( "Local_Clean_OsUser"), self.user, self.localLog) self.logger.debug("Command for deleting remote OS user: %s" % cmd) DefaultValue.execCommandWithMode(cmd, "delete OS user", self.sshTool, self.localMode, self.mpprcFile, otherNodes) self.logger.log("Successfully deleted remote OS user.") if (self.deleteGroup): # clean remote group self.logger.debug("Deleting remote 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 remote OS group: %s" % cmd) status = self.sshTool.getSshStatusOutput(cmd, otherNodes, self.mpprcFile)[0] outputMap = self.sshTool.parseSshOutput(otherNodes) for node in status.keys(): if (status[node] != DefaultValue.SUCCESS): self.logger.log((outputMap[node]).strip("\n")) self.logger.debug("Deleting remote group is completed.")
def cleanDirectory(self): """ function: clean install/instance/temp dirs input : NA output: NA """ # clean instance path hostName = DefaultValue.GetHostIpOrName() dbNodeInfo = self.clusterInfo.getDbNodeByName(hostName) instanceDirs = [] # get DB instance for dbInst in dbNodeInfo.datanodes: instanceDirs.append(dbInst.datadir) if (len(dbInst.ssdDir) != 0): instanceDirs.append(dbInst.ssdDir) # clean all instances if (len(instanceDirs) > 0): if (os.path.exists(instanceDirs[0]) and len(os.listdir(instanceDirs[0])) == 0): self.CleanInstanceDir() else: self.logger.debug("Instance directory [%s] is not empty. " "Skip to delete instance's directory." % instanceDirs[0]) else: self.logger.debug("Instance's directory is not been found. " "Skip to delete instance's directory.") # clean install path if (os.path.exists(self.clusterInfo.appPath)): self.logger.log("Deleting the installation directory.") cmd = "rm -rf '%s'" % self.clusterInfo.appPath self.logger.debug( "Command for deleting the installation path: %s" % cmd) DefaultValue.execCommandWithMode(cmd, "delete install path", self.sshTool, self.localMode, self.mpprcFile) self.logger.log("Successfully deleted the installation directory.") # clean tmp dir self.logger.log("Deleting the temporary directory.") tmpDir = DefaultValue.getTmpDir(self.user, self.xmlFile) cmd = "rm -rf '%s'; rm -rf /tmp/gs_checkos; rm -rf /tmp/gs_virtualip" \ % tmpDir self.logger.debug("Command for deleting the temporary directory: %s" % cmd) DefaultValue.execCommandWithMode(cmd, "delete the temporary directory", self.sshTool, self.localMode, self.mpprcFile) self.logger.log("Successfully deleted the temporary directory.")
def deleteTempFileForUninstall(self): """ function: Rollback install ,delete temporary file input : NA output: NA """ # Deleting temporary file self.context.logger.debug("Deleting temporary file.") tmpFile = "/tmp/temp.%s" % self.context.user cmd = g_file.SHELL_CMD_DICT["deleteFile"] % (tmpFile, tmpFile) DefaultValue.execCommandWithMode(cmd, "delete temporary file", self.context.sshTool, self.context.isSingle) self.context.logger.debug("Successfully deleted temporary file.")
def checkPreInstall(self, user, flag, nodes=None): """ function: check if have done preinstall on given nodes input : user, nodes output: NA """ if nodes is None: nodes = [] try: cmd = "%s -U %s -t %s" % ( OMCommand.getLocalScript("Local_Check_PreInstall"), user, flag) DefaultValue.execCommandWithMode(cmd, "check preinstall", self.sshTool, self.localMode or self.isSingle, "", nodes) except Exception as e: raise Exception(str(e))
def UninstallApp(self): """ function: Uninstall application input : NA output: NA """ self.logger.log("Uninstalling application.", "addStep") cmd = "%s -R '%s' -U %s -l %s -T" % ( OMCommand.getLocalScript("Local_Uninstall"), self.clusterInfo.appPath, self.user, self.localLog) self.logger.debug("Command for Uninstalling: %s" % cmd) # clean application DefaultValue.execCommandWithMode(cmd, "uninstall application", self.sshTool, self.localMode, self.mpprcFile) self.logger.log("Successfully uninstalled application.", "constant")
def CleanStaticConfFile(self): """ function: clean static conf file input : NA output: NA """ self.logger.debug("Deleting static configuration file.", "addStep") try: cmd = "rm -rf '%s'/bin " % self.clusterInfo.appPath # delete bin dir in GAUSSHOME DefaultValue.execCommandWithMode( cmd, "delete cluster static configuration file.", self.sshTool, self.localMode, self.mpprcFile) except Exception as e: self.logger.exitWithError(str(e)) self.logger.debug("Successfully deleted static configuration file.", "constant")
def deleteSymbolicAppPath(self): """ function: delete symbolic app path input : NA output : NA """ self.context.logger.debug("Delete symbolic link $GAUSSHOME.") versionFile = VersionInfo.get_version_file() commitid = VersionInfo.get_version_info(versionFile)[2] cmd = "rm -rf %s" % self.context.clusterInfo.appPath self.context.clusterInfo.appPath = \ self.context.clusterInfo.appPath + "_" + commitid DefaultValue.execCommandWithMode(cmd, "Delete symbolic link", self.context.sshTool, self.context.isSingle, self.context.mpprcFile) self.context.logger.debug( "Successfully delete symbolic link $GAUSSHOME, cmd: %s." % cmd)
def CleanRackFile(self): """ function: clean rack information file input : NA output: NA """ gp_home = DefaultValue.getEnv("GPHOME") if os.path.exists(gp_home): gp_home = os.path.realpath(gp_home) rack_conf_file = os.path.realpath( os.path.join(gp_home, "script/gspylib/etc/conf/rack_info.conf")) if os.path.isfile(rack_conf_file): cmd = "rm -f %s" % rack_conf_file DefaultValue.execCommandWithMode(cmd, "Deleted rack information file.", self.sshTool, self.localMode, mpprcFile=self.mpprcFile) self.logger.debug("Successfully deleted rack information file.")
def setHostIpEnv(self): """ function: set host ip env input : NA output : NA """ self.context.logger.log("Setting pssh path", "addStep") try: # remove HOST_IP info with /etc/profile and environ cmd = "sed -i '/^export[ ]*HOST_IP=/d' /etc/profile" DefaultValue.execCommandWithMode( cmd, "set host_ip env.", self.context.sshTool, self.context.localMode or self.context.isSingle) if "HOST_IP" in os.environ.keys(): os.environ.pop("HOST_IP") except Exception as e: raise Exception(str(e)) self.context.logger.log("Successfully set core path.", "constant")
def cleanOtherNodesEnvSoftware(self): """ function: clean other nodes environment software and variable input : NA output: NA """ # check if local mode if self.localMode: return self.logger.log("Deleting software packages " "and environmental variables of other nodes.") try: # get other nodes hostName = DefaultValue.GetHostIpOrName() otherNodes = self.clusterInfo.getClusterNodeNames() for otherNode in otherNodes: if (otherNode == hostName): otherNodes.remove(otherNode) self.logger.debug( "Deleting environmental variables of nodes: %s." % otherNodes) # clean $GAUSS_ENV if (not self.deleteUser): cmd = "%s -t %s -u %s -l '%s' -X '%s'" % ( OMCommand.getLocalScript("Local_UnPreInstall"), ACTION_CLEAN_GAUSS_ENV, self.user, self.localLog, self.xmlFile) self.logger.debug("Command for deleting $GAUSS_ENV: %s" % cmd) DefaultValue.execCommandWithMode(cmd, "delete $GAUSS_ENV", self.sshTool, self.localMode, self.mpprcFile, otherNodes) cmd = "%s -t %s -u %s -l '%s' -X '%s'" % ( OMCommand.getLocalScript("Local_UnPreInstall"), ACTION_CLEAN_TOOL_ENV, self.user, self.localLog, self.xmlFile) self.logger.debug( "Command for deleting environmental variables: %s" % cmd) DefaultValue.execCommandWithMode(cmd, "delete environment variables", self.sshTool, self.localMode, self.mpprcFile, otherNodes) except Exception as e: self.logger.logExit(str(e)) self.logger.log("Successfully deleted software packages " "and environmental variables of other nodes.")
def updateHbaConfig(self): """ function: config Hba instance input : NA output: NA """ self.context.logger.log("Configuring pg_hba on all nodes.") # Configuring pg_hba cmd = "source %s;" % self.context.mpprcFile cmd += "%s -U %s -X '%s' -l '%s' " % ( OMCommand.getLocalScript("Local_Config_Hba"), self.context.user, self.context.xmlFile, self.context.localLog) self.context.logger.debug("Command for configuring Hba instance: %s" % cmd) DefaultValue.execCommandWithMode(cmd, "config Hba instance", self.context.sshTool, self.context.isSingle) self.context.logger.debug("Successfully configured HBA.")
def setPssh(self): """ function: set pssh input : NA output : NA """ if "HOST_IP" in os.environ.keys(): return self.context.logger.log("Setting pssh path", "addStep") try: pssh_path = os.path.join(os.path.dirname(__file__), "../../../gspylib/pssh/bin/pssh") pscp_path = os.path.join(os.path.dirname(__file__), "../../../gspylib/pssh/bin/pscp") psshlib_path = os.path.join( os.path.dirname(__file__), "../../../gspylib/pssh/bin/TaskPool.py") dest_path = "/usr/bin/" secbox_path = "/var/chroot/usr/bin/" cmd = "cp %s %s %s %s" % (pssh_path, pscp_path, psshlib_path, dest_path) cmd += \ " && chmod %s %s/pssh && chmod %s %s/pscp " \ "&& chmod %s %s/TaskPool.py" % ( DefaultValue.MAX_DIRECTORY_MODE, dest_path, DefaultValue.MAX_DIRECTORY_MODE, dest_path, DefaultValue.MAX_DIRECTORY_MODE, dest_path) # Set pssh and pscp path to secbox environment in dwsMode if (os.path.exists('/var/chroot/') and os.path.exists('/rds/datastore/')): cmd += " && cp %s %s %s %s" % (pssh_path, pscp_path, psshlib_path, secbox_path) cmd += " && chmod %s %s/pssh && chmod %s %s/pscp " \ "&& chmod %s %s/TaskPool.py" % ( DefaultValue.MAX_DIRECTORY_MODE, secbox_path, DefaultValue.MAX_DIRECTORY_MODE, secbox_path, DefaultValue.MAX_DIRECTORY_MODE, secbox_path) DefaultValue.execCommandWithMode( cmd, "set pssh file.", self.context.sshTool, self.context.localMode or self.context.isSingle) except Exception as e: raise Exception(str(e)) self.context.logger.log("Successfully set pssh path.", "constant")
def checkUninstall(self): """ function: Check uninstall input : NA output: NA """ # Checking uninstallation self.logger.log("Checking uninstallation.", "addStep") # use check uninstall to check every nodes cmd = "%s -R '%s' -U %s -l %s" % ( OMCommand.getLocalScript("Local_Check_Uninstall"), self.clusterInfo.appPath, self.user, self.localLog) # check if need to clean instance if (self.cleanInstance): cmd += " -d" self.logger.debug("Command for checking uninstallation: " + cmd) DefaultValue.execCommandWithMode(cmd, "check uninstallation.", self.sshTool, self.localMode, self.mpprcFile) self.logger.log("Successfully checked uninstallation.", "constant")
def cleanNodeConfig(self, nodes=None, datadirs=None): """ function: Clean instance input : nodes, datadirs output: NA """ self.logger.log("Deleting instances from all nodes.") if nodes is None: nodes = [] if datadirs is None: datadirs = [] cmdParam = "" for datadir in datadirs: cmdParam += " -D %s " % datadir cmd = "%s -U %s %s -l %s" % (OMCommand.getLocalScript( "Local_Clean_Instance"), self.user, cmdParam, self.localLog) DefaultValue.execCommandWithMode(cmd, "clean instance", self.sshTool, self.localMode or self.isSingle, "", nodes) self.logger.log("Successfully deleted instances from all nodes.")
def checkUnPreInstall(self): """ function: check whether do uninstall before unpreinstall input : NA output: NA """ self.logger.log("Checking unpreinstallation.") if not self.localMode: DefaultValue.checkAllNodesMpprcFile( self.clusterInfo.getClusterNodeNames(), self.clusterInfo.appPath, self.mpprcFile) cmd = "%s -t %s -u %s -l '%s' -X '%s'" % ( OMCommand.getLocalScript("Local_UnPreInstall"), ACTION_CHECK_UNPREINSTALL, self.user, self.localLog, self.xmlFile) self.logger.debug("Command for checking unpreinstall: %s" % cmd) # check if do postuninstall in all nodes DefaultValue.execCommandWithMode(cmd, "check unpreinstall", self.sshTool, self.localMode, self.mpprcFile) self.logger.log("Successfully checked unpreinstallation.")