Пример #1
0
    def doCheck(self):
        parRes = ""
        flag = 0
        output = ""
        outputList, failList = self.checkSpecialChar()
        for output in outputList:
            if (output != ""):
                flag = 1
                parRes += "\nSpecial characters file: \"%s\"" % output

        outputList, errorList = self.checkErrorOwner(self.user)
        for output in outputList:
            if (output != ""):
                flag = 1
                parRes += "\nFile owner should be %s." \
                          " Incorrect owner file: \"%s\"" \
                          % (self.user, output)
        failList.extend(errorList)
        if (failList):
            flag = 1
            failList = DefaultValue.Deduplication(failList)
            parRes += "\n%s" % ("\n".join(failList))
        if (flag == 1):
            self.result.rst = ResultStatus.NG
            self.result.val = parRes
        else:
            self.result.rst = ResultStatus.OK
            self.result.val = "All files are normal."
Пример #2
0
 def checkErrorOwner(self, ownername):
     outputList = []
     failList = []
     path = ""
     for path in self.getDiskPath():
         if (not path or not os.path.isdir(path)):
             continue
         cmd = "find '%s' -iname '*' ! -user %s -print" % (path, ownername)
         (status, output) = subprocess.getstatusoutput(cmd)
         if (status == 0 and output != ""):
             pathList = output.split("\n")
             for path in pathList:
                 if (self.ignorePath(path)):
                     continue
                 outputList.append(path)
         elif (output.find("Permission denied") > 0):
             pathList = output.split("\n")
             for path in pathList:
                 if (path.find("Permission denied") > 0):
                     failList.append(path)
                     continue
                 if (self.ignorePath(path)):
                     continue
                 outputList.append(path)
     if (len(outputList) > 0):
         outputList = DefaultValue.Deduplication(outputList)
     return outputList, failList
    def perCheck(self):
        """
        function: 1.Check instance port  
                  2.Check instance IP
        input : NA
        output: NA
        """
        ipList = self.instInfo.listenIps
        ipList.extend(self.instInfo.haIps)
        portList = []
        portList.append(self.instInfo.port)
        portList.append(self.instInfo.haPort)

        ipList = DefaultValue.Deduplication(ipList)
        portList = DefaultValue.Deduplication(portList)
        # check port
        for port in portList:
            self.__checkport(port, ipList)
        # check ip
        failIps = g_network.checkIpAddressList(ipList)
        if (len(failIps) > 0):
            raise Exception(ErrorCode.GAUSS_506["GAUSS_50600"] +
                            " The IP is %s." % ",".join(failIps))
Пример #4
0
 def checkSpecialChar(self):
     outputList = []
     failList = []
     pathList = []
     paths = self.getDiskPath()
     for path in paths:
         if (not path or not os.path.isdir(path)):
             continue
         else:
             pathList.append(path)
     pool = ThreadPool(DefaultValue.getCpuSet())
     results = pool.map(self.checkSingleSpecialChar, pathList)
     pool.close()
     pool.join()
     for outlist, flist in results:
         if (outlist):
             outputList.extend(outlist)
         if (flist):
             failList.extend(flist)
     if (len(outputList) > 0):
         outputList = DefaultValue.Deduplication(outputList)
     if (failList):
         failList = DefaultValue.Deduplication(failList)
     return outputList, failList
Пример #5
0
    def getAllIps(self):
        """
        function: get all ip info from static configuration file
        input : NA
        output: NA
        """
        if (g_opts.addIps):
            self.allIps = g_opts.addIps
            return

        # get all node names
        nodenames = self.clusterInfo.getClusterNodeNames()
        for nodename in nodenames:
            nodeinfo = self.clusterInfo.getDbNodeByName(nodename)
            self.allIps += nodeinfo.backIps
            self.allIps += nodeinfo.sshIps
            for inst in nodeinfo.datanodes:
                self.allIps += inst.haIps
                self.allIps += inst.listenIps
        # get all ips. Remove the duplicates ips
        self.allIps = DefaultValue.Deduplication(self.allIps)