Merge lp:~rvb/maas/di-api-bug-1456969-1.7 into lp:maas/1.7

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
Merged at revision: 3369
Proposed branch: lp:~rvb/maas/di-api-bug-1456969-1.7
Merge into: lp:maas/1.7
Diff against target: 252 lines (+69/-5)
7 files modified
docs/changelog.rst (+9/-0)
src/maasserver/api/nodes.py (+11/-1)
src/maasserver/api/tests/test_enlistment.py (+4/-1)
src/maasserver/api/tests/test_node.py (+23/-0)
src/maasserver/forms.py (+13/-0)
src/maasserver/testing/factory.py (+7/-3)
src/maasserver/tests/test_forms_node.py (+2/-0)
To merge this branch: bzr merge lp:~rvb/maas/di-api-bug-1456969-1.7
Reviewer Review Type Date Requested Status
Blake Rouse (community) Approve
Review via email: mp+260172@code.launchpad.net

Commit message

Backport 3921: Expose the 'boot_type' field on the API. This controls whether the node will use curtin or di to install itself. The di installation is deprecated but before we fully support advanced networking and storage configuration in curtin, we still have to support di.

To post a comment you must log in.
Revision history for this message
Blake Rouse (blake-rouse) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'docs/changelog.rst'
2--- docs/changelog.rst 2015-05-21 17:35:36 +0000
3+++ docs/changelog.rst 2015-05-26 16:37:00 +0000
4@@ -2,6 +2,15 @@
5 Changelog
6 =========
7
8+1.7.5
9+=====
10+
11+Bug Fix Update
12+--------------
13+
14+#1456969 MAAS cli/API: missing option set use-fast-installer /
15+ use-debian-installer
16+
17 1.7.4
18 =====
19
20
21=== modified file 'src/maasserver/api/nodes.py'
22--- src/maasserver/api/nodes.py 2015-03-06 18:23:33 +0000
23+++ src/maasserver/api/nodes.py 2015-05-26 16:37:00 +0000
24@@ -100,6 +100,7 @@
25 'substatus',
26 'osystem',
27 'distro_series',
28+ 'boot_type',
29 'netboot',
30 'power_type',
31 'power_state',
32@@ -235,6 +236,11 @@
33 :type power_parameters_skip_check: unicode
34 :param zone: Name of a valid physical zone in which to place this node
35 :type zone: unicode
36+ :param boot_type: The installation type of the node. 'fastpath': use
37+ the default installer. 'di' use the debian installer.
38+ Note that using 'di' is now deprecated and will be removed in favor
39+ of the default installer in MAAS 1.9.
40+ :type boot_type: unicode
41
42 Returns 404 if the node is node found.
43 Returns 403 if the user does not have permission to update the node.
44@@ -243,7 +249,6 @@
45 system_id=system_id, user=request.user, perm=NODE_PERMISSION.EDIT)
46 Form = get_node_edit_form(request.user)
47 form = Form(data=request.data, instance=node)
48-
49 if form.is_valid():
50 return form.save()
51 else:
52@@ -689,6 +694,11 @@
53 and re-install its operating system. In anonymous enlistment and when
54 the enlistment is done by a non-admin, the node is held in the
55 "New" state for approval by a MAAS admin.
56+ :param boot_type: The installation type of the node. 'fastpath': use
57+ the default installer. 'di' use the debian installer.
58+ Note that using 'di' is now deprecated and will be removed in favor
59+ of the default installer in MAAS 1.9.
60+ :type boot_type: unicode
61 """
62 # XXX 2014-02-11 bug=1278685
63 # There's no documentation here on what parameters can be passed!
64
65=== modified file 'src/maasserver/api/tests/test_enlistment.py'
66--- src/maasserver/api/tests/test_enlistment.py 2014-12-02 16:47:25 +0000
67+++ src/maasserver/api/tests/test_enlistment.py 2015-05-26 16:37:00 +0000
68@@ -479,7 +479,7 @@
69 'architecture': make_usable_architecture(self),
70 'mac_addresses': ['aa:bb:cc:dd:ee:ff'],
71 })
72- self.assertEqual(httplib.OK, response.status_code)
73+ self.assertEqual(httplib.OK, response.status_code, response.content)
74 system_id = json.loads(response.content)['system_id']
75 self.assertEqual(
76 NODE_STATUS.NEW,
77@@ -526,6 +526,7 @@
78 'osystem',
79 'distro_series',
80 'netboot',
81+ 'boot_type',
82 'power_type',
83 'power_state',
84 'tag_names',
85@@ -622,6 +623,7 @@
86 'osystem',
87 'distro_series',
88 'netboot',
89+ 'boot_type',
90 'power_type',
91 'power_state',
92 'resource_uri',
93@@ -772,6 +774,7 @@
94 'osystem',
95 'distro_series',
96 'netboot',
97+ 'boot_type',
98 'power_type',
99 'power_state',
100 'resource_uri',
101
102=== modified file 'src/maasserver/api/tests/test_node.py'
103--- src/maasserver/api/tests/test_node.py 2015-03-06 18:23:33 +0000
104+++ src/maasserver/api/tests/test_node.py 2015-05-26 16:37:00 +0000
105@@ -26,6 +26,7 @@
106 from maasserver.api import nodes as api_nodes
107 from maasserver.enum import (
108 IPADDRESS_TYPE,
109+ NODE_BOOT,
110 NODE_STATUS,
111 NODE_STATUS_CHOICES,
112 POWER_STATE,
113@@ -184,6 +185,14 @@
114 parsed_result['zone']['name'],
115 parsed_result['zone']['description']])
116
117+ def test_GET_returns_boot_type(self):
118+ node = factory.make_Node()
119+ response = self.client.get(self.get_node_uri(node))
120+ self.assertEqual(httplib.OK, response.status_code)
121+ parsed_result = json.loads(response.content)
122+ self.assertEqual(
123+ node.boot_type, parsed_result['boot_type'])
124+
125 def test_GET_refuses_to_access_nonexistent_node(self):
126 # When fetching a Node, the api returns a 'Not Found' (404) error
127 # if no node is found.
128@@ -930,6 +939,20 @@
129 node = reload_object(node)
130 self.assertEqual(original_setting, node.disable_ipv4)
131
132+ def test_PUT_updates_boot_type(self):
133+ node = factory.make_Node(
134+ owner=self.logged_in_user,
135+ architecture=make_usable_architecture(self),
136+ boot_type=NODE_BOOT.FASTPATH,
137+ )
138+ response = self.client_put(
139+ self.get_node_uri(node), {'boot_type': NODE_BOOT.DEBIAN})
140+ parsed_result = json.loads(response.content)
141+ self.assertEqual(httplib.OK, response.status_code, response.content)
142+ node = reload_object(node)
143+ self.assertEqual(node.boot_type, parsed_result['boot_type'])
144+ self.assertEqual(node.boot_type, NODE_BOOT.DEBIAN)
145+
146 def test_DELETE_deletes_node(self):
147 # The api allows to delete a Node.
148 self.become_admin()
149
150=== modified file 'src/maasserver/forms.py'
151--- src/maasserver/forms.py 2014-12-15 09:59:57 +0000
152+++ src/maasserver/forms.py 2015-05-26 16:37:00 +0000
153@@ -86,6 +86,8 @@
154 from maasserver.enum import (
155 BOOT_RESOURCE_FILE_TYPE,
156 BOOT_RESOURCE_TYPE,
157+ NODE_BOOT,
158+ NODE_BOOT_CHOICES,
159 NODE_STATUS,
160 NODEGROUPINTERFACE_MANAGEMENT,
161 NODEGROUPINTERFACE_MANAGEMENT_CHOICES,
162@@ -481,6 +483,13 @@
163 self.cleaned_data['disable_ipv4'] = False
164 return self.cleaned_data['disable_ipv4']
165
166+ def clean_boot_type(self):
167+ boot_type = self.cleaned_data.get('boot_type')
168+ if not boot_type:
169+ return NODE_BOOT.FASTPATH
170+ else:
171+ return boot_type
172+
173 def clean(self):
174 cleaned_data = super(NodeForm, self).clean()
175 if self.new_node and self.data.get('disable_ipv4') is None:
176@@ -578,6 +587,9 @@
177 "does not manage DNS, then the host name as entered will be the "
178 "FQDN."))
179
180+ boot_type = forms.ChoiceField(
181+ choices=NODE_BOOT_CHOICES, initial=NODE_BOOT.FASTPATH, required=False)
182+
183 class Meta:
184 model = Node
185
186@@ -590,6 +602,7 @@
187 'distro_series',
188 'license_key',
189 'disable_ipv4',
190+ 'boot_type',
191 )
192
193
194
195=== modified file 'src/maasserver/testing/factory.py'
196--- src/maasserver/testing/factory.py 2014-12-04 12:33:26 +0000
197+++ src/maasserver/testing/factory.py 2015-05-26 16:37:00 +0000
198@@ -30,6 +30,7 @@
199 BOOT_RESOURCE_FILE_TYPE,
200 BOOT_RESOURCE_TYPE,
201 IPADDRESS_TYPE,
202+ NODE_BOOT,
203 NODE_STATUS,
204 NODEGROUP_STATUS,
205 NODEGROUPINTERFACE_MANAGEMENT,
206@@ -213,8 +214,9 @@
207 def make_Node(self, mac=False, hostname=None, status=None,
208 architecture="i386/generic", updated=None,
209 created=None, nodegroup=None, routers=None, zone=None,
210- power_type=None, networks=None, sortable_name=False,
211- power_state=None, disable_ipv4=None, **kwargs):
212+ power_type=None, networks=None, boot_type=None,
213+ sortable_name=False, power_state=None, disable_ipv4=None,
214+ **kwargs):
215 """Make a :class:`Node`.
216
217 :param sortable_name: If `True`, use a that will sort consistently
218@@ -242,11 +244,13 @@
219 power_state = self.pick_enum(POWER_STATE)
220 if disable_ipv4 is None:
221 disable_ipv4 = self.pick_bool()
222+ if boot_type is None:
223+ boot_type = self.pick_enum(NODE_BOOT)
224 node = Node(
225 hostname=hostname, status=status, architecture=architecture,
226 nodegroup=nodegroup, routers=routers, zone=zone,
227 power_type=power_type, disable_ipv4=disable_ipv4,
228- power_state=power_state,
229+ power_state=power_state, boot_type=boot_type,
230 **kwargs)
231 self._save_node_unchecked(node)
232 # We do not generate random networks by default because the limited
233
234=== modified file 'src/maasserver/tests/test_forms_node.py'
235--- src/maasserver/tests/test_forms_node.py 2014-10-19 20:08:50 +0000
236+++ src/maasserver/tests/test_forms_node.py 2015-05-26 16:37:00 +0000
237@@ -69,6 +69,7 @@
238 'distro_series',
239 'license_key',
240 'disable_ipv4',
241+ 'boot_type',
242 'nodegroup'
243 ], list(form.fields))
244
245@@ -492,6 +493,7 @@
246 'distro_series',
247 'license_key',
248 'disable_ipv4',
249+ 'boot_type',
250 'power_type',
251 'power_parameters',
252 'cpu_count',

Subscribers

People subscribed via source and target branches

to all changes: