def test_non_dict(self):
     errors = validation.check_allocation_pools_pairing(None, {})
     self.assertEqual(len(errors), 1)
     self.assertEqual("The first argument must be a dictionary.", errors[0])
     errors = validation.check_allocation_pools_pairing({}, None)
     self.assertEqual(len(errors), 1)
     self.assertEqual("The second argument must be a dictionary.", errors[0])
 def test_non_dict(self):
     errors = validation.check_allocation_pools_pairing(None, {})
     self.assertEqual(len(errors), 1)
     self.assertEqual('The first argument must be a dictionary.', errors[0])
     errors = validation.check_allocation_pools_pairing({}, None)
     self.assertEqual(len(errors), 1)
     self.assertEqual('The second argument must be a dictionary.',
                      errors[0])
 def test_multiple_ranges_and_pools(self):
     filedata = {
         'StorageNetCidr': '172.18.0.0/24',
         'TenantNetCidr': '172.16.0.0/24',
     }
     pools = {
         'StorageAllocationPools': [
             {
                 'start': '172.18.0.10',
                 'end': '172.18.0.20'
             },
             {
                 'start': '172.18.0.100',
                 'end': '172.18.0.200'
             },
         ],
         'TenantAllocationPools': [
             {
                 'start': '172.16.0.20',
                 'end': '172.16.0.30'
             },
             {
                 'start': '172.16.0.70',
                 'end': '172.16.0.80'
             },
         ],
     }
     errors = validation.check_allocation_pools_pairing(filedata, pools)
     self.assertEqual([], errors)
 def _test_pool_invalid_range(self, addr_range):
     filedata = {'TestNetCidr': '172.18.0.0/24'}
     pools = {'TestAllocationPools': [addr_range]}
     errors = validation.check_allocation_pools_pairing(filedata, pools)
     self.assertEqual(len(errors), 1)
     self.assertEqual(
         'Invalid format of the IP range in'
         ' TestAllocationPools: {}'.format(addr_range), errors[0])
 def test_pool_with_correct_range(self):
     filedata = {
         'StorageNetCidr': '172.18.0.0/24',
     }
     pools = {
         'StorageAllocationPools': [{
             'start': '172.18.0.10',
             'end': '172.18.0.200'
         }]
     }
     errors = validation.check_allocation_pools_pairing(filedata, pools)
     self.assertEqual([], errors)
 def test_pool_outside_cidr(self):
     filedata = {
         'StorageNetCidr': '172.18.0.0/25',
     }
     pools = {
         'StorageAllocationPools': [{
             'start': '172.18.0.10',
             'end': '172.18.0.200'
         }]
     }
     errors = validation.check_allocation_pools_pairing(filedata, pools)
     self.assertEqual(len(errors), 1)
     self.assertIn('outside of subnet StorageNetCidr', errors[0])
 def test_pool_with_invalid_cidr(self):
     filedata = {
         'StorageNetCidr': 'breakit',
     }
     pools = {
         'StorageAllocationPools': [{
             'start': '172.18.0.10',
             'end': '172.18.0.200'
         }]
     }
     errors = validation.check_allocation_pools_pairing(filedata, pools)
     self.assertEqual(len(errors), 1)
     self.assertEqual('Invalid IP network: breakit', errors[0])
 def test_pool_without_cidr(self):
     filedata = {}
     pools = {
         'StorageAllocationPools': [{
             'start': '172.18.0.10',
             'end': '172.18.0.200'
         }]
     }
     errors = validation.check_allocation_pools_pairing(filedata, pools)
     self.assertEqual(len(errors), 1)
     self.assertEqual(
         'The StorageNetCidr CIDR is not specified for'
         ' StorageAllocationPools.', errors[0])
 def test_multiple_ranges_and_pools(self):
     filedata = {"StorageNetCidr": "172.18.0.0/24", "TenantNetCidr": "172.16.0.0/24"}
     pools = {
         "StorageAllocationPools": [
             {"start": "172.18.0.10", "end": "172.18.0.20"},
             {"start": "172.18.0.100", "end": "172.18.0.200"},
         ],
         "TenantAllocationPools": [
             {"start": "172.16.0.20", "end": "172.16.0.30"},
             {"start": "172.16.0.70", "end": "172.16.0.80"},
         ],
     }
     errors = validation.check_allocation_pools_pairing(filedata, pools)
     self.assertEqual([], errors)
Пример #10
0
 def test_pool_with_invalid_cidr(self):
     filedata = {"StorageNetCidr": "breakit"}
     pools = {"StorageAllocationPools": [{"start": "172.18.0.10", "end": "172.18.0.200"}]}
     errors = validation.check_allocation_pools_pairing(filedata, pools)
     self.assertEqual(len(errors), 1)
     self.assertEqual("Invalid IP network: breakit", errors[0])
Пример #11
0
 def test_pool_without_cidr(self):
     filedata = {}
     pools = {"StorageAllocationPools": [{"start": "172.18.0.10", "end": "172.18.0.200"}]}
     errors = validation.check_allocation_pools_pairing(filedata, pools)
     self.assertEqual(len(errors), 1)
     self.assertEqual("The StorageNetCidr CIDR is not specified for" " StorageAllocationPools.", errors[0])
Пример #12
0
 def test_pool_with_correct_range(self):
     filedata = {"StorageNetCidr": "172.18.0.0/24"}
     pools = {"StorageAllocationPools": [{"start": "172.18.0.10", "end": "172.18.0.200"}]}
     errors = validation.check_allocation_pools_pairing(filedata, pools)
     self.assertEqual([], errors)
Пример #13
0
 def _test_pool_invalid_range(self, addr_range):
     filedata = {"TestNetCidr": "172.18.0.0/24"}
     pools = {"TestAllocationPools": [addr_range]}
     errors = validation.check_allocation_pools_pairing(filedata, pools)
     self.assertEqual(len(errors), 1)
     self.assertEqual("Invalid format of the IP range in" " TestAllocationPools: {}".format(addr_range), errors[0])
Пример #14
0
 def test_pool_range_not_list(self):
     pools = {"TestPools": None}
     errors = validation.check_allocation_pools_pairing({}, pools)
     self.assertEqual(len(errors), 1)
     self.assertEqual("The IP ranges in TestPools must form a list.", errors[0])
 def test_pool_range_not_list(self):
     pools = {'TestPools': None}
     errors = validation.check_allocation_pools_pairing({}, pools)
     self.assertEqual(len(errors), 1)
     self.assertEqual('The IP ranges in TestPools must form a list.',
                      errors[0])
Пример #16
0
 def test_pool_outside_cidr(self):
     filedata = {"StorageNetCidr": "172.18.0.0/25"}
     pools = {"StorageAllocationPools": [{"start": "172.18.0.10", "end": "172.18.0.200"}]}
     errors = validation.check_allocation_pools_pairing(filedata, pools)
     self.assertEqual(len(errors), 1)
     self.assertIn("outside of subnet StorageNetCidr", errors[0])
Пример #17
0
 def test_empty(self):
     errors = validation.check_allocation_pools_pairing({}, {})
     self.assertEqual([], errors)
 def test_empty(self):
     errors = validation.check_allocation_pools_pairing({}, {})
     self.assertEqual([], errors)