Example #1
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))
Example #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))
Example #3
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)
Example #4
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)
Example #5
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)
Example #6
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)
Example #7
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
Example #8
0
File: dhcp.py Project: 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
Example #9
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)
Example #10
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)
Example #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)
Example #12
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)
Example #13
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)
Example #14
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)