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