def checkIpAddressList(self, ipAddressList): """ function : Check the connection status of network. input : [] output : [] """ global g_failedAddressList g_failedAddressList = [] parallelTool.parallelExecute(self.executePingCmd, ipAddressList) return g_failedAddressList
def checkPortAndIp(self): """ function: Check instance port and IP input : NA output: NA """ self.logger.log("Checking instance port and IP.") components = self.etcdCons + self.cmCons + self.gtmCons \ + self.cnCons + self.dnCons try: # config instance in paralle parallelTool.parallelExecute(self.checkIpAndPort, components) except Exception as e: self.logger.logExit(str(e)) self.logger.log("Successfully checked instance port and IP.")
def configHba(self): """ function: set hba config input : NA output: NA """ self.getAllIps() componentList = self.dnCons # Determine whether this node containing CN, DN instance if (len(componentList) == 0): return try: parallelTool.parallelExecute(self.__configAnInstance, componentList) self.logger.log("Successfully configured all instances" " on node[%s]." % DefaultValue.GetHostIpOrName()) except Exception as e: raise Exception(str(e))
def __modifyConfig(self): """ function: Modify all instances on loacl node input : NA output: NA """ self.logger.log("Modifying Alarm configuration.") tmpAlarmDict = getAlarmDict(self.configType, self.alarmComponent) # init alarmItem.conf file configFile = "%s/bin/alarmItem.conf" % self.clusterInfo.appPath ClusterInstanceConfig.setConfigItem(DefaultValue.INSTANCE_ROLE_CMAGENT, "", configFile, tmpAlarmDict) componentList = self.dnCons if len(componentList) == 0: return try: # config instance in paralle parallelTool.parallelExecute(self.configInst, componentList) except Exception as e: self.logger.logExit(str(e))
def initNodeInst(self, vc_mode=False): """ function : Init all instance on local node input : NA output : NA """ self.logger.log("Initializing instance.") if not vc_mode: components = self.etcdCons + self.cmCons + self.gtmCons\ + self.cnCons + self.dnCons else: # just init dn instance components = self.dnCons try: # config instance in paralle parallelTool.parallelExecute(self.initInstance, components) except Exception as e: self.logger.logExit(str(e)) self.logger.log("Successfully init instance information.")
def cleanGphomeScript(self): """ function: clean gphome script input : NA output: NA """ try: if not self.clean_gphome: return global gphome gphome = os.path.normpath( self.getItemValueFromXml("gaussdbToolPath")) cmd = "rm -rf %s/*" % gphome if "HOST_IP" in os.environ.keys(): # Agent Mode if self.localMode: # clean gphome in local mode self.verifyCleanGphome() (status, output) = subprocess.getstatusoutput(cmd) if status != 0: raise Exception(ErrorCode.GAUSS_514["GAUSS_51400"] % cmd + " Error:\n%s" % output) self.logger.logExit("Successfully clean gphome locally.") else: # clean gphome with specified node self.sshpwd = self.verifyCleanGphome(self.localMode) parallelTool.parallelExecute(self.sshExecWithPwd, self.clean_host) self.logger.logExit( "Successfully clean gphome on node %s." % self.clean_host) else: # SSH Mode SSH_TRUST = True self.nodeList = self.getItemValueFromXml("nodeNames").split( ",") if len(self.nodeList) == 0: raise Exception(ErrorCode.GAUSS_502["GAUSS_50203"] % "nodeList") results = parallelTool.parallelExecute( self.checkAuthentication, self.nodeList) for (key, value) in results: if (not key): self.logger.log( "SSH trust has not been created. \ \nFor node : %s. Only clean local node." % value, "constant") SSH_TRUST = False break if SSH_TRUST and not self.localMode: # SSH trust has been created self.verifyCleanGphome() parallelTool.parallelExecute(self.sshExecWithPwd, self.nodeList) if not SSH_TRUST or self.localMode: # SSH trust has not been created # which means clean gphome locally self.verifyCleanGphome() (status, output) = subprocess.getstatusoutput(cmd) if status != 0: raise Exception(ErrorCode.GAUSS_514["GAUSS_51400"] % cmd + " Error:\n%s" % output) self.logger.logExit("Successfully clean gphome.") except Exception as e: self.logger.logExit(str(e))