Пример #1
0
 def _in_network(inter_ipv4, networks):
     '''Ensures that the interface's address is in networks
     '''
     # iterate over the network list
     for network in networks:
         # check if the interface's IPv4 address is in the network
         if common.compare_ipv4(inter_ipv4, network):
             return True
     return False
Пример #2
0
    def test_compare_ipv4(self):
        '''test compare_ipv4 returns valid results
        '''
        for i in range(len(self.tests)):
            ip1 = self.tests[i]['ip1']
            ip2 = self.tests[i]['ip2']
            result = self.tests[i]['result']
            assert common.compare_ipv4(ip1, ip2) == result, \
                    "compare_ipv4 failed %s test" % self.tests[i]['name']

            assert not common.compare_ipv4('10.0.100.1', '10.0.15.5/48'), \
                    "compare_ipv4 failed for invalid CIDR mask"

            assert common.compare_ipv4('10.0.15.10', '10.0.15.10/32'), \
                    "compare_ipv4 failed for & mask"

            assert common.compare_ipv4('10.0.15.10', '10.0.15.10'), \
                    "compare_ipv4 failed for identical IP address"
 def _in_network(inter_ipv4, networks):
     '''Ensures that the interface's address is in networks
     '''
     # iterate over the network list
     for network in networks:
         # check if the interface's IPv4 address is in the network
         if common.compare_ipv4(inter_ipv4, network):
             return True
     return False