def __init__(self, installPath, nodename, datadirs): """ Constructor """ self.installPath = installPath self.nodename = nodename self.datadirs = datadirs self.__user = "" self.__group = "" self.__logDir = DefaultValue.getOMLogPath(DefaultValue.GURRENT_DIR_FILE, "", installPath)
def checkParameter(): """ Check parameter for create os user """ if (g_opts.userInfo == ""): GaussLog.exitWithError("Parameter input error, need '-U' parameter.") strList = g_opts.userInfo.split(":") if (len(strList) != 2): GaussLog.exitWithError("Parameter input error: -U " + g_opts.userInfo) if (strList[0] == "" or strList[1] == ""): GaussLog.exitWithError("Parameter input error: -U " + g_opts.userInfo) g_opts.user = strList[0] g_opts.group = strList[1] if (g_opts.logFile == ""): g_opts.logFile = DefaultValue.getOMLogPath(DefaultValue.DEFAULT_LOG_FILE, g_opts.user, "") if (not os.path.isabs(g_opts.logFile)): GaussLog.exitWithError("Parameter input error, log path need absolute path.")
try: time_out = int(value) except Exception, e: GaussLog.exitWithError("Parameter input error: %s" % str(e)) elif (key == "-U"): user = value elif (key == "-l"): logFile = value else: GaussLog.exitWithError("Parameter input error, unknown options %s." % key) if (user == ""): GaussLog.exitWithError("Parameter input error, need '-U' parameter.") if (logFile == ""): logFile = DefaultValue.getOMLogPath(DefaultValue.DEFAULT_LOG_FILE, user, "") writePid(user) global g_logger g_logger = GaussLog(logFile) if (time_out <= 0): time_out = 1800 endTime = datetime.now() + timedelta(seconds=time_out) connList = ClusterCommand.readCooConnections(user) if (len(connList) == 0): raise Exception("There is no coordinator to connect!") ip = connList[0][0] port = connList[0][1]
usage() sys.exit(0) elif (key == "-X"): confFile = value elif (key == "-l"): logFile = value elif (key == "--target"): target = value else: GaussLog.exitWithError("Parameter input error, unknown options %s." % key) if (not os.path.isabs(confFile)): GaussLog.exitWithError("Parameter input error, configure file need absolute path.") if (logFile == ""): logFile = DefaultValue.getOMLogPath(DefaultValue.DEFAULT_LOG_FILE, "", "", confFile) if (not os.path.isabs(logFile)): GaussLog.exitWithError("Parameter input error, log file need absolute path.") config = DilatationConfig(logFile, "", confFile) if (target == "clean"): config.clean() elif (target == "restore"): config.restore() elif (target == "config"): config.config() elif (target == "check"): config.check() elif (target == "localstart"): config.localStart()
usage() sys.exit(0) elif (key == "-U"): g_clusterUser = value elif (key == "-P"): dbInitParams.append(value) elif (key == "-G"): gtmInitParams.append(value) elif (key == "-l"): logFile = os.path.abspath(value) # check if user exist and is the right user PlatformCommand.checkUser(g_clusterUser) if (logFile == ""): logFile = DefaultValue.getOMLogPath(DefaultValue.DEFAULT_LOG_FILE, g_clusterUser, "") # Init logger global g_logger g_logger = GaussLog(logFile, "InitInstance") try: dbInit = initDbNode(dbInitParams, gtmInitParams) dbInit.run() g_logger.log("Init instances on node[%s] successfully!" % socket.gethostname()) g_logger.closeLog() sys.exit(0) except Exception, e: g_logger.logExit(str(e)) if __name__ == '__main__':