Merge ~ltrager/maas:lp1701694 into maas:master

Proposed by Lee Trager on 2017-07-15
Status: Merged
Approved by: Lee Trager on 2017-07-19
Approved revision: 25239e803f86997e504f0b8f76395cbb1c117a41
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~ltrager/maas:lp1701694
Merge into: maas:master
Diff against target: 645 lines (+142/-135)
24 files modified
src/maasserver/bootresources.py (+3/-3)
src/maasserver/forms/__init__.py (+11/-13)
src/maasserver/forms/tests/test_bootresource.py (+45/-2)
src/maasserver/models/bootresource.py (+12/-3)
src/maasserver/models/tests/test_bootresource.py (+21/-0)
src/maasserver/tests/test_bootresources.py (+3/-3)
src/maasserver/utils/osystems.py (+3/-4)
src/maasserver/utils/tests/test_osystems.py (+16/-0)
src/provisioningserver/drivers/osystem/__init__.py (+5/-4)
src/provisioningserver/drivers/osystem/bootloader.py (+0/-4)
src/provisioningserver/drivers/osystem/centos.py (+0/-4)
src/provisioningserver/drivers/osystem/custom.py (+0/-5)
src/provisioningserver/drivers/osystem/rhel.py (+0/-4)
src/provisioningserver/drivers/osystem/tests/test_base.py (+10/-1)
src/provisioningserver/drivers/osystem/tests/test_bootloader.py (+0/-5)
src/provisioningserver/drivers/osystem/tests/test_centos.py (+0/-17)
src/provisioningserver/drivers/osystem/tests/test_custom.py (+0/-9)
src/provisioningserver/drivers/osystem/tests/test_rhel.py (+0/-17)
src/provisioningserver/drivers/osystem/tests/test_ubuntu.py (+11/-6)
src/provisioningserver/drivers/osystem/tests/test_ubuntucore.py (+0/-9)
src/provisioningserver/drivers/osystem/ubuntu.py (+1/-9)
src/provisioningserver/drivers/osystem/ubuntucore.py (+0/-5)
src/provisioningserver/drivers/osystem/windows.py (+1/-5)
src/provisioningserver/testing/os.py (+0/-3)
Reviewer Review Type Date Requested Status
Blake Rouse (community) 2017-07-15 Approve on 2017-07-18
Review via email: mp+327482@code.launchpad.net

Commit message

Allow uploading images with the format osystem/release.

All images uploaded are now of rtype UPLOADED. Users can upload using the format osystem/release where osystem is a supported OS.

Fixes: LP: #1701694, #1361370

To post a comment you must log in.
Blake Rouse (blake-rouse) wrote :

Looks good, thanks for the fix.

review: Approve
~ltrager/maas:lp1701694 updated on 2017-07-19
25239e8... by Lee Trager on 2017-07-19

Merge branch 'lp1701694' of git+ssh://git.launchpad.net/~ltrager/maas into lp1701694

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/bootresources.py b/src/maasserver/bootresources.py
2index fd7ede4..514d460 100644
3--- a/src/maasserver/bootresources.py
4+++ b/src/maasserver/bootresources.py
5@@ -224,11 +224,11 @@ class SimpleStreamsHandler:
6 def get_boot_resource_identifiers(self, resource):
7 """Return tuple (os, arch, subarch, series) for the given resource."""
8 arch, subarch = resource.split_arch()
9- if resource.rtype == BOOT_RESOURCE_TYPE.UPLOADED:
10+ if '/' in resource.name:
11+ os, series = resource.name.split('/')
12+ else:
13 os = 'custom'
14 series = resource.name
15- else:
16- os, series = resource.name.split('/')
17 return (os, arch, subarch, series)
18
19 def get_product_name(self, resource):
20diff --git a/src/maasserver/forms/__init__.py b/src/maasserver/forms/__init__.py
21index b58b65a..a7314d0 100644
22--- a/src/maasserver/forms/__init__.py
23+++ b/src/maasserver/forms/__init__.py
24@@ -2283,11 +2283,19 @@ class BootResourceForm(MAASModelForm):
25 If the passed resource already has a match in the database then that
26 resource is returned. If not then the passed resource is returned.
27 """
28+ if resource.rtype == BOOT_RESOURCE_TYPE.UPLOADED:
29+ # Uploaded BootResources were previously generated, now they're
30+ # uploaded. Search for both to convert.
31+ rtypes = [
32+ BOOT_RESOURCE_TYPE.UPLOADED, BOOT_RESOURCE_TYPE.GENERATED]
33+ else:
34+ rtypes = [resource.type]
35 existing_resource = get_one(
36 BootResource.objects.filter(
37- rtype=resource.rtype,
38+ rtype__in=rtypes,
39 name=resource.name, architecture=resource.architecture))
40 if existing_resource is not None:
41+ existing_resource.rtype = resource.rtype
42 return existing_resource
43 return resource
44
45@@ -2335,24 +2343,14 @@ class BootResourceForm(MAASModelForm):
46 This implementation of `save` does not support the `commit` argument.
47 """
48 resource = super(BootResourceForm, self).save(commit=False)
49-
50- # XXX blake_r 2014-09-22 bug=1361370: Temporarily support the ability
51- # to upload a generated image. This should only exist while CentOS and
52- # Windows images need to be uploaded, rather than synced or generated.
53- if '/' not in resource.name:
54- label = 'uploaded'
55- resource.rtype = BOOT_RESOURCE_TYPE.UPLOADED
56- else:
57- label = 'generated'
58- resource.rtype = BOOT_RESOURCE_TYPE.GENERATED
59-
60+ resource.rtype = BOOT_RESOURCE_TYPE.UPLOADED
61 resource = self.get_existing_resource(resource)
62 resource.extra = {'subarches': resource.architecture.split('/')[1]}
63 if 'title' in self.cleaned_data:
64 resource.extra['title'] = self.cleaned_data['title']
65
66 resource.save()
67- resource_set = self.create_resource_set(resource, label)
68+ resource_set = self.create_resource_set(resource, 'uploaded')
69 self.create_resource_file(
70 resource_set, self.cleaned_data)
71 return resource
72diff --git a/src/maasserver/forms/tests/test_bootresource.py b/src/maasserver/forms/tests/test_bootresource.py
73index d9f3c5d..c03792b 100644
74--- a/src/maasserver/forms/tests/test_bootresource.py
75+++ b/src/maasserver/forms/tests/test_bootresource.py
76@@ -9,6 +9,7 @@ import random
77
78 from django.core.files.uploadedfile import SimpleUploadedFile
79 from maasserver import forms as forms_module
80+from maasserver.clusterrpc import osystems
81 from maasserver.enum import (
82 BOOT_RESOURCE_FILE_TYPE,
83 BOOT_RESOURCE_TYPE,
84@@ -189,8 +190,11 @@ class TestBootResourceForm(MAASServerTestCase):
85 written_content = stream.read()
86 self.assertEqual(content, written_content)
87
88- def test_creates_boot_resoures_with_generated_rtype(self):
89+ def test_creates_boot_resoures_with_uploaded_rtype(self):
90 os = factory.make_name('os')
91+ self.patch(
92+ osystems, 'gen_all_known_operating_systems').return_value = [
93+ {'name': os}]
94 series = factory.make_name('series')
95 name = '%s/%s' % (os, series)
96 architecture = make_usable_architecture(self)
97@@ -208,7 +212,7 @@ class TestBootResourceForm(MAASServerTestCase):
98 self.assertTrue(form.is_valid(), form._errors)
99 form.save()
100 resource = BootResource.objects.get(
101- rtype=BOOT_RESOURCE_TYPE.GENERATED,
102+ rtype=BOOT_RESOURCE_TYPE.UPLOADED,
103 name=name, architecture=architecture)
104 resource_set = resource.sets.first()
105 rfile = resource_set.files.first()
106@@ -221,6 +225,9 @@ class TestBootResourceForm(MAASServerTestCase):
107
108 def test_adds_boot_resource_set_to_existing_generated_boot_resource(self):
109 os = factory.make_name('os')
110+ self.patch(
111+ osystems, 'gen_all_known_operating_systems').return_value = [
112+ {'name': os}]
113 series = factory.make_name('series')
114 name = '%s/%s' % (os, series)
115 architecture = make_usable_architecture(self)
116@@ -249,6 +256,42 @@ class TestBootResourceForm(MAASServerTestCase):
117 with rfile.largefile.content.open('rb') as stream:
118 written_content = stream.read()
119 self.assertEqual(content, written_content)
120+ self.assertEqual(resource.rtype, BOOT_RESOURCE_TYPE.UPLOADED)
121+
122+ def test_adds_boot_resource_set_to_existing_uploaded_boot_resource(self):
123+ os = factory.make_name('os')
124+ self.patch(
125+ osystems, 'gen_all_known_operating_systems').return_value = [
126+ {'name': os}]
127+ series = factory.make_name('series')
128+ name = '%s/%s' % (os, series)
129+ architecture = make_usable_architecture(self)
130+ resource = factory.make_usable_boot_resource(
131+ rtype=BOOT_RESOURCE_TYPE.UPLOADED,
132+ name=name, architecture=architecture)
133+ upload_type, filetype = self.pick_filetype()
134+ size = random.randint(1024, 2048)
135+ content = factory.make_string(size).encode('utf-8')
136+ upload_name = factory.make_name('filename')
137+ uploaded_file = SimpleUploadedFile(content=content, name=upload_name)
138+ data = {
139+ 'name': name,
140+ 'architecture': architecture,
141+ 'filetype': upload_type,
142+ }
143+ form = BootResourceForm(data=data, files={'content': uploaded_file})
144+ self.assertTrue(form.is_valid(), form._errors)
145+ form.save()
146+ resource = reload_object(resource)
147+ resource_set = resource.sets.order_by('id').last()
148+ rfile = resource_set.files.first()
149+ self.assertTrue(filetype, rfile.filetype)
150+ self.assertTrue(filetype, rfile.filename)
151+ self.assertTrue(size, rfile.largefile.total_size)
152+ with rfile.largefile.content.open('rb') as stream:
153+ written_content = stream.read()
154+ self.assertEqual(content, written_content)
155+ self.assertEqual(resource.rtype, BOOT_RESOURCE_TYPE.UPLOADED)
156
157 def test_requires_fields(self):
158 form = BootResourceForm(data={})
159diff --git a/src/maasserver/models/bootresource.py b/src/maasserver/models/bootresource.py
160index 905e675..5af3eee 100644
161--- a/src/maasserver/models/bootresource.py
162+++ b/src/maasserver/models/bootresource.py
163@@ -187,6 +187,7 @@ class BootResourceManager(Manager):
164 rtypes = [
165 BOOT_RESOURCE_TYPE.SYNCED,
166 BOOT_RESOURCE_TYPE.GENERATED,
167+ BOOT_RESOURCE_TYPE.UPLOADED,
168 ]
169 name = '%s/%s' % (image['osystem'], image['release'])
170 else:
171@@ -442,9 +443,17 @@ class BootResource(CleanSave, TimestampedModel):
172 """
173 if self.rtype == BOOT_RESOURCE_TYPE.UPLOADED:
174 if '/' in self.name:
175- raise ValidationError(
176- "%s boot resource cannot contain a '/' in it's name." % (
177- self.display_rtype))
178+ # Avoid circular dependency
179+ from maasserver.clusterrpc.osystems import (
180+ gen_all_known_operating_systems,
181+ )
182+ osystem = self.name.split('/')[0]
183+ if osystem not in {
184+ i['name'] for i in gen_all_known_operating_systems()}:
185+ raise ValidationError(
186+ "%s boot resource cannot contain a '/' in it's name "
187+ "unless it starts with a supported operating system."
188+ % (self.display_rtype))
189 elif self.rtype in RTYPE_REQUIRING_OS_SERIES_NAME:
190 if '/' not in self.name:
191 raise ValidationError(
192diff --git a/src/maasserver/models/tests/test_bootresource.py b/src/maasserver/models/tests/test_bootresource.py
193index 2efb4fc..59c3ac2 100644
194--- a/src/maasserver/models/tests/test_bootresource.py
195+++ b/src/maasserver/models/tests/test_bootresource.py
196@@ -10,6 +10,7 @@ from datetime import datetime
197 import random
198
199 from django.core.exceptions import ValidationError
200+from maasserver.clusterrpc import osystems
201 from maasserver.clusterrpc.testing.boot_images import make_rpc_boot_image
202 from maasserver.enum import (
203 BOOT_RESOURCE_FILE_TYPE,
204@@ -771,6 +772,26 @@ class TestBootResource(MAASServerTestCase):
205 self.assertRaises(
206 ValidationError, resource.save)
207
208+ def test_validation_allows_any_uploaded_name_slash_with_supported_os(self):
209+ osystem = factory.make_name('osystem')
210+ self.patch(
211+ osystems, 'gen_all_known_operating_systems').return_value = [
212+ {'name': osystem}]
213+ name = '%s/%s' % (osystem, factory.make_name('release'))
214+ arch = '%s/%s' % (
215+ factory.make_name('arch'), factory.make_name('subarch'))
216+ resource = BootResource(
217+ rtype=BOOT_RESOURCE_TYPE.UPLOADED, name=name, architecture=arch)
218+ resource.save()
219+
220+ def test_validation_allows_any_uploaded_name_without_slash(self):
221+ name = factory.make_name('name')
222+ arch = '%s/%s' % (
223+ factory.make_name('arch'), factory.make_name('subarch'))
224+ resource = BootResource(
225+ rtype=BOOT_RESOURCE_TYPE.UPLOADED, name=name, architecture=arch)
226+ resource.save()
227+
228 def test_create_raises_error_on_not_unique(self):
229 name = '%s/%s' % (
230 factory.make_name('os'), factory.make_name('series'))
231diff --git a/src/maasserver/tests/test_bootresources.py b/src/maasserver/tests/test_bootresources.py
232index b3fd049..5047e03 100644
233--- a/src/maasserver/tests/test_bootresources.py
234+++ b/src/maasserver/tests/test_bootresources.py
235@@ -200,11 +200,11 @@ class TestSimpleStreamsHandler(MAASServerTestCase):
236
237 def get_product_name_for_resource(self, resource):
238 arch, subarch = resource.architecture.split('/')
239- if resource.rtype == BOOT_RESOURCE_TYPE.UPLOADED:
240+ if '/' in resource.name:
241+ os, series = resource.name.split('/')
242+ else:
243 os = 'custom'
244 series = resource.name
245- else:
246- os, series = resource.name.split('/')
247 return 'maas:boot:%s:%s:%s:%s' % (os, arch, subarch, series)
248
249 def make_usable_product_boot_resource(
250diff --git a/src/maasserver/utils/osystems.py b/src/maasserver/utils/osystems.py
251index 4a624f5..2746d46 100644
252--- a/src/maasserver/utils/osystems.py
253+++ b/src/maasserver/utils/osystems.py
254@@ -25,7 +25,6 @@ from distro_info import UbuntuDistroInfo
255 from django.core.exceptions import ValidationError
256 from django.db.models import Q
257 from maasserver.clusterrpc.osystems import gen_all_known_operating_systems
258-from maasserver.enum import BOOT_RESOURCE_TYPE
259 from maasserver.models import (
260 BootResource,
261 BootSourceCache,
262@@ -75,11 +74,11 @@ def list_all_usable_releases(osystems):
263 # When custom images are returned by list_all_usable_osystems
264 # the osystem name is 'custom' and the release name to whatever
265 # the user specified.
266- if resource.rtype == BOOT_RESOURCE_TYPE.UPLOADED:
267+ if '/' in resource.name:
268+ osystem, release = resource.name.split('/')
269+ else:
270 osystem = 'custom'
271 release = resource.name
272- else:
273- osystem, release = resource.name.split('/')
274 if osystem not in titles:
275 titles[osystem] = {}
276 titles[osystem][release] = resource.extra['title']
277diff --git a/src/maasserver/utils/tests/test_osystems.py b/src/maasserver/utils/tests/test_osystems.py
278index bf8c2d5..8ee6b92 100644
279--- a/src/maasserver/utils/tests/test_osystems.py
280+++ b/src/maasserver/utils/tests/test_osystems.py
281@@ -10,6 +10,7 @@ import random
282
283 from distro_info import UbuntuDistroInfo
284 from django.core.exceptions import ValidationError
285+from maasserver.clusterrpc import osystems
286 from maasserver.clusterrpc.testing.osystems import (
287 make_rpc_osystem,
288 make_rpc_release,
289@@ -154,6 +155,21 @@ class TestReleases(MAASServerTestCase):
290 title,
291 list_all_usable_releases([osystem])[osystem['name']][0]['title'])
292
293+ def test_list_all_usable_releases_finds_uploaded_with_osystem(self):
294+ release = make_rpc_release()
295+ osystem = make_rpc_osystem(releases=[release])
296+ title = factory.make_name('title')
297+ self.patch(
298+ osystems, 'gen_all_known_operating_systems').return_value = [
299+ {'name': osystem['name']}]
300+ factory.make_BootResource(
301+ rtype=BOOT_RESOURCE_TYPE.UPLOADED,
302+ name='%s/%s' % (osystem['name'], release['name']),
303+ extra={'title': title})
304+ self.assertEquals(
305+ title,
306+ list_all_usable_releases([osystem])[osystem['name']][0]['title'])
307+
308 def test_list_all_releases_requiring_keys(self):
309 releases = [
310 make_rpc_release(requires_license_key=True) for _ in range(3)]
311diff --git a/src/provisioningserver/drivers/osystem/__init__.py b/src/provisioningserver/drivers/osystem/__init__.py
312index 2b049ff..ef754d8 100644
313--- a/src/provisioningserver/drivers/osystem/__init__.py
314+++ b/src/provisioningserver/drivers/osystem/__init__.py
315@@ -67,10 +67,6 @@ class OperatingSystem(metaclass=ABCMeta):
316 """Title of the operating system."""
317
318 @abstractmethod
319- def is_release_supported(self, release):
320- """Return True when the release is supported, False otherwise."""
321-
322- @abstractmethod
323 def get_default_release(self):
324 """Return the default release to use when none is specified.
325
326@@ -96,6 +92,11 @@ class OperatingSystem(metaclass=ABCMeta):
327 :return: list of supported purposes
328 """
329
330+ def is_release_supported(self, release):
331+ """Return True when the release is supported, False otherwise."""
332+ # If the osystem matches assume all releases are supported.
333+ return True
334+
335 def format_release_choices(self, releases):
336 """Format the release choices that are presented to the user.
337
338diff --git a/src/provisioningserver/drivers/osystem/bootloader.py b/src/provisioningserver/drivers/osystem/bootloader.py
339index 6ada008..2811a82 100644
340--- a/src/provisioningserver/drivers/osystem/bootloader.py
341+++ b/src/provisioningserver/drivers/osystem/bootloader.py
342@@ -18,10 +18,6 @@ class BootLoaderOS(OperatingSystem):
343 name = 'bootloader'
344 title = 'Bootloader'
345
346- def is_release_supported(self, release):
347- # All releases are supported, they're pulled from the Ubuntu archive.
348- return True
349-
350 def get_default_release(self):
351 # No Default bootloader as it depends on the arch.
352 return ''
353diff --git a/src/provisioningserver/drivers/osystem/centos.py b/src/provisioningserver/drivers/osystem/centos.py
354index 179fa0c..b9f2290 100644
355--- a/src/provisioningserver/drivers/osystem/centos.py
356+++ b/src/provisioningserver/drivers/osystem/centos.py
357@@ -35,10 +35,6 @@ class CentOS(OperatingSystem):
358 BOOT_IMAGE_PURPOSE.XINSTALL
359 ]
360
361- def is_release_supported(self, release):
362- matched = DISTRO_MATCHER.match(release)
363- return matched is not None
364-
365 def get_default_release(self):
366 """Gets the default release to use when a release is not
367 explicit."""
368diff --git a/src/provisioningserver/drivers/osystem/custom.py b/src/provisioningserver/drivers/osystem/custom.py
369index 6e817e1..845c132 100644
370--- a/src/provisioningserver/drivers/osystem/custom.py
371+++ b/src/provisioningserver/drivers/osystem/custom.py
372@@ -27,11 +27,6 @@ class CustomOS(OperatingSystem):
373 # Custom images can only be used with XINSTALL.
374 return [BOOT_IMAGE_PURPOSE.XINSTALL]
375
376- def is_release_supported(self, release):
377- """Return True when the release is supported, False otherwise."""
378- # All release are supported, since the user uploaded it.
379- return True
380-
381 def get_default_release(self):
382 """Gets the default release to use when a release is not
383 explicit."""
384diff --git a/src/provisioningserver/drivers/osystem/rhel.py b/src/provisioningserver/drivers/osystem/rhel.py
385index 553c880..5e63364 100644
386--- a/src/provisioningserver/drivers/osystem/rhel.py
387+++ b/src/provisioningserver/drivers/osystem/rhel.py
388@@ -35,10 +35,6 @@ class RHELOS(OperatingSystem):
389 BOOT_IMAGE_PURPOSE.XINSTALL
390 ]
391
392- def is_release_supported(self, release):
393- matched = DISTRO_MATCHER.match(release)
394- return matched is not None
395-
396 def get_default_release(self):
397 """Gets the default release to use when a release is not
398 explicit."""
399diff --git a/src/provisioningserver/drivers/osystem/tests/test_base.py b/src/provisioningserver/drivers/osystem/tests/test_base.py
400index 9c41dc4..1fa9ca1 100644
401--- a/src/provisioningserver/drivers/osystem/tests/test_base.py
402+++ b/src/provisioningserver/drivers/osystem/tests/test_base.py
403@@ -1,4 +1,4 @@
404-# Copyright 2014-2016 Canonical Ltd. This software is licensed under the
405+# Copyright 2014-2017 Canonical Ltd. This software is licensed under the
406 # GNU Affero General Public License version 3 (see the file LICENSE).
407
408 """Tests for `provisioningserver.drivers.osystem`."""
409@@ -42,6 +42,15 @@ class TestOperatingSystem(MAASTestCase):
410 osystem_module, 'list_boot_images_for').return_value = images
411 return images
412
413+ def test_is_release_supported(self):
414+ osystem = self.make_usable_osystem()
415+ releases = [factory.make_name('release') for _ in range(3)]
416+ supported = [
417+ osystem.is_release_supported(release)
418+ for release in releases
419+ ]
420+ self.assertEqual([True, True, True], supported)
421+
422 def test_format_release_choices(self):
423 osystem = self.make_usable_osystem()
424 releases = osystem.get_supported_releases()
425diff --git a/src/provisioningserver/drivers/osystem/tests/test_bootloader.py b/src/provisioningserver/drivers/osystem/tests/test_bootloader.py
426index da0766e..9d89480 100644
427--- a/src/provisioningserver/drivers/osystem/tests/test_bootloader.py
428+++ b/src/provisioningserver/drivers/osystem/tests/test_bootloader.py
429@@ -13,11 +13,6 @@ from provisioningserver.drivers.osystem.bootloader import BootLoaderOS
430
431 class TestCustomOS(MAASTestCase):
432
433- def test_is_release_supported(self):
434- osystem = BootLoaderOS()
435- self.assertTrue(
436- osystem.is_release_supported(factory.make_name('release')))
437-
438 def test_get_default_release(self):
439 osystem = BootLoaderOS()
440 self.assertEquals("", osystem.get_default_release())
441diff --git a/src/provisioningserver/drivers/osystem/tests/test_centos.py b/src/provisioningserver/drivers/osystem/tests/test_centos.py
442index 207ea48..92f8be7 100644
443--- a/src/provisioningserver/drivers/osystem/tests/test_centos.py
444+++ b/src/provisioningserver/drivers/osystem/tests/test_centos.py
445@@ -34,23 +34,6 @@ class TestCentOS(MAASTestCase):
446 BOOT_IMAGE_PURPOSE.XINSTALL,
447 ])
448
449- def test_is_release_supported(self):
450- name_supported = {
451- "centos6": True,
452- "centos65": True,
453- "centos7": True,
454- "centos71": True,
455- "cent65": False,
456- "centos711": True,
457- "centos-title": True,
458- "centos71.custom": True,
459- factory.make_name("name"): False,
460- }
461- osystem = CentOS()
462- for name, supported in name_supported.items():
463- self.expectThat(
464- osystem.is_release_supported(name), Equals(supported))
465-
466 def test_get_default_release(self):
467 osystem = CentOS()
468 expected = osystem.get_default_release()
469diff --git a/src/provisioningserver/drivers/osystem/tests/test_custom.py b/src/provisioningserver/drivers/osystem/tests/test_custom.py
470index 1b7ff8e..80a6cce 100644
471--- a/src/provisioningserver/drivers/osystem/tests/test_custom.py
472+++ b/src/provisioningserver/drivers/osystem/tests/test_custom.py
473@@ -51,15 +51,6 @@ class TestCustomOS(MAASTestCase):
474 BOOT_IMAGE_PURPOSE.XINSTALL,
475 ])
476
477- def test_is_release_supported(self):
478- osystem = CustomOS()
479- releases = [factory.make_name('release') for _ in range(3)]
480- supported = [
481- osystem.is_release_supported(release)
482- for release in releases
483- ]
484- self.assertEqual([True, True, True], supported)
485-
486 def test_get_default_release(self):
487 osystem = CustomOS()
488 self.assertEqual("", osystem.get_default_release())
489diff --git a/src/provisioningserver/drivers/osystem/tests/test_rhel.py b/src/provisioningserver/drivers/osystem/tests/test_rhel.py
490index 5c74417..4d85356 100644
491--- a/src/provisioningserver/drivers/osystem/tests/test_rhel.py
492+++ b/src/provisioningserver/drivers/osystem/tests/test_rhel.py
493@@ -34,23 +34,6 @@ class TestRHEL(MAASTestCase):
494 BOOT_IMAGE_PURPOSE.XINSTALL,
495 ])
496
497- def test_is_release_supported(self):
498- name_supported = {
499- "rhel6": True,
500- "rhel65": True,
501- "rhel7": True,
502- "rhel71": True,
503- "cent65": False,
504- "rhel711": True,
505- "rhel-title": True,
506- "rhel71.custom": True,
507- factory.make_name("name"): False,
508- }
509- osystem = RHELOS()
510- for name, supported in name_supported.items():
511- self.expectThat(
512- osystem.is_release_supported(name), Equals(supported))
513-
514 def test_get_default_release(self):
515 osystem = RHELOS()
516 expected = osystem.get_default_release()
517diff --git a/src/provisioningserver/drivers/osystem/tests/test_ubuntu.py b/src/provisioningserver/drivers/osystem/tests/test_ubuntu.py
518index d64faa9..f68f493 100644
519--- a/src/provisioningserver/drivers/osystem/tests/test_ubuntu.py
520+++ b/src/provisioningserver/drivers/osystem/tests/test_ubuntu.py
521@@ -19,12 +19,7 @@ from provisioningserver.drivers.osystem.ubuntu import UbuntuOS
522 class TestUbuntuOS(MAASTestCase):
523
524 def get_lts_release(self):
525- # XXX ltrager 2016-04-06 - python3-distro-info won't set the latest lts
526- # to Xenial until its been released. So we can start testing MAAS 2.0
527- # with Xenial by default override it here. Once Xenial is released this
528- # can be removed
529- # return UbuntuDistroInfo().lts()
530- return "xenial"
531+ return UbuntuDistroInfo().lts()
532
533 def get_release_title(self, release):
534 info = UbuntuDistroInfo()
535@@ -51,6 +46,16 @@ class TestUbuntuOS(MAASTestCase):
536 BOOT_IMAGE_PURPOSE.DISKLESS,
537 ])
538
539+ def test_is_release_supported(self):
540+ osystem = UbuntuOS()
541+ info = UbuntuDistroInfo()
542+ self.assertTrue(osystem.is_release_supported(random.choice(info.all)))
543+
544+ def test_get_lts_release(self):
545+ # Canary so we know when the lts changes
546+ osystem = UbuntuOS()
547+ self.assertEquals('xenial', osystem.get_lts_release())
548+
549 def test_get_default_release(self):
550 osystem = UbuntuOS()
551 expected = osystem.get_default_release()
552diff --git a/src/provisioningserver/drivers/osystem/tests/test_ubuntucore.py b/src/provisioningserver/drivers/osystem/tests/test_ubuntucore.py
553index 591a7bf..c01ee28 100644
554--- a/src/provisioningserver/drivers/osystem/tests/test_ubuntucore.py
555+++ b/src/provisioningserver/drivers/osystem/tests/test_ubuntucore.py
556@@ -51,15 +51,6 @@ class TestUbuntuCoreOS(MAASTestCase):
557 BOOT_IMAGE_PURPOSE.XINSTALL,
558 ])
559
560- def test_is_release_supported(self):
561- osystem = UbuntuCoreOS()
562- releases = [factory.make_name('release') for _ in range(3)]
563- supported = [
564- osystem.is_release_supported(release)
565- for release in releases
566- ]
567- self.assertEqual([True, True, True], supported)
568-
569 def test_get_default_release(self):
570 osystem = UbuntuCoreOS()
571 self.assertEqual("16", osystem.get_default_release())
572diff --git a/src/provisioningserver/drivers/osystem/ubuntu.py b/src/provisioningserver/drivers/osystem/ubuntu.py
573index 7490465..dd8d243 100644
574--- a/src/provisioningserver/drivers/osystem/ubuntu.py
575+++ b/src/provisioningserver/drivers/osystem/ubuntu.py
576@@ -42,15 +42,7 @@ class UbuntuOS(OperatingSystem):
577
578 def get_lts_release(self):
579 """Return the latest Ubuntu LTS release."""
580- lts_release = self.ubuntu_distro_info.lts()
581- # XXX ltrager 2016-04-06 - python3-distro-info won't set the latest lts
582- # to Xenial until its been released. So we can start testing MAAS 2.0
583- # with Xenial by default override it here. Once Xenial is released this
584- # can be removed
585- if lts_release == "trusty":
586- return "xenial"
587- else:
588- return lts_release
589+ return self.ubuntu_distro_info.lts()
590
591 def get_default_release(self):
592 """Gets the default release to use when a release is not
593diff --git a/src/provisioningserver/drivers/osystem/ubuntucore.py b/src/provisioningserver/drivers/osystem/ubuntucore.py
594index 0a1ea45..1830da6 100644
595--- a/src/provisioningserver/drivers/osystem/ubuntucore.py
596+++ b/src/provisioningserver/drivers/osystem/ubuntucore.py
597@@ -27,11 +27,6 @@ class UbuntuCoreOS(OperatingSystem):
598 # Custom images can only be used with XINSTALL.
599 return [BOOT_IMAGE_PURPOSE.XINSTALL]
600
601- def is_release_supported(self, release):
602- """Return True when the release is supported, False otherwise."""
603- # All release are supported, since the user uploaded it.
604- return True
605-
606 def get_default_release(self):
607 """Gets the default release to use when a release is not
608 explicit."""
609diff --git a/src/provisioningserver/drivers/osystem/windows.py b/src/provisioningserver/drivers/osystem/windows.py
610index a3bc514..ad7391d 100644
611--- a/src/provisioningserver/drivers/osystem/windows.py
612+++ b/src/provisioningserver/drivers/osystem/windows.py
613@@ -55,10 +55,6 @@ class WindowsOS(OperatingSystem):
614 purposes.append(BOOT_IMAGE_PURPOSE.INSTALL)
615 return purposes
616
617- def is_release_supported(self, release):
618- """Return True when the release is supported, False otherwise."""
619- return release in WINDOWS_CHOICES
620-
621 def get_default_release(self):
622 """Gets the default release to use when a release is not
623 explicit."""
624@@ -66,7 +62,7 @@ class WindowsOS(OperatingSystem):
625
626 def get_release_title(self, release):
627 """Return the title for the given release."""
628- return WINDOWS_CHOICES.get(release)
629+ return WINDOWS_CHOICES.get(release, release)
630
631 def requires_license_key(self, release):
632 return release in REQUIRE_LICENSE_KEY
633diff --git a/src/provisioningserver/testing/os.py b/src/provisioningserver/testing/os.py
634index 5dd7538..9bc5626 100644
635--- a/src/provisioningserver/testing/os.py
636+++ b/src/provisioningserver/testing/os.py
637@@ -34,9 +34,6 @@ class FakeOS(OperatingSystem):
638 def get_boot_image_purposes(self, *args):
639 return self.purpose
640
641- def is_release_supported(self, release):
642- return release in self.fake_list
643-
644 def get_supported_releases(self):
645 return self.fake_list
646

Subscribers

People subscribed via source and target branches

to all changes: