コード例 #1
0
ファイル: Backup.py プロジェクト: jianhuiz/cf-apps
class LocalBackup():
    '''
    classdocs
    '''   
    def __init__(self, user = "", backupDir = "", backupPara = False, backupBin = False, logFile = ""):
        '''
        Constructor
        '''
        self.backupDir = backupDir
        self.backupPara = backupPara
        self.backupBin = backupBin
        self.logFile = logFile
        
        self.installPath = ""
        self.user = user
        self.group = ""
        self.nodeInfo = None
        
        self.logger = None
        self.__hostnameFile = None
        
        ##static parameter
        self.defaultLogDir = ""
        self.logName = "gs_local_backup.log"
        self.envirName = "GAUSS_VERSION"
        self.binTarName = "binary.tar"
        self.paraTarName = "parameter.tar"
        self.hostnameFileName = "HOSTNAME"
        
    ####################################################################################
    # This is the main install flow.  
    ####################################################################################
    
    def run(self):
        '''
        check install 
        '''
        self.logger = GaussLog(self.logFile, "LocalBackup") 
        try:
            self.parseConfigFile()
            self.checkBackupDir()
            self.doBackup()
        except Exception,e:
            self.logger.closeLog()
            raise Exception(str(e))     
            
        self.logger.closeLog()
コード例 #2
0
ファイル: CheckConfig.py プロジェクト: jianhuiz/cf-apps
        elif (key == "-l"):
            logFile = os.path.abspath(value)
        elif(key == "-i"):
            if (value.isdigit()):
                instanceIds.append(int(value))
            else:
                GaussLog.exitWithError("Parameter invalid. -i %s is not digit." % value)

    # check if user exist and is the right user
    PlatformCommand.checkUser(g_clusterUser)

    #check log dir
    if (logFile == ""):
        logFile = DefaultValue.getOMLogPath(DefaultValue.DEFAULT_LOG_FILE, g_clusterUser, "", "")

    #Init logger
    global g_logger
    g_logger = GaussLog(logFile, "CheckConfig")
    try:
        checker = CheckNodeEnv(cooParams, dataParams, instanceIds)
        checker.run()

        g_logger.log("Check config on node[%s] successfully!" % socket.gethostname())
        g_logger.closeLog()
        sys.exit(0)
    except Exception, e:
        g_logger.logExit(str(e))

if __name__ == '__main__':
    main()
コード例 #3
0
ファイル: GaussStat.py プロジェクト: jianhuiz/cf-apps
        elif (key == "-p"):
            installPath = value.strip()
        elif (key == "-u"):
            user = value.strip()
        elif (key == "-c"):
            localPort = value.strip()
        elif (key == "-l" or key == "--logpath"):
            logFile = value.strip()
        elif (key == "-d" or key == "--detail"):
            detail = True
        else:
            GaussLog.exitWithError("Unknown parameter for GaussStat: %s" % key)
    
    if(not os.path.exists(installPath) or user == "" or localPort == ""):
        usage()
        GaussLog.exitWithError("indispensable paramter missed.")
        
    if(logFile == ""):
        logFile = "%s/om/gaussdb_local.log" % DefaultValue.getUserLogDirWithUser(user)
        
    logger = GaussLog(logFile, "GaussStat")
        
    try:  
        stat = GaussStat(installPath, user, localPort, logger, detail)
        stat.collect()
        stat.outPut()
    except Exception, e:
        logger.logExit("Can't get statistics, reason: %s" % str(e))
        
    logger.closeLog()