示例#1
0
 def test_delete_subnet(self):
     """Delete a subnet; return True"""
     subnet = '172.16.4.1'
     mask = 24
     sub = SpokeSubnet(subnet, mask)
     sub.create()
     self.assertTrue(sub.delete())
示例#2
0
文件: test_ip.py 项目: mattmb/spoke
 def test_delete_subnet(self):
     """Delete a subnet; return True"""
     subnet = '172.16.4.1'
     mask = 24
     sub = SpokeSubnet(subnet, mask)
     sub.create()
     self.assertTrue(sub.delete())
示例#3
0
 def test_reserve_ip_from_exhausted_subnet(self):
     """Request an ip from an exhausted subnet; raise InsufficientResouce."""
     subnet = '172.16.1.1'
     mask = '30'
     sub = SpokeSubnet(subnet, mask)
     sub.create()
     self.assertRaises(error.InsufficientResource, sub.modify, reserve=3)
     sub.delete()
示例#4
0
文件: test_ip.py 项目: mattmb/spoke
 def test_reserve_ip_from_exhausted_subnet(self):
     """Request an ip from an exhausted subnet; raise InsufficientResouce."""
     subnet = '172.16.1.1'
     mask = '30'
     sub = SpokeSubnet(subnet, mask)
     sub.create()
     self.assertRaises(error.InsufficientResource, sub.modify, reserve=3)
     sub.delete()
示例#5
0
 def test_len_reserve_single_ip_from_subnet(self):
     """Request an ip from a subnet; return a single IP address as list."""
     subnet = '172.16.1.1'
     mask = '30'
     sub = SpokeSubnet(subnet, mask)
     sub.create()
     result = sub.modify(reserve=1)['data']
     self.assertEquals(len(result), 1)
     sub.delete()
示例#6
0
文件: test_ip.py 项目: mattmb/spoke
 def test_len_reserve_single_ip_from_subnet(self):
     """Request an ip from a subnet; return a single IP address as list."""
     subnet = '172.16.1.1'
     mask = '30'
     sub = SpokeSubnet(subnet, mask)
     sub.create()
     result = sub.modify(reserve=1)['data']
     self.assertEquals(len(result), 1)
     sub.delete()
示例#7
0
 def test_release_ip_twice_from_subnet(self):
     """Release an ip twice from a subnet; return True."""
     ip = '172.16.2.1'
     mask = '30'
     sub = SpokeSubnet(ip, mask)
     sub.create()
     sub.modify(reserve=2)
     sub.modify(release='172.16.1.2')
     self.assertTrue(sub.modify(release='172.16.1.2'))
     sub.delete()
示例#8
0
文件: test_ip.py 项目: mattmb/spoke
 def test_release_ip_twice_from_subnet(self):
     """Release an ip twice from a subnet; return True."""
     ip = '172.16.2.1'
     mask = '30'
     sub = SpokeSubnet(ip, mask)
     sub.create()
     sub.modify(reserve=2)
     sub.modify(release='172.16.1.2')
     self.assertTrue(sub.modify(release='172.16.1.2'))
     sub.delete()
示例#9
0
文件: test_ip.py 项目: mattmb/spoke
 def test_get_subnet_ip_info(self):
     """Get a subnet's free and aloc IP status; return as list"""
     ip = '172.16.1.1'
     network = '172.16.1.0'
     mask = 24
     expected_result = [(network, {'free': [254], 'aloc': [0]})]
     sub = SpokeSubnet(ip, mask)
     sub.create()
     result = sub.get()['data']
     self.assertEqual(result, expected_result)
     sub.delete()
示例#10
0
 def test_get_subnet_ip_info(self):
     """Get a subnet's free and aloc IP status; return as list"""
     ip = '172.16.1.1'
     network = '172.16.1.0'
     mask = 24
     expected_result = [(network, {'free': [254], 'aloc': [0]})]
     sub = SpokeSubnet(ip, mask)
     sub.create()
     result = sub.get()['data']
     self.assertEqual(result, expected_result)
     sub.delete()
示例#11
0
 def test_release_ip_from_subnet(self):
     """Release an ip from a subnet; return a results object."""
     subnet = '172.16.2.1'
     network = '172.16.2.0'
     mask = '30'
     expected_result = [(network, {'free': [1], 'aloc': [2]})]
     sub = SpokeSubnet(subnet, mask)
     sub.create()
     sub.modify(reserve=2)
     result = sub.modify(release='172.16.1.2')['data']
     self.assertEqual(result, expected_result)
     sub.delete()
示例#12
0
文件: test_ip.py 项目: mattmb/spoke
 def test_release_ip_from_subnet(self):
     """Release an ip from a subnet; return a results object."""
     subnet = '172.16.2.1'
     network = '172.16.2.0'
     mask = '30'
     expected_result = [(network, {'free': [1], 'aloc': [2]})]
     sub = SpokeSubnet(subnet, mask)
     sub.create()
     sub.modify(reserve=2)
     result = sub.modify(release='172.16.1.2')['data']
     self.assertEqual(result, expected_result)
     sub.delete()
示例#13
0
文件: test_ip.py 项目: mattmb/spoke
 def test_free_aloc_reserve_ip_from_subnet(self):
     """Request an ip from a subnet; verify free/aloc addresses."""
     ip = '172.16.1.1'
     network = '172.16.1.0'
     mask = '30'
     expected_result = [(network, {'free': [1], 'aloc': [1]})]
     sub = SpokeSubnet(ip, mask)
     sub.create()
     sub.modify(reserve=1)
     result = sub.get()['data']
     self.assertEqual(result, expected_result)
     sub.delete()
示例#14
0
 def test_free_aloc_reserve_ip_from_subnet(self):
     """Request an ip from a subnet; verify free/aloc addresses."""
     ip = '172.16.1.1'
     network = '172.16.1.0'
     mask = '30'
     expected_result = [(network, {'free': [1], 'aloc': [1]})]
     sub = SpokeSubnet(ip, mask)
     sub.create()
     sub.modify(reserve=1)
     result = sub.get()['data']
     self.assertEqual(result, expected_result)
     sub.delete()
示例#15
0
文件: ip.py 项目: KrisSaxton/spoke
def create(network, mask):
    try:
        conf = _spoke_config(_salt_config('config'))
        subnet = SpokeSubnet(ip=network, mask=mask, dc=None)
        result = subnet.create(None)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
示例#16
0
def create(network, mask):
    try:
        from spoke.lib.ip import SpokeSubnet
        subnet = SpokeSubnet(ip=network, mask=mask, dc=None)
        result = subnet.create(None)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
示例#17
0
 def test_create_subnet_mask_string(self):
     """Create a subnet with a mask as string; return True"""
     subnet = '10.0.0.0'
     mask = '30'
     expected_result = [(subnet, {'aloc': [0], 'free': [2]})]
     sub = SpokeSubnet(subnet, mask)
     result = sub.create()['data']
     self.assertEqual(result, expected_result)
     sub.delete()
示例#18
0
 def test_create_subnet(self):
     """Create a subnet object; return results object."""
     subnet = '10.0.0.0'
     mask = 30
     expected_result = [(subnet, {'aloc': [0], 'free': [2]})]
     sub = SpokeSubnet(subnet, mask)
     result = sub.create()['data']
     self.assertEqual(result, expected_result)
     sub.delete()
示例#19
0
文件: test_ip.py 项目: mattmb/spoke
 def test_create_subnet(self):
     """Create a subnet object; return results object."""
     subnet = '10.0.0.0'
     mask = 30
     expected_result = [(subnet, {'aloc': [0], 'free': [2]})]
     sub = SpokeSubnet(subnet, mask)
     result = sub.create()['data']
     self.assertEqual(result, expected_result)
     sub.delete()
示例#20
0
文件: test_ip.py 项目: mattmb/spoke
 def test_create_subnet_mask_string(self):
     """Create a subnet with a mask as string; return True"""
     subnet = '10.0.0.0'
     mask = '30'
     expected_result = [(subnet, {'aloc': [0], 'free': [2]})]
     sub = SpokeSubnet(subnet, mask)
     result = sub.create()['data']
     self.assertEqual(result, expected_result)
     sub.delete()
示例#21
0
 def test_create_subnet_with_dc_prefix(self):
     """Create a subnet with a data centre prefix; return True."""
     dc = 'dc1'
     subnet = '10.0.0.0'
     mask = 30
     expected_result = [(dc + subnet, {'aloc': [0], 'free': [2]})]
     sub = SpokeSubnet(subnet, mask, dc)
     result = sub.create()['data']
     self.assertEqual(result, expected_result)
     sub.delete()
示例#22
0
文件: test_ip.py 项目: mattmb/spoke
 def test_create_subnet_with_dc_prefix(self):
     """Create a subnet with a data centre prefix; return True."""
     dc = 'dc1'
     subnet = '10.0.0.0'
     mask = 30
     expected_result = [(dc + subnet, {'aloc': [0], 'free': [2]})]
     sub = SpokeSubnet(subnet, mask, dc)
     result = sub.create()['data']
     self.assertEqual(result, expected_result)
     sub.delete()
示例#23
0
文件: test_ip.py 项目: mattmb/spoke
 def setUp(self):
     sub = SpokeSubnet(self.subnet, self.mask)
     sub.create()
示例#24
0
 def setUp(self): 
     sub = SpokeSubnet(self.subnet, self.mask)
     sub.create()