예제 #1
0
    def doCheck(self):
        ipList = []
        routingBinary = self.getBinaryRouting(self.routing)
        if g_Platform.isPlatFormEulerOSOrRHEL7X():
            cmd = "/sbin/ifconfig -a |grep -E '\<inet\>'| awk '{print $2}'"
        else:
            cmd = "/sbin/ifconfig -a |grep 'inet addr'|" \
                  " awk '{print $2}'| awk -F ':' '{print $2}'"
        output = SharedFuncs.runShellCmd(cmd)
        for eachLine in output.split('\n'):
            if (SharedFuncs.validate_ipv4(eachLine)):
                maskAddr = SharedFuncs.getMaskByIP(eachLine)
                ipMask = "%s:%s" % (eachLine, maskAddr)
                ipList.append(ipMask)
        self.result.raw = "Routing: %s [bit]%s\nlocalIP:\n%s" % (
            self.routing, routingBinary, "\n".join(ipList))

        commIP = []
        for ipMask in ipList:
            ipBinary = self.getBinaryRouting(ipMask)
            if (ipBinary == routingBinary):
                commIP.append(ipMask)

        if (len(commIP) > 1):
            self.result.rst = ResultStatus.WARNING
        else:
            self.result.rst = ResultStatus.OK
        self.result.val = "Business network segment IP: " + ", ".join(commIP)
예제 #2
0
 def __getLocalIP(self, nodeList):
     for node in nodeList:
         if (SharedFuncs.is_local_node(node) and SharedFuncs.validate_ipv4(
                 node)):
             self.ipAddr = node
             return