Ejemplo n.º 1
0
def get_public_network_ip(ips, public_subnet):
    """
    Given a public subnet, chose the one IP from the remote host that exists
    within the subnet range.
    """
    for ip in ips:
        if net.ip_in_subnet(ip, public_subnet):
            return ip
    msg = "IPs (%s) are not valid for any of subnet specified %s" % (str(ips), str(public_subnet))
    raise RuntimeError(msg)
Ejemplo n.º 2
0
def get_public_network_ip(ips, public_subnet):
    """
    Given a public subnet, chose the one IP from the remote host that exists
    within the subnet range.
    """
    for ip in ips:
        if net.ip_in_subnet(ip, public_subnet):
            return ip
    msg = "IPs (%s) are not valid for any of subnet specified %s" % (str(ips), str(public_subnet))
    raise RuntimeError(msg)
Ejemplo n.º 3
0
 def ip_in_one_subnet(ips, subnet):
     """ ensure an ip exists in at least one subnet """
     for ip in ips:
         if net.ip_in_subnet(ip, subnet):
             return True
     return False
Ejemplo n.º 4
0
 def test_correct_for_10_0_0_255(self, ip):
     assert net.ip_in_subnet(ip, "10.0.0.0/16")
Ejemplo n.º 5
0
 def test_false_for_24_subnets(self, ip):
     assert net.ip_in_subnet(ip, "10.9.1.0/24") is False
Ejemplo n.º 6
0
 def test_true_for_16_subnets(self, ip):
     assert net.ip_in_subnet(ip, "10.9.1.0/16") is True
Ejemplo n.º 7
0
 def test_false_for_172_addresses(self, ip):
     assert net.ip_in_subnet(ip, "172.3.0.0/16") is False
Ejemplo n.º 8
0
 def test_false_for_255_addresses(self, ip):
     assert net.ip_in_subnet(ip, "10.9.1.0/16") is False
Ejemplo n.º 9
0
 def test_false_for_10_0_0_255(self, ip):
     assert net.ip_in_subnet(ip, "10.2.0.0/24") is False
Ejemplo n.º 10
0
 def ip_in_one_subnet(ips, subnet):
     """ ensure an ip exists in at least one subnet """
     for ip in ips:
         if net.ip_in_subnet(ip, subnet):
             return True
     return False
Ejemplo n.º 11
0
 def test_false_for_24_subnets(self, ip):
     assert net.ip_in_subnet(ip, "10.9.1.0/24") is False
Ejemplo n.º 12
0
 def test_true_for_16_subnets(self, ip):
     assert net.ip_in_subnet(ip, "10.9.1.0/16") is True
Ejemplo n.º 13
0
 def test_false_for_172_addresses(self, ip):
     assert net.ip_in_subnet(ip, "172.3.0.0/16") is False
Ejemplo n.º 14
0
 def test_false_for_255_addresses(self, ip):
     assert net.ip_in_subnet(ip, "10.9.1.0/16") is False
Ejemplo n.º 15
0
 def test_false_for_10_0_0_255(self, ip):
     assert net.ip_in_subnet(ip, "10.2.0.0/24") is False
Ejemplo n.º 16
0
 def test_correct_for_10_0_0_255(self, ip):
     assert net.ip_in_subnet(ip, "10.0.0.0/16")