Merge lp:~ltrager/maas/otheros_qwerks into lp:~maas-committers/maas/trunk

Proposed by Lee Trager
Status: Merged
Approved by: Lee Trager
Approved revision: no longer in the source branch.
Merged at revision: 4429
Proposed branch: lp:~ltrager/maas/otheros_qwerks
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 376 lines (+152/-23)
11 files modified
docs/networking.rst (+2/-1)
docs/storage.rst (+5/-4)
src/maasserver/preseed.py (+16/-3)
src/maasserver/static/js/angular/controllers/node_details.js (+14/-0)
src/maasserver/static/js/angular/controllers/tests/test_node_details.js (+18/-0)
src/maasserver/static/partials/node-details.html (+16/-2)
src/maasserver/testing/factory.py (+16/-0)
src/maasserver/tests/test_forms_commissioning.py (+1/-5)
src/maasserver/tests/test_preseed.py (+31/-3)
src/maasserver/utils/osystems.py (+9/-2)
src/maasserver/utils/tests/test_osystems.py (+24/-3)
To merge this branch: bzr merge lp:~ltrager/maas/otheros_qwerks
Reviewer Review Type Date Requested Status
Blake Rouse (community) Approve
Review via email: mp+276043@code.launchpad.net

Commit message

Only pass custom storage and networking options to curtin if the OS is supported

Description of the change

When generating the preseed data to pass to curtin check if the osystem is Ubuntu. If it isn't warn the user and pass no storage and networking data. In the absence of data this tells curtin to use a flat storage layout and the OS networking default configuration.

In the UI we also display a warning to the user in both the networking and storage section telling them that the shown configuration was not used on the due to an OS other than Ubuntu being used. We currently have no way of informing CLI users this so I added a note in the documentation.

I also came across a bug where when deploying a non Ubuntu OS with min_hwe_kernel set we were deploying with the commissioning OS(trusty) and the default kernel(hwe-t). This patch also ensures that when a non-Ubuntu OS is deployed min_hwe_kernel is respected during deployment.

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

Looks good. Got some comments that need to be addressed. Not going to block you on landing this branch because of the issues. just fix them before landing. Mainly the extra MockNeverCalled? Don't know if that is any different than MockNotCalled.

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (1003.7 KiB)

The attempt to merge lp:~ltrager/maas/otheros_qwerks into lp:maas failed. Below is the output from the failed tests.

Get:1 http://security.ubuntu.com trusty-security InRelease [64.4 kB]
Ign http://nova.clouds.archive.ubuntu.com trusty InRelease
Get:2 http://nova.clouds.archive.ubuntu.com trusty-updates InRelease [64.4 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty Release.gpg
Hit http://nova.clouds.archive.ubuntu.com trusty Release
Get:3 http://security.ubuntu.com trusty-security/main Sources [98.0 kB]
Get:4 http://security.ubuntu.com trusty-security/universe Sources [31.0 kB]
Get:5 http://nova.clouds.archive.ubuntu.com trusty-updates/main Sources [241 kB]
Get:6 http://security.ubuntu.com trusty-security/main amd64 Packages [357 kB]
Get:7 http://nova.clouds.archive.ubuntu.com trusty-updates/universe Sources [143 kB]
Get:8 http://nova.clouds.archive.ubuntu.com trusty-updates/main amd64 Packages [637 kB]
Get:9 http://security.ubuntu.com trusty-security/universe amd64 Packages [117 kB]
Hit http://security.ubuntu.com trusty-security/main Translation-en
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Get:10 http://nova.clouds.archive.ubuntu.com trusty-updates/universe amd64 Packages [326 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/main Sources
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Sources
Hit http://nova.clouds.archive.ubuntu.com trusty/main amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en
Ign http://nova.clouds.archive.ubuntu.com trusty/main Translation-en_US
Ign http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en_US
Fetched 2,080 kB in 4s (515 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
     --no-install-recommends install apache2 authbind bind9 bind9utils build-essential bzr-builddeb chromium-browser chromium-chromedriver curl daemontools debhelper dh-apport dh-systemd distro-info dnsutils firefox freeipmi-tools git gjs ipython isc-dhcp-common libjs-angularjs libjs-jquery libjs-jquery-hotkeys libjs-yui3-full libjs-yui3-min libpq-dev make nodejs-legacy npm pep8 phantomjs postgresql pyflakes python-apt python-bson python-bzrlib python-convoy python-coverage python-crochet python-cssselect python-curtin python-dev python-distro-info python-django python-django-piston python-django-south python-djorm-ext-pgarray python-docutils python-extras python-fixtures python-flake8 python-formencode python-hivex python-httplib2 python-jinja2 python-jsonschema python-lxml python-mock python-netaddr python-netifaces python-nose python-oauth python-openssl python-paramiko python-pexpect python-pip python-pocket-lint python-psycopg2 python-pyinotify python-pyparsing python-seamicroclient python-simplejson python-simplestreams python-sphinx python-subunit python-tempita python-testresources python-testscenarios python-tes...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'docs/networking.rst'
2--- docs/networking.rst 2015-10-19 18:31:19 +0000
3+++ docs/networking.rst 2015-10-28 21:00:41 +0000
4@@ -8,7 +8,8 @@
5
6 .. note::
7
8- This feature is available in MAAS versions 1.9 and above.
9+ This feature is available in MAAS versions 1.9 and above on Ubuntu
10+ deployments.
11
12 MAAS 1.9 adds support for the modeling of a wide variety of networking concepts
13 and configurations.
14
15=== modified file 'docs/storage.rst'
16--- docs/storage.rst 2015-10-20 16:02:23 +0000
17+++ docs/storage.rst 2015-10-28 21:00:41 +0000
18@@ -8,10 +8,11 @@
19
20 .. note::
21
22- This feature is available in MAAS versions 1.9 and above.
23- If you're writing a client application, you can check if MAAS
24- supports this feature via the web API; see the documentation for the
25- ``storage-deployment`` capability :ref:`here<cap-storage-deployment>`.
26+ This feature is available in MAAS versions 1.9 and above on Ubuntu
27+ deployments. If you're writing a client application, you can check
28+ if MAAS supports this feature via the web API; see the documentation
29+ for the ``storage-deployment`` capability
30+ :ref:`here<cap-storage-deployment>`.
31
32 MAAS has the ability to configure any storage layout during node deployment.
33 MAAS doesn't just do simple partitioning it supports complex storage layouts,
34
35=== modified file 'src/maasserver/preseed.py'
36--- src/maasserver/preseed.py 2015-09-24 16:22:12 +0000
37+++ src/maasserver/preseed.py 2015-10-28 21:00:41 +0000
38@@ -230,16 +230,29 @@
39 kernel_config = compose_curtin_kernel_preseed(node)
40 verbose_config = compose_curtin_verbose_preseed()
41
42+ supports_custom_storage = True
43 # Get the storage configration if curtin supports custom storage.
44- storage_config = compose_curtin_storage_config(node)
45 if not curtin_supports_custom_storage():
46 maaslog.error(
47 "%s: cannot deploy with custom storage config; missing support "
48 "from curtin." % node.hostname)
49+ supports_custom_storage = False
50+
51+ if node.osystem != "ubuntu":
52+ maaslog.error(
53+ "%s: is not being deployed with custom storage or networking "
54+ "config; using operating system other than Ubuntu." %
55+ node.hostname)
56+ supports_custom_storage = False
57+ network_config = []
58+ else:
59+ network_config = compose_curtin_network_config(node)
60+
61+ if supports_custom_storage:
62+ storage_config = compose_curtin_storage_config(node)
63+ else:
64 storage_config = []
65
66- network_config = compose_curtin_network_config(node)
67-
68 # Pack the curtin and the configuration into a script to execute on the
69 # deploying node.
70 return pack_install(
71
72=== modified file 'src/maasserver/static/js/angular/controllers/node_details.js'
73--- src/maasserver/static/js/angular/controllers/node_details.js 2015-10-19 23:54:54 +0000
74+++ src/maasserver/static/js/angular/controllers/node_details.js 2015-10-28 21:00:41 +0000
75@@ -566,6 +566,20 @@
76 return os_release;
77 };
78
79+ $scope.isUbuntuOS = function() {
80+ // This will get called very early and node can be empty.
81+ // In that case just return an empty string. It will be
82+ // called again to show the correct information.
83+ if(!angular.isObject($scope.node)) {
84+ return false;
85+ }
86+
87+ if($scope.node.osystem === "ubuntu") {
88+ return true;
89+ }
90+ return false;
91+ };
92+
93 // Return true if there is an action error.
94 $scope.isActionError = function() {
95 return $scope.actionError !== null;
96
97=== modified file 'src/maasserver/static/js/angular/controllers/tests/test_node_details.js'
98--- src/maasserver/static/js/angular/controllers/tests/test_node_details.js 2015-09-27 20:01:05 +0000
99+++ src/maasserver/static/js/angular/controllers/tests/test_node_details.js 2015-10-28 21:00:41 +0000
100@@ -837,6 +837,24 @@
101 });
102 });
103
104+ describe("isUbuntuOS", function() {
105+ it("returns true when ubuntu", function() {
106+ var controller = makeController();
107+ $scope.node = node;
108+ node.osystem = 'ubuntu';
109+ node.distro_series = makeName("distro_series");
110+ expect($scope.isUbuntuOS()).toBe(true);
111+ });
112+
113+ it("returns false when otheros", function() {
114+ var controller = makeController();
115+ $scope.node = node;
116+ node.osystem = makeName("osystem");
117+ node.distro_series = makeName("distro_series");
118+ expect($scope.isUbuntuOS()).toBe(false);
119+ });
120+ });
121+
122 describe("isActionError", function() {
123
124 it("returns true if actionError", function() {
125
126=== modified file 'src/maasserver/static/partials/node-details.html'
127--- src/maasserver/static/partials/node-details.html 2015-10-28 18:53:35 +0000
128+++ src/maasserver/static/partials/node-details.html 2015-10-28 21:00:41 +0000
129@@ -249,8 +249,8 @@
130 </dd>
131 <dt class="two-col ng-hide" data-ng-show="node.show_os_info">Operating System</dt>
132 <dd class="four-col last-col ng-hide" data-ng-show="node.show_os_info">{$ getOSText() $}</dd>
133- <dt class="two-col ng-hide" data-ng-show="node.show_os_info">Kernel</dt>
134- <dd class="four-col last-col ng-hide" data-ng-show="node.show_os_info">{$ node.hwe_kernel $}</dd>
135+ <dt class="two-col ng-hide" data-ng-show="node.show_os_info && isUbuntuOS()">Kernel</dt>
136+ <dd class="four-col last-col ng-hide" data-ng-show="node.show_os_info && isUbuntuOS()">{$ node.hwe_kernel $}</dd>
137 <dt class="two-col ng-hide" data-ng-show="node.show_os_info && node.third_party_driver">Third Party Driver</dt>
138 <dd class="four-col last-col ng-hide" data-ng-show="node.show_os_info && node.third_party_driver">
139 {$ node.third_party_driver.module $} "{$ node.third_party_driver.comment $}"
140@@ -323,6 +323,13 @@
141 </li>
142 </ul>
143 </div>
144+ <div class="twelve-col error ng-hide" data-ng-show="!isUbuntuOS()">
145+ <ul class="flash-messages">
146+ <li class="flash-messages__item info">
147+ Custom network configuration only supported on Ubuntu. Using OS default configuration.
148+ </li>
149+ </ul>
150+ </div>
151 <div class="table margin-bottom">
152 <header class="table__head">
153 <div class="table__row">
154@@ -633,6 +640,13 @@
155 </li>
156 </ul>
157 </div>
158+ <div class="twelve-col error ng-hide" data-ng-show="!isUbuntuOS()">
159+ <ul class="flash-messages">
160+ <li class="flash-messages__item info">
161+ Custom storage configuration only supported on Ubuntu. Using flat layout.
162+ </li>
163+ </ul>
164+ </div>
165 <div class="twelve-col padding-bottom">
166 <h3>File System</h3>
167 <section class="table">
168
169=== modified file 'src/maasserver/testing/factory.py'
170--- src/maasserver/testing/factory.py 2015-10-27 20:53:16 +0000
171+++ src/maasserver/testing/factory.py 2015-10-28 21:00:41 +0000
172@@ -26,6 +26,7 @@
173 import random
174 import time
175
176+from distro_info import UbuntuDistroInfo
177 from django.contrib.auth.models import User
178 from django.test.client import RequestFactory
179 from django.utils import timezone
180@@ -236,6 +237,21 @@
181 releases = osystem.get_supported_commissioning_releases()
182 return random.choice(releases)
183
184+ def pick_ubuntu_release(self, but_not=None):
185+ """Pick a random supported Ubuntu release.
186+
187+ :param but_not: Exclude these releases from the result
188+ :type but_not: Sequence
189+ """
190+ ubuntu_releases = UbuntuDistroInfo()
191+ supported_releases = ubuntu_releases.all[
192+ ubuntu_releases.all.index('precise'):]
193+ if but_not is None:
194+ but_not = []
195+ return random.choice(
196+ [choice for choice in supported_releases if choice not in but_not],
197+ ).decode("utf-8")
198+
199 def _save_node_unchecked(self, node):
200 """Save a :class:`Node`, but circumvent status transition checks."""
201 valid_initial_states = NODE_TRANSITIONS[None]
202
203=== modified file 'src/maasserver/tests/test_forms_commissioning.py'
204--- src/maasserver/tests/test_forms_commissioning.py 2015-10-27 17:50:36 +0000
205+++ src/maasserver/tests/test_forms_commissioning.py 2015-10-28 21:00:41 +0000
206@@ -14,9 +14,6 @@
207 __metaclass__ = type
208 __all__ = []
209
210-import random
211-
212-from distro_info import UbuntuDistroInfo
213 from django.core.files.uploadedfile import SimpleUploadedFile
214 from maasserver.enum import BOOT_RESOURCE_TYPE
215 from maasserver.forms import (
216@@ -50,8 +47,7 @@
217 field.error_messages['invalid_choice'])
218
219 def test_commissioningform_contains_real_and_ui_choice(self):
220- ubuntu_releases = UbuntuDistroInfo()
221- release = random.choice(ubuntu_releases.all).decode("utf-8")
222+ release = factory.pick_ubuntu_release()
223 name = 'ubuntu/%s' % release
224 kernel = 'hwe-' + release[0]
225 factory.make_usable_boot_resource(
226
227=== modified file 'src/maasserver/tests/test_preseed.py'
228--- src/maasserver/tests/test_preseed.py 2015-09-15 01:39:03 +0000
229+++ src/maasserver/tests/test_preseed.py 2015-10-28 21:00:41 +0000
230@@ -78,7 +78,10 @@
231 from maasserver.testing.testcase import MAASServerTestCase
232 from maasserver.utils import absolute_reverse
233 from maasserver.utils.curtin import curtin_supports_webhook_events
234-from maastesting.matchers import MockCalledOnceWith
235+from maastesting.matchers import (
236+ MockCalledOnceWith,
237+ MockNotCalled,
238+)
239 from metadataserver.models import NodeKey
240 from provisioningserver.drivers.osystem.ubuntu import UbuntuOS
241 from provisioningserver.rpc.exceptions import NoConnectionsAvailable
242@@ -734,7 +737,7 @@
243 PreseedRPCMixin, BootImageHelperMixin, MAASServerTestCase):
244 """Tests for `get_curtin_userdata`."""
245
246- def test_get_curtin_userdata_calls_compose_curtin_storage_config(self):
247+ def test_get_curtin_userdata_calls_compose_curtin_config_on_ubuntu(self):
248 node = factory.make_Node(
249 nodegroup=self.rpc_nodegroup, boot_type=NODE_BOOT.FASTPATH,
250 interface=True)
251@@ -744,10 +747,35 @@
252 self.configure_get_boot_images_for_node(node, 'xinstall')
253 mock_compose_storage = self.patch(
254 preseed_module, "compose_curtin_storage_config")
255-
256+ mock_compose_network = self.patch(
257+ preseed_module, "compose_curtin_network_config")
258+ self.patch(
259+ preseed_module, "curtin_supports_custom_storage").value = True
260+ node.osystem = u'ubuntu'
261 user_data = get_curtin_userdata(node)
262 self.assertIn("PREFIX='curtin'", user_data)
263 self.assertThat(mock_compose_storage, MockCalledOnceWith(node))
264+ self.assertThat(mock_compose_network, MockCalledOnceWith(node))
265+
266+ def test_get_curtin_userdata_doesnt_call_compose_config_on_otheros(self):
267+ node = factory.make_Node(
268+ nodegroup=self.rpc_nodegroup, boot_type=NODE_BOOT.FASTPATH,
269+ interface=True)
270+ factory.make_NodeGroupInterface(
271+ node.nodegroup, management=NODEGROUPINTERFACE_MANAGEMENT.DHCP)
272+ arch, subarch = node.architecture.split('/')
273+ self.configure_get_boot_images_for_node(node, 'xinstall')
274+ mock_compose_storage = self.patch(
275+ preseed_module, "compose_curtin_storage_config")
276+ mock_compose_network = self.patch(
277+ preseed_module, "compose_curtin_network_config")
278+ self.patch(
279+ preseed_module, "curtin_supports_custom_storage").value = True
280+ node.osystem = factory.make_name("osystem")
281+ user_data = get_curtin_userdata(node)
282+ self.assertIn("PREFIX='curtin'", user_data)
283+ self.assertThat(mock_compose_storage, MockNotCalled())
284+ self.assertThat(mock_compose_network, MockNotCalled())
285
286 def test_get_curtin_userdata_calls_curtin_supports_custom_storage(self):
287 node = factory.make_Node(
288
289=== modified file 'src/maasserver/utils/osystems.py'
290--- src/maasserver/utils/osystems.py 2015-10-24 00:07:26 +0000
291+++ src/maasserver/utils/osystems.py 2015-10-28 21:00:41 +0000
292@@ -34,6 +34,7 @@
293 from maasserver.models import (
294 BootResource,
295 BootSourceCache,
296+ Config,
297 )
298
299
300@@ -286,12 +287,18 @@
301 os/release/architecture combination, and that the selected hwe_kernel is >=
302 min_hwe_kernel. If no hwe_kernel is selected one will be chosen.
303 """
304- # The hwe_kernel feature is only supported on Ubuntu
305- if((osystem and "ubuntu" not in osystem.lower()) or
306+ if (not osystem or
307 (not architecture or architecture == '') or
308 (not distro_series or distro_series == '')):
309 return hwe_kernel
310
311+ # If we're not deploying Ubuntu we are just setting the kernel to be used
312+ # during deployment
313+ if osystem != "ubuntu":
314+ osystem = Config.objects.get_config('commissioning_osystem')
315+ distro_series = Config.objects.get_config(
316+ 'commissioning_distro_series')
317+
318 arch, subarch = architecture.split('/')
319
320 if (subarch != 'generic' and
321
322=== modified file 'src/maasserver/utils/tests/test_osystems.py'
323--- src/maasserver/utils/tests/test_osystems.py 2015-10-27 17:50:36 +0000
324+++ src/maasserver/utils/tests/test_osystems.py 2015-10-28 21:00:41 +0000
325@@ -24,7 +24,10 @@
326 make_rpc_release,
327 )
328 from maasserver.enum import BOOT_RESOURCE_TYPE
329-from maasserver.models import BootResource
330+from maasserver.models import (
331+ BootResource,
332+ Config,
333+)
334 from maasserver.testing.factory import factory
335 from maasserver.testing.osystems import make_usable_osystem
336 from maasserver.testing.testcase import MAASServerTestCase
337@@ -43,6 +46,7 @@
338 validate_hwe_kernel,
339 validate_osystem_and_distro_series,
340 )
341+from maastesting.matchers import MockAnyCall
342
343
344 class TestOsystems(MAASServerTestCase):
345@@ -264,8 +268,7 @@
346 self.assertEqual(choices, list_commissioning_choices([osystem]))
347
348 def test_make_hwe_kernel_ui_text_finds_release_from_bootsourcecache(self):
349- ubuntu_releases = UbuntuDistroInfo()
350- release = random.choice(ubuntu_releases.all).decode("utf-8")
351+ release = factory.pick_ubuntu_release()
352 kernel = 'hwe-' + release[0]
353 factory.make_usable_boot_resource(
354 name="ubuntu/%s" % release,
355@@ -445,3 +448,21 @@
356 ' min_hwe_kernel(hwe-v).', e.message)
357 exception_raised = True
358 self.assertEqual(True, exception_raised)
359+
360+ def test_validate_hwe_kern_always_sets_kern_with_commissionable_os(self):
361+ self.patch(
362+ BootResource.objects,
363+ 'get_usable_hwe_kernels').return_value = ('hwe-t', 'hwe-v')
364+ mock_get_config = self.patch(Config.objects, "get_config")
365+ mock_get_config.return_value = 'trusty'
366+ kernel = validate_hwe_kernel(
367+ None,
368+ 'hwe-v',
369+ '%s/generic' % factory.make_name('arch'),
370+ factory.make_name("osystem"),
371+ factory.make_name("distro"))
372+ self.assertThat(
373+ mock_get_config, MockAnyCall('commissioning_osystem'))
374+ self.assertThat(
375+ mock_get_config, MockAnyCall('commissioning_distro_series'))
376+ self.assertEquals('hwe-v', kernel)