コード例 #1
0
ファイル: new.py プロジェクト: thesues/ceph-deploy
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
ファイル: new.py プロジェクト: thesues/ceph-deploy
 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
ファイル: test_net.py プロジェクト: hugb/ceph-deploy
 def test_false_for_24_subnets(self, ip):
     assert net.ip_in_subnet(ip, "10.9.1.0/24") is False
コード例 #12
0
ファイル: test_net.py プロジェクト: hugb/ceph-deploy
 def test_true_for_16_subnets(self, ip):
     assert net.ip_in_subnet(ip, "10.9.1.0/16") is True
コード例 #13
0
ファイル: test_net.py プロジェクト: hugb/ceph-deploy
 def test_false_for_172_addresses(self, ip):
     assert net.ip_in_subnet(ip, "172.3.0.0/16") is False
コード例 #14
0
ファイル: test_net.py プロジェクト: hugb/ceph-deploy
 def test_false_for_255_addresses(self, ip):
     assert net.ip_in_subnet(ip, "10.9.1.0/16") is False
コード例 #15
0
ファイル: test_net.py プロジェクト: hugb/ceph-deploy
 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
ファイル: test_net.py プロジェクト: hugb/ceph-deploy
 def test_correct_for_10_0_0_255(self, ip):
     assert net.ip_in_subnet(ip, "10.0.0.0/16")