launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #11077
[Merge] lp:~julian-edwards/maas/dhcp-config-writing into lp:maas
Julian Edwards has proposed merging lp:~julian-edwards/maas/dhcp-config-writing into lp:maas.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~julian-edwards/maas/dhcp-config-writing/+merge/120061
Small change to create a script to invoke src/provisioningserver/dhcp/writer.py. Jtv said we should have a script in scripts so count that as a pre-imp :)
The only bit I am not happy with is setting the PYTHONPATH for the new script. If there's a better way, I'll gladly change it.
--
https://code.launchpad.net/~julian-edwards/maas/dhcp-config-writing/+merge/120061
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~julian-edwards/maas/dhcp-config-writing into lp:maas.
=== added file 'scripts/write_dhcp_config'
--- scripts/write_dhcp_config 1970-01-01 00:00:00 +0000
+++ scripts/write_dhcp_config 2012-08-17 07:05:21 +0000
@@ -0,0 +1,26 @@
+#!/usr/bin/env python2.7
+# Copyright 2012 Canonical Ltd. This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Generate and write out a configuration for a DHCP server."""
+
+# In a development environment, run this with bin/py to set the PYTHONPATH.
+
+from __future__ import (
+ absolute_import,
+ print_function,
+ unicode_literals,
+ )
+
+__metaclass__ = type
+
+
+from argparse import ArgumentParser
+import sys
+
+from provisioningserver.dhcp import writer
+
+parser = ArgumentParser(__doc__)
+writer.add_arguments(parser)
+args = parser.parse_args(sys.argv[1:])
+writer.run(args)
=== added directory 'src/provisioningserver/dhcp/templates'
=== modified file 'src/provisioningserver/dhcp/tests/test_writer.py'
--- src/provisioningserver/dhcp/tests/test_writer.py 2012-08-17 04:28:56 +0000
+++ src/provisioningserver/dhcp/tests/test_writer.py 2012-08-17 07:05:21 +0000
@@ -15,6 +15,7 @@
from argparse import ArgumentParser
from io import BytesIO
from os import path
+from subprocess import Popen, PIPE
import sys
from maastesting.matchers import ContainsAll
@@ -38,6 +39,18 @@
'--omapi-key', 'omapi-key',
)
+ def test_script_executable(self):
+ script = ["scripts/write_dhcp_config"]
+ script.extend(self.test_args)
+ cmd = Popen(
+ script, stdout=PIPE, env=dict(PYTHONPATH=":".join(sys.path)))
+ output, err = cmd.communicate()
+ contains_all_params = ContainsAll(
+ ['subnet', 'subnet-mask', 'next-server', 'broadcast-ip',
+ 'omapi-shared-key', 'dns-servers', 'router-ip',
+ 'ip-range-low', 'ip-range-high'])
+ self.assertThat(output, contains_all_params)
+
def test_arg_setup(self):
parser = ArgumentParser()
writer.add_arguments(parser)
Follow ups