Ejemplo n.º 1
0
    def cleanGaussEnv(self):
        """
        function: clean $GAUSS_ENV
        input : NA
        output: NA
        """
        self.logger.debug("Cleaning $GAUSS_ENV.")

        # check if user profile exist
        if (self.userProfile is not None and self.userProfile != ""):
            userProfile = self.userProfile
        else:
            userProfile = "/home/%s/.bashrc" % self.user

        if (not os.path.exists(userProfile)):
            self.logger.debug("The %s does not exist." % userProfile +
                              " Please skip to clean $GAUSS_ENV.")
            return
        # clean user's environmental variable
        DefaultValue.cleanUserEnvVariable(userProfile,
                                          cleanGAUSS_WARNING_TYPE=True)

        # clean $GAUSS_ENV
        envContent = "^\\s*export\\s*GAUSS_ENV=.*$"
        g_file.deleteLine(userProfile, envContent)

        self.logger.debug("Cleaned $GAUSS_ENV.")
Ejemplo n.º 2
0
    def cleanEnv(self):
        """
        function: clean envriment variable
        """
        self.logger.debug("Begin clean envrionment variable")
        if not self.userProfile:
            self.logger.logExit("Clean Env failed: can not get user profile.")
        for comp in self.clusterComponent:
            comp.cleanEnv(self.userProfile)

        # clean user's environment variable
        self.logger.debug("Clean user environment variable.")
        DefaultValue.cleanUserEnvVariable(self.userProfile,
                                          cleanGAUSS_WARNING_TYPE=True)
        # clean GAUSS_ENV
        self.logger.debug("Clean GAUSS_ENV.")
        g_file.deleteLine(self.userProfile, "^\\s*export\\s*GAUSS_ENV=.*$")
        self.logger.debug("Clean envrionment variable successfully.")
Ejemplo n.º 3
0
    def cleanLocalNodeEnvSoftware(self):
        """
        function: clean local node environment software and variable
        input : NA
        output: NA
        in this function, Gauss-MPPDB* & sctp_patch is came from R5 upgrade R7
        """
        self.logger.log("Deleting software packages "
                        "and environmental variables of the local node.")
        try:
            self.clusterToolPath = DefaultValue.getClusterToolPath()

            # clean local node environment software
            path = "%s/%s" % (self.clusterToolPath, PSSHDIR)
            g_file.removeDirectory(path)
            path = "%s/upgrade.sh" % self.clusterToolPath
            g_file.removeFile(path)
            path = "%s/version.cfg" % self.clusterToolPath
            g_file.removeFile(path)
            path = "%s/GaussDB.py" % self.clusterToolPath
            g_file.removeFile(path)
            path = "%s/libcgroup" % self.clusterToolPath
            g_file.removeDirectory(path)
            path = "%s/unixodbc" % self.clusterToolPath
            g_file.removeDirectory(path)
            path = "%s/server.key.cipher" % self.clusterToolPath
            g_file.removeFile(path)
            path = "%s/server.key.rand" % self.clusterToolPath
            g_file.removeFile(path)
            path = "%s/%s*" % (self.clusterToolPath, VersionInfo.PRODUCT_NAME)
            g_file.removeDirectory(path)
            path = "%s/server.key.rand" % self.clusterToolPath
            g_file.removeFile(path)
            path = "%s/Gauss*" % (self.clusterToolPath)
            g_file.removeDirectory(path)
            path = "%s/sctp_patch" % (self.clusterToolPath)
            g_file.removeDirectory(path)
            self.logger.debug(
                "Deleting environmental software of local nodes.")

            # clean local node environment variable
            cmd = "(if [ -s '%s' ]; then " % PROFILE_FILE
            cmd += "sed -i -e '/^export GPHOME=%s$/d' %s " % (
                self.clusterToolPath.replace('/', '\/'), PROFILE_FILE)
            cmd += \
                "-e '/^export PATH=\$GPHOME\/pssh-2.3.1\/bin:" \
                "\$GPHOME\/script:\$PATH$/d' %s " % PROFILE_FILE
            cmd += \
                "-e '/^export PATH=\$GPHOME\/script\/gspylib\/pssh\/bin:" \
                "\$GPHOME\/script:\$PATH$/d' %s " % PROFILE_FILE
            cmd += \
                "-e '/^export LD_LIBRARY_PATH=\$GPHOME\/script" \
                "\/gspylib\/clib:\$LD_LIBRARY_PATH$/d' %s " % PROFILE_FILE
            cmd += \
                "-e '/^export LD_LIBRARY_PATH=\$GPHOME\/lib:" \
                "\$LD_LIBRARY_PATH$/d' %s " % PROFILE_FILE
            cmd += \
                "-e '/^export PATH=\/root\/gauss_om\/%s\/script:" \
                "\$PATH$/d' %s " % (self.user, PROFILE_FILE)
            cmd += \
                "-e '/^export PYTHONPATH=\$GPHOME\/lib$/d' %s; fi) " \
                % PROFILE_FILE
            self.logger.debug("Command for deleting environment variable: %s" %
                              cmd)
            (status, output) = subprocess.getstatusoutput(cmd)
            if (status != 0):
                self.logger.logExit(ErrorCode.GAUSS_502["GAUSS_50207"] %
                                    "environment variables of the local node" +
                                    " Error: \n%s" % output)

            # check if user profile exist
            userProfile = ""
            if (self.mpprcFile is not None and self.mpprcFile != ""):
                userProfile = self.mpprcFile
            else:
                userProfile = "/home/%s/.bashrc" % self.user
            if (not os.path.exists(userProfile)):
                self.logger.debug("The %s does not exist. "
                                  "Please skip to clean $GAUSS_ENV." %
                                  userProfile)
                return
            # clean user's environmental variable
            DefaultValue.cleanUserEnvVariable(userProfile,
                                              cleanGAUSS_WARNING_TYPE=True)

            # clean $GAUSS_ENV
            if (not self.deleteUser):
                envContent = "^\\s*export\\s*GAUSS_ENV=.*$"
                g_file.deleteLine(userProfile, envContent)
                self.logger.debug("Command for deleting $GAUSS_ENV: %s" % cmd,
                                  "constant")

        except Exception as e:
            self.logger.logExit(str(e))
        self.logger.log("Successfully deleted software packages "
                        "and environmental variables of the local nodes.")