Example #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)
Example #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)
Example #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
Example #4
0
 def test_correct_for_10_0_0_255(self, ip):
     assert net.ip_in_subnet(ip, "10.0.0.0/16")
Example #5
0
 def test_false_for_24_subnets(self, ip):
     assert net.ip_in_subnet(ip, "10.9.1.0/24") is False
Example #6
0
 def test_true_for_16_subnets(self, ip):
     assert net.ip_in_subnet(ip, "10.9.1.0/16") is True
Example #7
0
 def test_false_for_172_addresses(self, ip):
     assert net.ip_in_subnet(ip, "172.3.0.0/16") is False
Example #8
0
 def test_false_for_255_addresses(self, ip):
     assert net.ip_in_subnet(ip, "10.9.1.0/16") is False
Example #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
Example #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
Example #11
0
 def test_false_for_24_subnets(self, ip):
     assert net.ip_in_subnet(ip, "10.9.1.0/24") is False
Example #12
0
 def test_true_for_16_subnets(self, ip):
     assert net.ip_in_subnet(ip, "10.9.1.0/16") is True
Example #13
0
 def test_false_for_172_addresses(self, ip):
     assert net.ip_in_subnet(ip, "172.3.0.0/16") is False
Example #14
0
 def test_false_for_255_addresses(self, ip):
     assert net.ip_in_subnet(ip, "10.9.1.0/16") is False
Example #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
Example #16
0
 def test_correct_for_10_0_0_255(self, ip):
     assert net.ip_in_subnet(ip, "10.0.0.0/16")