Esempio n. 1
0
 def test_get_missing_dhcp_subnet(self):
     """Fetch missing DHCP subnet; return empty list."""
     subnet = "192.168.0.0"
     sub = SpokeDHCPSubnet(self.dhcp_server)
     result = sub.get(subnet)["data"]
     expected_result = []
     self.assertEqual(result, expected_result)
Esempio n. 2
0
 def test_delete_dhcp_subnet(self):
     """Delete DHCP subnet, return True."""
     subnet = '172.16.1.0'
     mask = '8'
     sub = SpokeDHCPSubnet(self.dhcp_server)
     sub.create(subnet, mask)
     self.assertTrue(sub.delete(subnet))
Esempio n. 3
0
 def test_get_missing_dhcp_subnet(self):
     """Fetch missing DHCP subnet; return empty list."""
     subnet = '192.168.0.0'
     sub = SpokeDHCPSubnet(self.dhcp_server)
     result = sub.get(subnet)['data']
     expected_result = []
     self.assertEqual(result, expected_result)
Esempio n. 4
0
 def test_delete_dhcp_subnet(self):
     """Delete DHCP subnet, return True."""
     subnet = "172.16.1.0"
     mask = "8"
     sub = SpokeDHCPSubnet(self.dhcp_server)
     sub.create(subnet, mask)
     self.assertTrue(sub.delete(subnet))
Esempio n. 5
0
File: dhcp.py Progetto: mattmb/spoke
def subnet_search(dhcp_server, subnet):
    try:
        from spoke.lib.dhcp import SpokeDHCPSubnet
        subnet = SpokeDHCPSubnet(dhcp_server)
        result = subnet.get(subnet)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Esempio n. 6
0
def subnet_create(dhcp_server, subnet, mask, start_ip=None, stop_ip=None):
    try:
        from spoke.lib.dhcp import SpokeDHCPSubnet
        subnet = SpokeDHCPSubnet(dhcp_server)
        result = subnet.create(subnet, mask, start_ip, stop_ip)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Esempio n. 7
0
def subnet_search(dhcp_server, subnet):
    try:
        from spoke.lib.dhcp import SpokeDHCPSubnet
        subnet = SpokeDHCPSubnet(dhcp_server)
        result = subnet.get(subnet)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Esempio n. 8
0
 def test_create_dhcp_subnet_twice(self):
     """Create DHCP subnet twice; raise AlreadyExists."""
     subnet = "10.0.0.0"
     subnet_mask = "16"
     sub = SpokeDHCPSubnet(self.dhcp_server)
     sub.create(subnet, subnet_mask)
     self.assertRaises(error.AlreadyExists, sub.create, subnet, subnet_mask)
     sub.delete(subnet)
Esempio n. 9
0
File: dhcp.py Progetto: mattmb/spoke
def subnet_create(dhcp_server, subnet, mask, start_ip=None, stop_ip=None):
    try:
        from spoke.lib.dhcp import SpokeDHCPSubnet
        subnet= SpokeDHCPSubnet(dhcp_server)
        result = subnet.create(subnet, mask, start_ip, stop_ip)
    except error.SpokeError as e:
        result = common.handle_error(e)
    return result
Esempio n. 10
0
 def test_delete_dhcp_service_before_subnet(self):
     """Delete DHCP service while subnet present, raise SaveTheBabies."""
     dhcp_server = "deletechildren.dhcp.service.local"
     dhcp = SpokeDHCPService()
     dhcp.create(dhcp_server)
     subnet = "10.0.0.0"
     mask = "16"
     sub = SpokeDHCPSubnet(dhcp_server)
     sub.create(subnet, mask)
     self.assertRaises(error.SaveTheBabies, dhcp.delete, dhcp_server)
     sub.delete(subnet)
     dhcp.delete(dhcp_server)
Esempio n. 11
0
 def test_create_dhcp_subnet_with_integer_mask(self):
     """Create DHCP subnet with integer mask; return True."""
     subnet = "10.0.0.0"
     subnet_mask = 16
     sub = SpokeDHCPSubnet(self.dhcp_server)
     result = sub.create(subnet, subnet_mask)["data"]
     service_name = self.dhcp_server + self.dhcp_conf_suffix
     service_dn = "cn=%s,%s" % (service_name, self.base_dn)
     dn = "cn=%s,%s" % (subnet, service_dn)
     dn_info = {"objectClass": ["top", self.dhcp_subnet_class], "cn": [subnet], "dhcpNetMask": [str(subnet_mask)]}
     expected_result = [(dn, dn_info)]
     self.assertEqual(result, expected_result)
     sub.delete(subnet)
Esempio n. 12
0
 def test_create_dhcp_subnet_with_integer_mask(self):
     """Create DHCP subnet with integer mask; return True."""
     subnet = '10.0.0.0'
     subnet_mask = 16
     sub = SpokeDHCPSubnet(self.dhcp_server)
     result = sub.create(subnet, subnet_mask)['data']
     service_name = self.dhcp_server + self.dhcp_conf_suffix
     service_dn = 'cn=%s,%s' % (service_name, self.base_dn)
     dn = 'cn=%s,%s' % (subnet, service_dn)
     dn_info = {'objectClass': ['top', self.dhcp_subnet_class],
                'cn': [subnet],
                'dhcpNetMask': [str(subnet_mask)]}
     expected_result = [(dn, dn_info)]
     self.assertEqual(result, expected_result)
     sub.delete(subnet)
Esempio n. 13
0
 def test_create_dhcp_subnet_with_missing_stop_ip(self):
     """Create DHCP subnet with no stop IP; raise InputError."""
     subnet = '10.0.0.0'
     subnet_mask = '16'
     start_ip = '10.0.0.1'
     sub = SpokeDHCPSubnet(self.dhcp_server)
     self.assertRaises(error.InputError, sub.create, subnet, subnet_mask,
                       start_ip)
Esempio n. 14
0
 def test_create_dhcp_subnet_with_integer_mask(self):
     """Create DHCP subnet with integer mask; return True."""
     subnet = '10.0.0.0'
     subnet_mask = 16
     sub = SpokeDHCPSubnet(self.dhcp_server)
     result = sub.create(subnet, subnet_mask)['data']
     service_name = self.dhcp_server + self.dhcp_conf_suffix
     service_dn = 'cn=%s,%s' % (service_name, self.base_dn)
     dn = 'cn=%s,%s' % (subnet, service_dn)
     dn_info = {
         'objectClass': ['top', self.dhcp_subnet_class],
         'cn': [subnet],
         'dhcpNetMask': [str(subnet_mask)]
     }
     expected_result = [(dn, dn_info)]
     self.assertEqual(result, expected_result)
     sub.delete(subnet)
Esempio n. 15
0
 def test_create_dhcp_subnet_with_non_ip_range(self):
     """Create DHCP subnet with non IP range; raise InputError."""
     subnet = '10.0.0.0'
     subnet_mask = '16'
     start_ip = '10.0.0'
     stop_ip = '10.0.0.254'
     sub = SpokeDHCPSubnet(self.dhcp_server)
     self.assertRaises(error.InputError, sub.create, subnet, subnet_mask,
                       start_ip, stop_ip)
Esempio n. 16
0
 def test_create_dhcp_subnet_with_stop_ip_preceding_start_ip(self):
     """Create DHCP subnet with the stop IP preceding the start ip; \
     raise InputError."""
     subnet = '10.0.0.0'
     subnet_mask = '16'
     start_ip = '10.0.2.25'
     stop_ip = '10.0.1.250'
     sub = SpokeDHCPSubnet(self.dhcp_server)
     self.assertRaises(error.InputError, sub.create, subnet, subnet_mask,
                       start_ip, stop_ip)
Esempio n. 17
0
 def test_get_dhcp_subnet(self):
     """Fetch DHCP subnet; return True."""
     subnet = '10.0.0.0'
     mask = '16'
     start_ip = '10.0.0.1'
     stop_ip = '10.0.0.254'
     subnet_range = start_ip + ' ' + stop_ip
     sub = SpokeDHCPSubnet(self.dhcp_server)
     result = sub.create(subnet, mask, start_ip, stop_ip)['data']
     service_name = self.dhcp_server + self.dhcp_conf_suffix
     service_dn = 'cn=%s,%s' % (service_name, self.base_dn)
     dn = 'cn=%s,%s' % (subnet, service_dn)
     dn_info = {'objectClass': ['top', self.dhcp_subnet_class],
                'cn': [subnet],
                'dhcpNetMask': [str(mask)],
                'dhcpRange': [subnet_range]}
     expected_result = [(dn, dn_info)]
     self.assertEqual(result, expected_result)
     sub.delete(subnet)
Esempio n. 18
0
 def test_get_dhcp_subnet(self):
     """Fetch DHCP subnet; return True."""
     subnet = "10.0.0.0"
     mask = "16"
     start_ip = "10.0.0.1"
     stop_ip = "10.0.0.254"
     subnet_range = start_ip + " " + stop_ip
     sub = SpokeDHCPSubnet(self.dhcp_server)
     result = sub.create(subnet, mask, start_ip, stop_ip)["data"]
     service_name = self.dhcp_server + self.dhcp_conf_suffix
     service_dn = "cn=%s,%s" % (service_name, self.base_dn)
     dn = "cn=%s,%s" % (subnet, service_dn)
     dn_info = {
         "objectClass": ["top", self.dhcp_subnet_class],
         "cn": [subnet],
         "dhcpNetMask": [str(mask)],
         "dhcpRange": [subnet_range],
     }
     expected_result = [(dn, dn_info)]
     self.assertEqual(result, expected_result)
     sub.delete(subnet)
Esempio n. 19
0
 def test_get_dhcp_subnet(self):
     """Fetch DHCP subnet; return True."""
     subnet = '10.0.0.0'
     mask = '16'
     start_ip = '10.0.0.1'
     stop_ip = '10.0.0.254'
     subnet_range = start_ip + ' ' + stop_ip
     sub = SpokeDHCPSubnet(self.dhcp_server)
     result = sub.create(subnet, mask, start_ip, stop_ip)['data']
     service_name = self.dhcp_server + self.dhcp_conf_suffix
     service_dn = 'cn=%s,%s' % (service_name, self.base_dn)
     dn = 'cn=%s,%s' % (subnet, service_dn)
     dn_info = {
         'objectClass': ['top', self.dhcp_subnet_class],
         'cn': [subnet],
         'dhcpNetMask': [str(mask)],
         'dhcpRange': [subnet_range]
     }
     expected_result = [(dn, dn_info)]
     self.assertEqual(result, expected_result)
     sub.delete(subnet)
Esempio n. 20
0
 def test_create_dhcp_subnet_twice(self):
     """Create DHCP subnet twice; raise AlreadyExists."""
     subnet = '10.0.0.0'
     subnet_mask = '16'
     sub = SpokeDHCPSubnet(self.dhcp_server)
     sub.create(subnet, subnet_mask)
     self.assertRaises(error.AlreadyExists, sub.create, subnet, subnet_mask)
     sub.delete(subnet)
Esempio n. 21
0
 def test_delete_dhcp_service_before_subnet(self):
     """Delete DHCP service while subnet present, raise SaveTheBabies."""
     dhcp_server = 'deletechildren.dhcp.service.local'
     dhcp = SpokeDHCPService()
     dhcp.create(dhcp_server)
     subnet = '10.0.0.0'
     mask = '16'
     sub = SpokeDHCPSubnet(dhcp_server)
     sub.create(subnet, mask)
     self.assertRaises(error.SaveTheBabies, dhcp.delete, dhcp_server)
     sub.delete(subnet)
     dhcp.delete(dhcp_server)
Esempio n. 22
0
 def test_create_dhcp_subnet_with_invalid_mask(self):
     """Create DHCP subnet with non-integer mask; raise InputError."""
     subnet = '10.0.0.0'
     subnet_mask = '255.0.0.0'
     sub = SpokeDHCPSubnet(self.dhcp_server)
     self.assertRaises(error.InputError, sub.create, subnet, subnet_mask)
Esempio n. 23
0
 def test_get_invalid_dhcp_subnet(self):
     """Fetch DHCP invalid subnet; raise InputError."""
     subnet = '10.0.0'
     sub = SpokeDHCPSubnet(self.dhcp_server)
     self.assertRaises(error.InputError, sub.get, subnet)
Esempio n. 24
0
 def test_delete_missing_dhcp_subnet(self):
     """Delete missing DHCP subnet; raise NotFound."""
     # This should be deleted when the instantiation raises the error.
     subnet = '172.16.2.0'
     sub = SpokeDHCPSubnet(self.dhcp_server)
     self.assertRaises(error.NotFound, sub.delete, subnet)