launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #12071
[Merge] lp:~jtv/maas/custom-dhcp into lp:maas
Jeroen T. Vermeulen has proposed merging lp:~jtv/maas/custom-dhcp into lp:maas.
Requested reviews:
MAAS Maintainers (maas-maintainers)
For more details, see:
https://code.launchpad.net/~jtv/maas/custom-dhcp/+merge/124671
The “sudo -n” was Raphaël's suggestion. The required packaging branches are at:
https://code.launchpad.net/~smoser/maas/packaging.lp1049177/+merge/124083
https://code.launchpad.net/~jtv/maas/packaging-custom-dhcpd/+merge/124594
Jeroen
--
https://code.launchpad.net/~jtv/maas/custom-dhcp/+merge/124671
Your team MAAS Maintainers is requested to review the proposed merge of lp:~jtv/maas/custom-dhcp into lp:maas.
=== modified file 'HACKING.txt'
--- HACKING.txt 2012-08-21 10:56:22 +0000
+++ HACKING.txt 2012-09-17 13:02:21 +0000
@@ -271,23 +271,32 @@
^^^^^^^^^^^^^^^^
MAAS requires a properly configured DHCP server so it can boot machines using
-PXE. MAAS works with the ISC DHCP server; install it if it's not already
-installed::
-
- $ sudo apt-get install isc-dhcp-server
-
-There is a tool to generate a configuration that will work with MAAS::
+PXE. MAAS can work with its own instance of the ISC DHCP server, if you
+install the maas-dhcp package::
+
+ $ sudo apt-get install maas-dhcp
+
+If you choose to run your own ISC DHCP server, there is a bit more
+configuration to do. First, run this tool to generate a configuration that
+will work with MAAS::
$ maas-provision generate-dhcp-config [options]
Run ``maas-provision generate-dhcp-config -h`` to see the options. You will
need to provide various IP details such as the range of IP addresses to assign
to clients. You can use the generated output to configure your system's ISC
-DHCP server, by putting the configuration in the ``/etc/dhcp/dhcpd.conf`` file.
+DHCP server, by inserting the configuration in the ``/etc/dhcp/dhcpd.conf``
+file.
+
+Also, edit /etc/default/isc-dhcp-server to set the INTERFACES variable to just
+the network interfaces that should be serviced by this DHCP server.
Now restart dhcpd::
- $ sudo /etc/init.d/isc-dhcp-server restart
+ $ sudo service isc-dhcp-server restart
+
+None of this work is needed if you let MAAS run its own DHCP server by
+installing ``maas-dhcp``.
Development services
=== modified file 'etc/celeryconfig.py'
--- etc/celeryconfig.py 2012-09-17 10:10:46 +0000
+++ etc/celeryconfig.py 2012-09-17 13:02:21 +0000
@@ -40,6 +40,9 @@
# ISC dhcpd configuration file.
DHCP_CONFIG_FILE = '/etc/dhcp/dhcpd.conf'
+# List of interfaces that the dhcpd should service (if managed by MAAS).
+DHCP_INTERFACES_FILE = '/var/lib/maas/dhcpd-interfaces'
+
# Broken connection information.
# Format: transport://userid:password@hostname:port/virtual_host
BROKER_URL = 'amqp://guest:guest@localhost:5672//'
=== modified file 'src/maasserver/models/nodegroup.py'
--- src/maasserver/models/nodegroup.py 2012-09-13 16:26:24 +0000
+++ src/maasserver/models/nodegroup.py 2012-09-17 13:02:21 +0000
@@ -186,7 +186,8 @@
router_ip=interface.router_ip,
dns_servers=get_dns_server_address(),
ip_range_low=interface.ip_range_low,
- ip_range_high=interface.ip_range_high)
+ ip_range_high=interface.ip_range_high,
+ dhcp_interfaces=interface.interface)
def add_dhcp_host_maps(self, new_leases):
if self.is_dhcp_enabled() and len(new_leases) > 0:
=== modified file 'src/maasserver/tests/test_nodegroup.py'
--- src/maasserver/tests/test_nodegroup.py 2012-09-12 17:37:51 +0000
+++ src/maasserver/tests/test_nodegroup.py 2012-09-17 13:02:21 +0000
@@ -189,7 +189,8 @@
nodegroup = factory.make_node_group(
dhcp_key=factory.getRandomString(),
ip_range_low='192.168.102.1', ip_range_high='192.168.103.254',
- subnet_mask='255.255.252.0', broadcast_ip='192.168.103.255')
+ subnet_mask='255.255.252.0', broadcast_ip='192.168.103.255',
+ interface='eth93')
nodegroup.set_up_dhcp()
dhcp_params = [
'subnet_mask', 'broadcast_ip', 'router_ip',
@@ -207,6 +208,7 @@
expected_params["omapi_key"] = nodegroup.dhcp_key
expected_params["dns_servers"] = get_dns_server_address()
expected_params["subnet"] = '192.168.100.0'
+ expected_params["dhcp_interfaces"] = 'eth93'
mocked_task.delay.assert_called_once_with(**expected_params)
=== modified file 'src/provisioningserver/tasks.py'
--- src/provisioningserver/tasks.py 2012-09-17 06:46:55 +0000
+++ src/provisioningserver/tasks.py 2012-09-17 13:02:21 +0000
@@ -29,7 +29,10 @@
)
from celery.task import task
-from celeryconfig import DHCP_CONFIG_FILE
+from celeryconfig import (
+ DHCP_CONFIG_FILE,
+ DHCP_INTERFACES_FILE,
+ )
from provisioningserver import boot_images
from provisioningserver.auth import (
record_api_credentials,
@@ -306,18 +309,19 @@
def write_dhcp_config(**kwargs):
"""Write out the DHCP configuration file and restart the DHCP server.
+ :param dhcp_interfaces: Space-separated list of interfaces that the
+ DHCP server should listen on.
:param **kwargs: Keyword args passed to dhcp.config.get_config()
"""
- sudo_write_file(
- DHCP_CONFIG_FILE, config.get_config(**kwargs), encoding='ascii',
- mode=0744)
+ sudo_write_file(DHCP_CONFIG_FILE, config.get_config(**kwargs))
+ sudo_write_file(DHCP_INTERFACES_FILE, kwargs.get('dhcp_interfaces', ''))
restart_dhcp_server()
@task
def restart_dhcp_server():
"""Restart the DHCP server."""
- check_call(['sudo', 'service', 'isc-dhcp-server', 'restart'])
+ check_call(['sudo', '-n', 'service', 'maas-dhcp-server', 'restart'])
# =====================================================================
=== modified file 'src/provisioningserver/tests/test_tasks.py'
--- src/provisioningserver/tests/test_tasks.py 2012-09-17 10:55:11 +0000
+++ src/provisioningserver/tests/test_tasks.py 2012-09-17 13:02:21 +0000
@@ -24,7 +24,10 @@
from apiclient.creds import convert_tuple_to_string
from apiclient.maas_client import MAASClient
from apiclient.testing.credentials import make_api_credentials
-from celeryconfig import DHCP_CONFIG_FILE
+from celeryconfig import (
+ DHCP_CONFIG_FILE,
+ DHCP_INTERFACES_FILE,
+ )
from maastesting.celery import CeleryFixture
from maastesting.factory import factory
from maastesting.fakemethod import (
@@ -255,18 +258,24 @@
content = config.get_config(**config_params).encode("ascii")
mocked_proc.communicate.assert_any_call(content)
+ # Similarly, it also writes the DHCPD interfaces to
+ # /var/lib/maas/dhcpd-interfaces.
+ mocked_popen.assert_any_call(
+ ["sudo", "-n", "maas-provision", "atomic-write", "--filename",
+ DHCP_INTERFACES_FILE, "--mode", "0744"], stdin=PIPE)
+
# Finally it should restart the dhcp server.
check_call_args = mocked_check_call.call_args
self.assertEqual(
check_call_args[0][0],
- ['sudo', 'service', 'isc-dhcp-server', 'restart'])
+ ['sudo', '-n', 'service', 'maas-dhcp-server', 'restart'])
def test_restart_dhcp_server_sends_command(self):
recorder = FakeMethod()
self.patch(tasks, 'check_call', recorder)
restart_dhcp_server()
self.assertEqual(
- (1, (['sudo', 'service', 'isc-dhcp-server', 'restart'],)),
+ (1, (['sudo', '-n', 'service', 'maas-dhcp-server', 'restart'],)),
(recorder.call_count, recorder.extract_args()[0]))
Follow ups