diff --git a/src/manager/om/script/gs_expansion b/src/manager/om/script/gs_expansion index 83696f78a..aa05816b3 100644 --- a/src/manager/om/script/gs_expansion +++ b/src/manager/om/script/gs_expansion @@ -134,6 +134,7 @@ General options: GaussLog.exitWithError(ErrorCode.GAUSS_357["GAUSS_35701"] % "-h") clusterInfo = ExpansipnClusterInfo() + self.clusterInfo = clusterInfo hostNameIpDict = clusterInfo.initFromXml(self.xmlFile) clusterDict = clusterInfo.getClusterDirectorys() backIpList = clusterInfo.getClusterBackIps() diff --git a/src/manager/om/script/impl/expansion/ExpansionImpl.py b/src/manager/om/script/impl/expansion/ExpansionImpl.py index 75dfd778e..075bac3ec 100644 --- a/src/manager/om/script/impl/expansion/ExpansionImpl.py +++ b/src/manager/om/script/impl/expansion/ExpansionImpl.py @@ -588,25 +588,34 @@ retry for %s times" % start_retry_num) """ self.logger.debug("Start to generate and send cluster static file.\n") - curHostName = socket.gethostname() - command = "gs_om -t generateconf -X %s --distribute" % self.context.xmlFile - sshTool = SshTool([curHostName]) - resultMap, outputCollect = sshTool.getSshStatusOutput(command, - [curHostName], self.envFile) - self.logger.debug(outputCollect) - self.cleanSshToolFile(sshTool) + primaryHost = self.getPrimaryHostName() + result = self.commonGsCtl.queryOmCluster(primaryHost, self.envFile) + for nodeName in self.context.nodeNameList: + nodeInfo = self.context.clusterInfoDict[nodeName] + nodeIp = nodeInfo["backIp"] + dataNode = nodeInfo["dataNode"] + exist_reg = r"(.*)%s[\s]*%s(.*)%s(.*)" % (nodeName, nodeIp, dataNode) + if not re.search(exist_reg, result) and nodeIp not in self.context.newHostList: + self.logger.debug("The node ip [%s] will not be added to cluster." % nodeIp) + dbNode = self.context.clusterInfo.getDbNodeByName(nodeName) + self.context.clusterInfo.dbNodes.remove(dbNode) + + toolPath = self.context.clusterInfoDict["toolPath"] + appPath = self.context.clusterInfoDict["appPath"] - nodeNameList = self.context.nodeNameList - - for hostName in nodeNameList: - hostSsh = SshTool([hostName]) - toolPath = self.context.clusterInfoDict["toolPath"] - appPath = self.context.clusterInfoDict["appPath"] - srcFile = "%s/script/static_config_files/cluster_static_config_%s" \ - % (toolPath, hostName) + static_config_dir = "%s/script/static_config_files" % toolPath + if not os.path.exists(static_config_dir): + os.makedirs(static_config_dir) + + for dbNode in self.context.clusterInfo.dbNodes: + hostName = dbNode.name + staticConfigPath = "%s/script/static_config_files/cluster_static_config_%s" % \ + (toolPath, hostName) + self.context.clusterInfo.saveToStaticConfig(staticConfigPath, dbNode.id) + srcFile = staticConfigPath if not os.path.exists(srcFile): - GaussLog.exitWithError("Generate static file [%s] not found." \ - % srcFile) + GaussLog.exitWithError("Generate static file [%s] not found." % srcFile) + hostSsh = SshTool([hostName]) targetFile = "%s/bin/cluster_static_config" % appPath hostSsh.scpFiles(srcFile, targetFile, [hostName], self.envFile) self.cleanSshToolFile(hostSsh)