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
=== modified file 'src/maasserver/management/commands/config_master_dhcp.py'
--- src/maasserver/management/commands/config_master_dhcp.py 2012-09-04 04:47:28 +0000
+++ src/maasserver/management/commands/config_master_dhcp.py 2012-09-04 10:20:24 +0000
@@ -106,7 +106,7 @@
106 setattr(master_nodegroup, item, value)106 setattr(master_nodegroup, item, value)
107 master_nodegroup.save()107 master_nodegroup.save()
108108
109 # If DHCP management is enabled, create a Task that will109 # Enable DHCP management and create a Task that will
110 # write the config out.110 # write the config out.
111 if Config.objects.get_config('manage_dhcp'):111 Config.objects.set_config('manage_dhcp', True)
112 master_nodegroup.set_up_dhcp()112 master_nodegroup.set_up_dhcp()
113113
=== modified file 'src/maasserver/tests/test_commands_config_master_dhcp.py'
--- src/maasserver/tests/test_commands_config_master_dhcp.py 2012-09-04 04:47:28 +0000
+++ src/maasserver/tests/test_commands_config_master_dhcp.py 2012-09-04 10:20:24 +0000
@@ -58,12 +58,8 @@
5858
59 def setUp(self):59 def setUp(self):
60 super(TestConfigMasterDHCP, self).setUp()60 super(TestConfigMasterDHCP, self).setUp()
61 # Make sure any attempts to write a dhcp config end up in a temp61 # Make sure any attempts to write a dhcp config do nothing.
62 # file rather than the system one.62 self.patch(NodeGroup, 'set_up_dhcp')
63 conf_file = self.make_file()
64 self.patch(tasks, "DHCP_CONFIG_FILE", conf_file)
65 # Prevent DHCPD restarts.
66 self.patch(tasks, 'check_call', Mock())
6763
68 def test_configures_dhcp_for_master_nodegroup(self):64 def test_configures_dhcp_for_master_nodegroup(self):
69 settings = make_dhcp_settings()65 settings = make_dhcp_settings()
@@ -133,18 +129,10 @@
133 def test_name_option_turns_dhcp_setting_name_into_option(self):129 def test_name_option_turns_dhcp_setting_name_into_option(self):
134 self.assertEqual('--subnet-mask', name_option('subnet_mask'))130 self.assertEqual('--subnet-mask', name_option('subnet_mask'))
135131
136 def test_sets_up_dhcp_if_dhcp_enabled(self):132 def test_sets_up_dhcp_and_enables_it(self):
137 master = NodeGroup.objects.ensure_master()133 master = NodeGroup.objects.ensure_master()
138 self.patch(NodeGroup, 'set_up_dhcp', Mock())
139 settings = make_dhcp_settings()134 settings = make_dhcp_settings()
140 Config.objects.set_config('manage_dhcp', True)135 Config.objects.set_config('manage_dhcp', False)
141 call_command('config_master_dhcp', **settings)136 call_command('config_master_dhcp', **settings)
142 self.assertEqual(1, master.set_up_dhcp.call_count)137 self.assertEqual(1, master.set_up_dhcp.call_count)
143138 self.assertTrue(Config.objects.get_config('manage_dhcp'))
144 def test_ignores_set_up_dhcp_if_dhcp_disabled(self):
145 master = NodeGroup.objects.ensure_master()
146 self.patch(NodeGroup, 'set_up_dhcp', Mock())
147 settings = make_dhcp_settings()
148 Config.objects.set_config('manage_dhcp', False)
149 call_command('config_master_dhcp', **settings)
150 self.assertEqual(0, master.set_up_dhcp.call_count)