def checkParameter():
    """
    function: 1.check input parameters
              2.check user info
              3.check os user
              4.check log file info
              5.check mpprc file path
              6.check configFile
              7.check install path
    input : NA
    output: NA
    """
    # check user info
    checkUser(g_opts.userInfo)

    # check mpprc file path
    g_opts.mpprcFile = DefaultValue.getMpprcFile()
    checkOSUser()

    # check log file info
    checkLogFile(g_opts.logFile)

    # check configFile
    checkXMLFile()

    # check install path
    checkInstallPath()
Exemple #2
0
    def setPghbaConfig(self, clusterAllIpList, user='******'):
        """
        """
        principal = None
        if (DefaultValue.checkKerberos(DefaultValue.getMpprcFile())):

            (status, output) = \
                g_OSlib.getGrepValue("-Er", "^default_realm",
                                     os.path.join(os.path.dirname(
                                         DefaultValue.getMpprcFile()),
                                         DefaultValue.FI_KRB_CONF))
            if (status != 0):
                raise Exception(ErrorCode.GAUSS_502["GAUSS_50222"] %
                                "krb5.conf" + "Error:\n%s" % output)
            principal = output.split("=")[1].strip()

        # build ip string list
        # Every 1000 records merged into one
        i = 0
        GUCParasStr = ""
        GUCParasStrList = []
        for ipAddress in clusterAllIpList:
            i += 1
            # Set the initial user and initial database access permissions
            if principal is None:
                GUCParasStr += "-h \"host    all    %s    %s/32    %s\" " % \
                               (user, ipAddress, METHOD_TRUST)
            else:
                GUCParasStr += "-h \"host    all    %s    %s/32    gss    " \
                               "include_realm=1    krb_realm=%s\" "\
                               % (user, ipAddress, principal)
            if (i % MAX_PARA_NUMBER == 0):
                GUCParasStrList.append(GUCParasStr)
                i = 0
                GUCParasStr = ""

        if (GUCParasStr != ""):
            GUCParasStrList.append(GUCParasStr)

        for parasStr in GUCParasStrList:
            self.doGUCConfig("set", parasStr, True)
Exemple #3
0
    def checkParameters(self):
        """
        function: Check input parameters
        input : NA
        output: NA
        """
        try:
            opts, args = getopt.getopt(sys.argv[1:], "t:U:R:l:X:M:T",
                                       ["help", "delete-data"])
        except getopt.GetoptError as e:
            GaussLog.exitWithError(ErrorCode.GAUSS_500["GAUSS_50000"]
                                   % str(e))

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

        for key, value in opts:
            if (key == "-U"):
                self.user = value
            elif (key == "-R"):
                self.installPath = value
            elif (key == "-l"):
                self.logFile = value
            elif (key == "--help"):
                self.usage()
                sys.exit(0)
            elif (key == "-T"):
                self.installflag = True
            elif key == "--delete-data":
                self.keepData = False
            elif key == "-M":
                self.method = value
            elif key == "-t":
                self.action = value
            else:
                GaussLog.exitWithError(ErrorCode.GAUSS_500["GAUSS_50000"]
                                       % key)

            Parameter.checkParaVaild(key, value)

        if (self.user == ""):
            GaussLog.exitWithError(ErrorCode.GAUSS_500["GAUSS_50001"]
                                   % 'U' + ".")

        if (self.installPath == ""):
            GaussLog.exitWithError(ErrorCode.GAUSS_500["GAUSS_50001"]
                                   % 'R' + ".")

        self.mpprcFile = DefaultValue.getMpprcFile()
        if (self.logFile == ""):
            self.logFile = DefaultValue.getOMLogPath(
                DefaultValue.LOCAL_LOG_FILE, self.user, self.installPath)
def checkParameter():
    """
    function: check install parameter
    input : NA
    output: NA
    """
    if g_opts.action == "":
        GaussLog.exitWithError(ErrorCode.GAUSS_500["GAUSS_50001"] % 't' + '.')

    if (g_opts.action != ACTION_INSTALL_CLUSTER
            and g_opts.action != ACTION_PREPARE_CONFIG_CLUSTER
            and g_opts.action != ACTION_INIT_INSTNACE
            and g_opts.action != ACTION_CONFIG_CLUSTER
            and g_opts.action != ACTION_START_CLUSTER
            and g_opts.action != ACTION_CLEAN_TEMP_FILE
            and g_opts.action != ACTION_BUILD_STANDBY
            and g_opts.action != ACTION_BUILD_CASCADESTANDBY):
        GaussLog.exitWithError(ErrorCode.GAUSS_500["GAUSS_50004"] % "t")

    if (g_opts.clusterConfig != "" and
            not os.path.exists(g_opts.clusterConfig)):
        GaussLog.exitWithError(ErrorCode.GAUSS_502["GAUSS_50201"]
                               % g_opts.clusterConfig)

    if (g_opts.logPath != "" and not os.path.exists(g_opts.logPath)
            and not os.path.isabs(g_opts.logPath)):
        GaussLog.exitWithError(ErrorCode.GAUSS_502["GAUSS_50219"]
                               % g_opts.logPath)

    if (g_opts.static_config_file != "" and
            not os.path.isfile(g_opts.static_config_file)):
        GaussLog.exitWithError(ErrorCode.GAUSS_502["GAUSS_50219"]
                               % g_opts.static_config_file)

    # check mpprc file path
    g_opts.mpprcFile = DefaultValue.getMpprcFile()
    g_opts.logger = GaussLog(g_opts.logFile)
    checkParameterEmpty(g_opts.user, "U")
    g_opts.installPath = os.path.normpath(g_opts.installPath)
    g_opts.installPath = os.path.realpath(g_opts.installPath)
    g_opts.logger.log("Using " + g_opts.user + ":" + g_opts.group
                      + " to install database.")
    g_opts.logger.log("Using installation program path : "
                      + g_opts.installPath)

    if g_opts.logFile == "":
        g_opts.logFile = DefaultValue.getOMLogPath(
            DefaultValue.LOCAL_LOG_FILE, g_opts.user, "",
            g_opts.clusterConfig)

    if g_opts.alarmComponent == "":
        g_opts.alarmComponent = DefaultValue.ALARM_COMPONENT_PATH
 def getPrepareKeysCmd(key_file,
                       user,
                       confFile,
                       destPath,
                       logfile,
                       userProfile="",
                       localMode=False):
     """
     function: get  etcd communication keys command
     input: key_file, user, confFile, destPath, localMode:do not scp keys
     output: NA
     """
     if (not os.path.exists(key_file)):
         raise Exception(ErrorCode.GAUSS_502["GAUSS_50201"] % key_file)
     if (not userProfile):
         userProfile = DefaultValue.getMpprcFile()
     # create the directory on all nodes
     cmd = "source %s; %s -U %s -X %s --src-file=%s --dest-path=%s -l %s" \
           % (userProfile, OMCommand.getLocalScript("Local_PrepareKeys"),
            user, confFile, key_file, destPath, logfile)
     # if local mode, only prepare keys, do not scp keys to cluster nodes
     if (localMode):
         cmd += " -L"
     return cmd