Merge ~andreserl/maas:add_skip_bmc_config into maas:master

Proposed by Andres Rodriguez
Status: Merged
Approved by: Andres Rodriguez
Approved revision: d5e120c5879eccede0d22044bc7ec4402d42ee18
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~andreserl/maas:add_skip_bmc_config
Merge into: maas:master
Diff against target: 284 lines (+59/-17)
12 files modified
src/maasserver/api/machines.py (+3/-0)
src/maasserver/api/tests/test_machine.py (+2/-0)
src/maasserver/forms/ephemeral.py (+4/-2)
src/maasserver/forms/tests/test_ephemeral.py (+9/-7)
src/maasserver/migrations/builtin/maasserver/0153_add_skip_bmc_config.py (+23/-0)
src/maasserver/models/node.py (+7/-3)
src/maasserver/models/tests/test_node.py (+2/-0)
src/maasserver/node_action.py (+4/-3)
src/maasserver/websockets/handlers/controller.py (+1/-0)
src/maasserver/websockets/handlers/device.py (+1/-0)
src/maasserver/websockets/handlers/machine.py (+1/-0)
src/metadataserver/user_data/templates/commissioning.template (+2/-2)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Lee Trager (community) Approve
Review via email: mp+342151@code.launchpad.net

Commit message

Add ability to skip BMC configuration over the API only

To post a comment you must log in.
Revision history for this message
Lee Trager (ltrager) wrote :

LGTM!

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b add_skip_bmc_config lp:~andreserl/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci-jenkins.internal:8080/job/maas/job/branch-tester/2104/console
COMMIT: 1e7643cb76530247eeff6de8b74c2aa176d06044

review: Needs Fixing
Revision history for this message
MAAS Lander (maas-lander) wrote :
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b add_skip_bmc_config lp:~andreserl/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: e394a632d242396faeaf21abc7eb52b1e7911a3d

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b add_skip_bmc_config lp:~andreserl/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: d5e120c5879eccede0d22044bc7ec4402d42ee18

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/api/machines.py b/src/maasserver/api/machines.py
2index 06219c8..cfc5d0d 100644
3--- a/src/maasserver/api/machines.py
4+++ b/src/maasserver/api/machines.py
5@@ -676,6 +676,9 @@ class MachineHandler(NodeHandler, OwnerDataMixin, PowerMixin):
6 :param enable_ssh: Whether to enable SSH for the commissioning
7 environment using the user's SSH key(s).
8 :type enable_ssh: bool ('0' for False, '1' for True)
9+ :param skip_bmc_config: Whether to skip re-configuration of the BMC
10+ for IPMI based machines.
11+ :type skip_bmc_config: bool ('0' for False, '1' for True)
12 :param skip_networking: Whether to skip re-configuring the networking
13 on the machine after the commissioning has completed.
14 :type skip_networking: bool ('0' for False, '1' for True)
15diff --git a/src/maasserver/api/tests/test_machine.py b/src/maasserver/api/tests/test_machine.py
16index 34d5d5d..65fd929 100644
17--- a/src/maasserver/api/tests/test_machine.py
18+++ b/src/maasserver/api/tests/test_machine.py
19@@ -1039,6 +1039,7 @@ class TestMachineAPI(APITestCase.ForUser):
20 response = self.client.post(self.get_machine_uri(machine), {
21 'op': 'commission',
22 'enable_ssh': "true",
23+ 'skip_bmc_config': 1,
24 'skip_networking': 1,
25 'commissioning_scripts': ','.join([
26 choice([
27@@ -1056,6 +1057,7 @@ class TestMachineAPI(APITestCase.ForUser):
28 commissioning_script_set = machine.current_commissioning_script_set
29 testing_script_set = machine.current_testing_script_set
30 self.assertTrue(machine.enable_ssh)
31+ self.assertTrue(machine.skip_bmc_config)
32 self.assertTrue(machine.skip_networking)
33 self.assertItemsEqual(
34 set(expected_commissioning_scripts),
35diff --git a/src/maasserver/forms/ephemeral.py b/src/maasserver/forms/ephemeral.py
36index 46a873b..7e1ea01 100644
37--- a/src/maasserver/forms/ephemeral.py
38+++ b/src/maasserver/forms/ephemeral.py
39@@ -92,6 +92,7 @@ class TestForm(Form):
40 class CommissionForm(TestForm):
41 """Commission form."""
42
43+ skip_bmc_config = BooleanField(required=False, initial=False)
44 skip_networking = BooleanField(required=False, initial=False)
45 skip_storage = BooleanField(required=False, initial=False)
46
47@@ -131,11 +132,12 @@ class CommissionForm(TestForm):
48
49 def save(self):
50 enable_ssh = self.cleaned_data.get("enable_ssh", False)
51+ skip_bmc_config = self.cleaned_data.get("skip_bmc_config", False)
52 skip_networking = self.cleaned_data.get("skip_networking", False)
53 skip_storage = self.cleaned_data.get("skip_storage", False)
54 commissioning_scripts = self.cleaned_data.get("commissioning_scripts")
55 testing_scripts = self.cleaned_data.get("testing_scripts")
56 self.instance.start_commissioning(
57- self.user, enable_ssh, skip_networking, skip_storage,
58- commissioning_scripts, testing_scripts)
59+ self.user, enable_ssh, skip_bmc_config, skip_networking,
60+ skip_storage, commissioning_scripts, testing_scripts)
61 return self.instance
62diff --git a/src/maasserver/forms/tests/test_ephemeral.py b/src/maasserver/forms/tests/test_ephemeral.py
63index 3b457a7..3cd3dea 100644
64--- a/src/maasserver/forms/tests/test_ephemeral.py
65+++ b/src/maasserver/forms/tests/test_ephemeral.py
66@@ -146,9 +146,9 @@ class TestCommissionForm(MAASServerTestCase):
67 self.assertThat(
68 mock_start_commissioning,
69 MockCalledOnceWith(
70- user, enable_ssh=False, skip_networking=False,
71- skip_storage=False, commissioning_scripts=[],
72- testing_scripts=[]))
73+ user, enable_ssh=False, skip_bmc_config=False,
74+ skip_networking=False, skip_storage=False,
75+ commissioning_scripts=[], testing_scripts=[]))
76
77 def test__calls_start_commissioning_with_options(self):
78 node = factory.make_Node(
79@@ -166,6 +166,7 @@ class TestCommissionForm(MAASServerTestCase):
80 node, 'start_commissioning')
81 form = CommissionForm(instance=node, user=user, data={
82 'enable_ssh': True,
83+ 'skip_bmc_config': True,
84 'skip_networking': True,
85 'skip_storage': True,
86 'commissioning_scripts': ','.join(commissioning_scripts),
87@@ -177,7 +178,8 @@ class TestCommissionForm(MAASServerTestCase):
88 self.assertThat(
89 mock_start_commissioning,
90 MockCalledOnceWith(
91- user, enable_ssh=True, skip_networking=True, skip_storage=True,
92+ user, enable_ssh=True, skip_bmc_config=True,
93+ skip_networking=True, skip_storage=True,
94 commissioning_scripts=commissioning_scripts,
95 testing_scripts=testing_scripts))
96
97@@ -214,6 +216,6 @@ class TestCommissionForm(MAASServerTestCase):
98 self.assertThat(
99 mock_start_commissioning,
100 MockCalledOnceWith(
101- user, enable_ssh=False, skip_networking=False,
102- skip_storage=False, commissioning_scripts=[],
103- testing_scripts=['none']))
104+ user, enable_ssh=False, skip_bmc_config=False,
105+ skip_networking=False, skip_storage=False,
106+ commissioning_scripts=[], testing_scripts=['none']))
107diff --git a/src/maasserver/migrations/builtin/maasserver/0153_add_skip_bmc_config.py b/src/maasserver/migrations/builtin/maasserver/0153_add_skip_bmc_config.py
108new file mode 100644
109index 0000000..fc9ad72
110--- /dev/null
111+++ b/src/maasserver/migrations/builtin/maasserver/0153_add_skip_bmc_config.py
112@@ -0,0 +1,23 @@
113+# -*- coding: utf-8 -*-
114+# Generated by Django 1.11.11 on 2018-03-27 16:59
115+from __future__ import unicode_literals
116+
117+from django.db import (
118+ migrations,
119+ models,
120+)
121+
122+
123+class Migration(migrations.Migration):
124+
125+ dependencies = [
126+ ('maasserver', '0152_add_usergroup_local'),
127+ ]
128+
129+ operations = [
130+ migrations.AddField(
131+ model_name='node',
132+ name='skip_bmc_config',
133+ field=models.BooleanField(default=False),
134+ ),
135+ ]
136diff --git a/src/maasserver/models/node.py b/src/maasserver/models/node.py
137index a6d49ce..c8821e8 100644
138--- a/src/maasserver/models/node.py
139+++ b/src/maasserver/models/node.py
140@@ -857,6 +857,8 @@ class Node(CleanSave, TimestampedModel):
141 :ivar enable_ssh: An optional flag to indicate if this node can have
142 ssh enabled during commissioning, allowing the user to ssh into the
143 machine's commissioning environment using the user's SSH key.
144+ :ivar skip_bmc_config: An optional flag to indicate if this node can be
145+ commissioned without re-running the IPMI auto discovery mechanism.
146 :ivar skip_networking: An optional flag to indicate if this node
147 networking configuration doesn't need to be touched when it is
148 commissioned.
149@@ -1039,6 +1041,7 @@ class Node(CleanSave, TimestampedModel):
150 # 2. Skip reconfiguring networking when a node is commissioned.
151 # 3. Skip reconfiguring storage when a node is commissioned.
152 enable_ssh = BooleanField(default=False)
153+ skip_bmc_config = BooleanField(default=False)
154 skip_networking = BooleanField(default=False)
155 skip_storage = BooleanField(default=False)
156
157@@ -1854,9 +1857,9 @@ class Node(CleanSave, TimestampedModel):
158
159 @transactional
160 def start_commissioning(
161- self, user, enable_ssh=False, skip_networking=False,
162- skip_storage=False, commissioning_scripts=[],
163- testing_scripts=[]):
164+ self, user, enable_ssh=False, skip_bmc_config=False,
165+ skip_networking=False, skip_storage=False,
166+ commissioning_scripts=[], testing_scripts=[]):
167 """Install OS and self-test a new node.
168
169 :return: a `Deferred` which contains the post-commit tasks that are
170@@ -1879,6 +1882,7 @@ class Node(CleanSave, TimestampedModel):
171
172 # Set the commissioning options on the node.
173 self.enable_ssh = enable_ssh
174+ self.skip_bmc_config = skip_bmc_config
175 self.skip_networking = skip_networking
176 self.skip_storage = skip_storage
177
178diff --git a/src/maasserver/models/tests/test_node.py b/src/maasserver/models/tests/test_node.py
179index bb23d00..5ce5244 100644
180--- a/src/maasserver/models/tests/test_node.py
181+++ b/src/maasserver/models/tests/test_node.py
182@@ -2685,6 +2685,7 @@ class TestNode(MAASServerTestCase):
183 post_commit()))
184 admin = factory.make_admin()
185 enable_ssh = factory.pick_bool()
186+ skip_bmc_config = factory.pick_bool()
187 skip_networking = factory.pick_bool()
188 skip_storage = factory.pick_bool()
189 node.start_commissioning(
190@@ -2694,6 +2695,7 @@ class TestNode(MAASServerTestCase):
191 node = reload_object(node)
192 expected_attrs = {
193 'enable_ssh': enable_ssh,
194+ 'skip_bmc_config': skip_bmc_config,
195 'skip_networking': skip_networking,
196 'skip_storage': skip_storage,
197 }
198diff --git a/src/maasserver/node_action.py b/src/maasserver/node_action.py
199index 45c13a2..72b56c3 100644
200--- a/src/maasserver/node_action.py
201+++ b/src/maasserver/node_action.py
202@@ -233,14 +233,15 @@ class Commission(NodeAction):
203 for_type = {NODE_TYPE.MACHINE}
204
205 def execute(
206- self, enable_ssh=False, skip_networking=False,
207- skip_storage=False, commissioning_scripts=[],
208- testing_scripts=[]):
209+ self, enable_ssh=False, skip_bmc_config=False,
210+ skip_networking=False, skip_storage=False,
211+ commissioning_scripts=[], testing_scripts=[]):
212 """See `NodeAction.execute`."""
213 try:
214 self.node.start_commissioning(
215 self.user,
216 enable_ssh=enable_ssh,
217+ skip_bmc_config=skip_bmc_config,
218 skip_networking=skip_networking,
219 skip_storage=skip_storage,
220 commissioning_scripts=commissioning_scripts,
221diff --git a/src/maasserver/websockets/handlers/controller.py b/src/maasserver/websockets/handlers/controller.py
222index f207da5..9fbe5c8 100644
223--- a/src/maasserver/websockets/handlers/controller.py
224+++ b/src/maasserver/websockets/handlers/controller.py
225@@ -60,6 +60,7 @@ class ControllerHandler(MachineHandler):
226 "gateway_link_ipv4",
227 "gateway_link_ipv6",
228 "enable_ssh",
229+ "skip_bmc_config",
230 "skip_networking",
231 "skip_storage",
232 "instance_power_parameters",
233diff --git a/src/maasserver/websockets/handlers/device.py b/src/maasserver/websockets/handlers/device.py
234index 7469821..dc5374f 100644
235--- a/src/maasserver/websockets/handlers/device.py
236+++ b/src/maasserver/websockets/handlers/device.py
237@@ -113,6 +113,7 @@ class DeviceHandler(NodeHandler):
238 "gateway_link_ipv4",
239 "gateway_link_ipv6",
240 "enable_ssh",
241+ "skip_bmc_config",
242 "skip_networking",
243 "skip_storage",
244 "instance_power_parameters",
245diff --git a/src/maasserver/websockets/handlers/machine.py b/src/maasserver/websockets/handlers/machine.py
246index b1c0e20..375b0fb 100644
247--- a/src/maasserver/websockets/handlers/machine.py
248+++ b/src/maasserver/websockets/handlers/machine.py
249@@ -149,6 +149,7 @@ class MachineHandler(NodeHandler):
250 "gateway_link_ipv4",
251 "gateway_link_ipv6",
252 "enable_ssh",
253+ "skip_bmc_config",
254 "skip_networking",
255 "skip_storage",
256 "instance_power_parameters",
257diff --git a/src/metadataserver/user_data/templates/commissioning.template b/src/metadataserver/user_data/templates/commissioning.template
258index bea840f..1ba2510 100644
259--- a/src/metadataserver/user_data/templates/commissioning.template
260+++ b/src/metadataserver/user_data/templates/commissioning.template
261@@ -26,7 +26,7 @@ add_ipmi_config() {
262
263 main() {
264 prep_maas_api_helper
265-
266+ {{if not node.skip_bmc_config}}
267 # LP:1730524 - Make sure we can signal the metadata service before updating
268 # the BMC username and password.
269 signal WORKING "Starting [maas-bmc-autodetect]" || exit 1
270@@ -67,6 +67,7 @@ main() {
271 "--power-type=${power_type}" "--power-parameters=${power_settings}" \
272 WORKING "Finished [maas-bmc-autodetect]"
273 fi
274+ {{endif}}
275
276 maas-run-remote-scripts "--config=${CRED_CFG}" "${TEMP_D}"
277 }
278@@ -101,6 +102,5 @@ add_bin "maas-run-remote-scripts" <<"END_MAAS_RUN_REMOTE_SCRIPTS"
279 {{maas_run_remote_scripts_py}}
280 END_MAAS_RUN_REMOTE_SCRIPTS
281
282-
283 main
284 exit

Subscribers

People subscribed via source and target branches