Merge lp:~julian-edwards/maas/enable_dhcp_when_setting_up_params into lp:~maas-committers/maas/trunk

Proposed by Julian Edwards
Status: Merged
Approved by: Julian Edwards
Approved revision: no longer in the source branch.
Merged at revision: 969
Proposed branch: lp:~julian-edwards/maas/enable_dhcp_when_setting_up_params
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 55 lines (+8/-20)
2 files modified
src/maasserver/management/commands/config_master_dhcp.py (+3/-3)
src/maasserver/tests/test_commands_config_master_dhcp.py (+5/-17)
To merge this branch: bzr merge lp:~julian-edwards/maas/enable_dhcp_when_setting_up_params
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) Approve
Review via email: mp+122613@code.launchpad.net

Commit message

Implicitly enable DHCP management when using the command "maas config-master-dhcp" to set up the DHCP parameters.

This will cause the DHCPD config file to also get written, which is reasonable behaviour given that someone is calling a command to set up DHCP parameters.

To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Makes sense. One small thing: in that last test, it may help to disable manage_dhcp explicitly. If we ever decide to change the default, or there's another test isolation problem, it'll be good to know that the test isn't passing for the wrong reason.

Jeroen

review: Approve
Revision history for this message
Julian Edwards (julian-edwards) wrote :

On Tuesday 04 September 2012 06:10:44 you wrote:
> Review: Approve
>
> Makes sense. One small thing: in that last test, it may help to disable
> manage_dhcp explicitly. If we ever decide to change the default, or
> there's another test isolation problem, it'll be good to know that the test
> isn't passing for the wrong reason.
>
>
> Jeroen

Good call, thanks.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/management/commands/config_master_dhcp.py'
2--- src/maasserver/management/commands/config_master_dhcp.py 2012-09-04 04:47:28 +0000
3+++ src/maasserver/management/commands/config_master_dhcp.py 2012-09-04 10:20:24 +0000
4@@ -106,7 +106,7 @@
5 setattr(master_nodegroup, item, value)
6 master_nodegroup.save()
7
8- # If DHCP management is enabled, create a Task that will
9+ # Enable DHCP management and create a Task that will
10 # write the config out.
11- if Config.objects.get_config('manage_dhcp'):
12- master_nodegroup.set_up_dhcp()
13+ Config.objects.set_config('manage_dhcp', True)
14+ master_nodegroup.set_up_dhcp()
15
16=== modified file 'src/maasserver/tests/test_commands_config_master_dhcp.py'
17--- src/maasserver/tests/test_commands_config_master_dhcp.py 2012-09-04 04:47:28 +0000
18+++ src/maasserver/tests/test_commands_config_master_dhcp.py 2012-09-04 10:20:24 +0000
19@@ -58,12 +58,8 @@
20
21 def setUp(self):
22 super(TestConfigMasterDHCP, self).setUp()
23- # Make sure any attempts to write a dhcp config end up in a temp
24- # file rather than the system one.
25- conf_file = self.make_file()
26- self.patch(tasks, "DHCP_CONFIG_FILE", conf_file)
27- # Prevent DHCPD restarts.
28- self.patch(tasks, 'check_call', Mock())
29+ # Make sure any attempts to write a dhcp config do nothing.
30+ self.patch(NodeGroup, 'set_up_dhcp')
31
32 def test_configures_dhcp_for_master_nodegroup(self):
33 settings = make_dhcp_settings()
34@@ -133,18 +129,10 @@
35 def test_name_option_turns_dhcp_setting_name_into_option(self):
36 self.assertEqual('--subnet-mask', name_option('subnet_mask'))
37
38- def test_sets_up_dhcp_if_dhcp_enabled(self):
39+ def test_sets_up_dhcp_and_enables_it(self):
40 master = NodeGroup.objects.ensure_master()
41- self.patch(NodeGroup, 'set_up_dhcp', Mock())
42 settings = make_dhcp_settings()
43- Config.objects.set_config('manage_dhcp', True)
44+ Config.objects.set_config('manage_dhcp', False)
45 call_command('config_master_dhcp', **settings)
46 self.assertEqual(1, master.set_up_dhcp.call_count)
47-
48- def test_ignores_set_up_dhcp_if_dhcp_disabled(self):
49- master = NodeGroup.objects.ensure_master()
50- self.patch(NodeGroup, 'set_up_dhcp', Mock())
51- settings = make_dhcp_settings()
52- Config.objects.set_config('manage_dhcp', False)
53- call_command('config_master_dhcp', **settings)
54- self.assertEqual(0, master.set_up_dhcp.call_count)
55+ self.assertTrue(Config.objects.get_config('manage_dhcp'))