Merge lp:~andreserl/maas/revert_rev5602_lp1686169_2.1 into lp:maas/2.1
- revert_rev5602_lp1686169_2.1
- Merge into 2.1
Proposed by
Andres Rodriguez
Status: | Superseded | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~andreserl/maas/revert_rev5602_lp1686169_2.1 | ||||
Merge into: | lp:maas/2.1 | ||||
Diff against target: |
637 lines (+160/-251) 4 files modified
src/maasserver/bootresources.py (+63/-2) src/maasserver/tests/test_bootresources.py (+86/-59) src/provisioningserver/import_images/download_descriptions.py (+0/-72) src/provisioningserver/import_images/tests/test_download_descriptions.py (+11/-118) |
||||
To merge this branch: | bzr merge lp:~andreserl/maas/revert_rev5602_lp1686169_2.1 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
MAAS Committers | Pending | ||
Review via email: mp+323261@code.launchpad.net |
This proposal has been superseded by a proposal from 2017-04-26.
Commit message
Revert rev5602, which fixed LP: #1686169. This causes rack controllers to fail importing images
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/maasserver/bootresources.py' |
2 | --- src/maasserver/bootresources.py 2017-04-26 00:27:23 +0000 |
3 | +++ src/maasserver/bootresources.py 2017-04-26 19:10:13 +0000 |
4 | @@ -18,6 +18,7 @@ |
5 | from datetime import timedelta |
6 | from operator import itemgetter |
7 | import os |
8 | +import re |
9 | from subprocess import CalledProcessError |
10 | from textwrap import dedent |
11 | import threading |
12 | @@ -80,7 +81,6 @@ |
13 | from provisioningserver.import_images.download_descriptions import ( |
14 | download_all_image_descriptions, |
15 | image_passes_filter, |
16 | - validate_product, |
17 | ) |
18 | from provisioningserver.import_images.helpers import ( |
19 | get_os_from_product, |
20 | @@ -1019,6 +1019,12 @@ |
21 | # will be downloaded from simplestreams. |
22 | 'max_items': 1, |
23 | }) |
24 | + # Compile a regex to validate bootloader product names. This only |
25 | + # allows V1 bootloaders. |
26 | + self.bootloader_regex = re.compile('.*:1:.*', re.IGNORECASE) |
27 | + # Compile a regex to validate Ubuntu product names. This only allows |
28 | + # V2 and V3 Ubuntu products. |
29 | + self.ubuntu_regex = re.compile('.*:v[23]:.*', re.IGNORECASE) |
30 | |
31 | def load_products(self, path=None, content_id=None): |
32 | """Overridable from `BasicMirrorWriter`.""" |
33 | @@ -1032,6 +1038,59 @@ |
34 | return self.product_mapping.contains( |
35 | sutil.products_exdata(src, pedigree)) |
36 | |
37 | + def _validate_ubuntu(self, data, product_name): |
38 | + osystem = data.get('os') |
39 | + if 'ubuntu' not in osystem.lower(): |
40 | + # It's not an Ubuntu product, nothing to validate. |
41 | + return True |
42 | + elif self.ubuntu_regex.search(product_name) is None: |
43 | + # Only insert v2 or v3 Ubuntu products. |
44 | + return False |
45 | + else: |
46 | + return True |
47 | + |
48 | + def _validate_bootloader(self, data, product_name): |
49 | + bootloader_type = data.get('bootloader-type') |
50 | + if bootloader_type is None: |
51 | + # It's not a bootloader, nothing to validate |
52 | + return True |
53 | + if self.bootloader_regex.search(product_name) is None: |
54 | + # Only insert V1 bootloaders from the stream |
55 | + return False |
56 | + # Validate MAAS supports the specific bootloader_type, os, arch |
57 | + # combination. |
58 | + SUPPORTED_BOOTLOADERS = { |
59 | + 'pxe': [ |
60 | + { |
61 | + 'os': 'pxelinux', |
62 | + 'arch': 'i386', |
63 | + } |
64 | + ], |
65 | + 'uefi': [ |
66 | + { |
67 | + 'os': 'grub-efi-signed', |
68 | + 'arch': 'amd64', |
69 | + }, |
70 | + { |
71 | + 'os': 'grub-efi', |
72 | + 'arch': 'arm64', |
73 | + } |
74 | + ], |
75 | + 'open-firmware': [ |
76 | + { |
77 | + 'os': 'grub-ieee1275', |
78 | + 'arch': 'ppc64el', |
79 | + } |
80 | + ], |
81 | + } |
82 | + for bootloader in SUPPORTED_BOOTLOADERS.get(bootloader_type, []): |
83 | + if ( |
84 | + data.get('os') == bootloader['os'] and |
85 | + data.get('arch') == bootloader['arch']): |
86 | + return True |
87 | + # Bootloader not supported, ignore |
88 | + return False |
89 | + |
90 | def insert_item(self, data, src, target, pedigree, contentsource): |
91 | """Overridable from `BasicMirrorWriter`.""" |
92 | item = sutil.products_exdata(src, pedigree) |
93 | @@ -1048,7 +1107,9 @@ |
94 | elif item['ftype'] not in dict(BOOT_RESOURCE_FILE_TYPE_CHOICES).keys(): |
95 | # Skip filetypes that we don't know about. |
96 | return |
97 | - elif not validate_product(item, product_name): |
98 | + elif not self._validate_ubuntu(item, product_name): |
99 | + return |
100 | + elif not self._validate_bootloader(item, product_name): |
101 | return |
102 | else: |
103 | self.store.insert(item, contentsource) |
104 | |
105 | === modified file 'src/maasserver/tests/test_bootresources.py' |
106 | --- src/maasserver/tests/test_bootresources.py 2017-04-26 00:27:23 +0000 |
107 | +++ src/maasserver/tests/test_bootresources.py 2017-04-26 19:10:13 +0000 |
108 | @@ -2103,7 +2103,7 @@ |
109 | class TestBootResourceRepoWriter(MAASServerTestCase): |
110 | """Tests for `BootResourceRepoWriter`.""" |
111 | |
112 | - def create_ubuntu_simplestream(self, ftypes, stream_version=None): |
113 | + def create_simplestream(self, ftypes, stream_version=None): |
114 | version = '16.04' |
115 | arch = 'amd64' |
116 | subarch = 'hwe-x' |
117 | @@ -2145,47 +2145,10 @@ |
118 | } |
119 | return src, product, version |
120 | |
121 | - def create_bootloader_simplestream(self, stream_version=None): |
122 | - if stream_version is None: |
123 | - stream_version = '1' |
124 | - product = ( |
125 | - 'com.ubuntu.maas:daily:%s:bootloader-download' % stream_version) |
126 | - version = datetime.now().date().strftime('%Y%m%d.0') |
127 | - versions = { |
128 | - version: { |
129 | - 'items': { |
130 | - BOOT_RESOURCE_FILE_TYPE.BOOTLOADER: { |
131 | - 'sha256': factory.make_name('sha256'), |
132 | - 'path': factory.make_name('path'), |
133 | - 'ftype': BOOT_RESOURCE_FILE_TYPE.BOOTLOADER, |
134 | - 'size': random.randint(0, 2**64), |
135 | - } |
136 | - } |
137 | - } |
138 | - } |
139 | - products = { |
140 | - product: { |
141 | - 'label': 'daily', |
142 | - 'os': 'grub-efi-signed', |
143 | - 'arch': 'amd64', |
144 | - 'bootloader-type': 'uefi', |
145 | - 'version': version, |
146 | - 'versions': versions, |
147 | - } |
148 | - } |
149 | - src = { |
150 | - 'datatype': 'image-downloads', |
151 | - 'format': 'products:1.0', |
152 | - 'updated': format_datetime(datetime.now()), |
153 | - 'products': products, |
154 | - 'content_id': 'com.ubuntu.maas:daily:1:bootloader-download' |
155 | - } |
156 | - return src, product, version |
157 | - |
158 | def test_insert_prefers_squashfs_over_root_image(self): |
159 | boot_resource_repo_writer = BootResourceRepoWriter( |
160 | BootResourceStore(), None) |
161 | - src, product, version = self.create_ubuntu_simplestream([ |
162 | + src, product, version = self.create_simplestream([ |
163 | BOOT_RESOURCE_FILE_TYPE.ROOT_IMAGE, |
164 | BOOT_RESOURCE_FILE_TYPE.SQUASHFS_IMAGE, |
165 | ]) |
166 | @@ -2199,7 +2162,7 @@ |
167 | def test_insert_allows_squashfs(self): |
168 | boot_resource_repo_writer = BootResourceRepoWriter( |
169 | BootResourceStore(), None) |
170 | - src, product, version = self.create_ubuntu_simplestream([ |
171 | + src, product, version = self.create_simplestream([ |
172 | BOOT_RESOURCE_FILE_TYPE.SQUASHFS_IMAGE, |
173 | ]) |
174 | data = src['products'][product]['versions'][version]['items'][ |
175 | @@ -2212,7 +2175,7 @@ |
176 | def test_insert_allows_root_image(self): |
177 | boot_resource_repo_writer = BootResourceRepoWriter( |
178 | BootResourceStore(), None) |
179 | - src, product, version = self.create_ubuntu_simplestream([ |
180 | + src, product, version = self.create_simplestream([ |
181 | BOOT_RESOURCE_FILE_TYPE.ROOT_IMAGE, |
182 | ]) |
183 | data = src['products'][product]['versions'][version]['items'][ |
184 | @@ -2225,7 +2188,9 @@ |
185 | def test_insert_allows_bootloader(self): |
186 | boot_resource_repo_writer = BootResourceRepoWriter( |
187 | BootResourceStore(), None) |
188 | - src, product, version = self.create_bootloader_simplestream() |
189 | + src, product, version = self.create_simplestream([ |
190 | + BOOT_RESOURCE_FILE_TYPE.BOOTLOADER, |
191 | + ]) |
192 | data = src['products'][product]['versions'][version]['items'][ |
193 | BOOT_RESOURCE_FILE_TYPE.BOOTLOADER] |
194 | pedigree = (product, version, BOOT_RESOURCE_FILE_TYPE.BOOTLOADER) |
195 | @@ -2236,7 +2201,7 @@ |
196 | def test_insert_allows_archive_tar_xz(self): |
197 | boot_resource_repo_writer = BootResourceRepoWriter( |
198 | BootResourceStore(), None) |
199 | - src, product, version = self.create_ubuntu_simplestream([ |
200 | + src, product, version = self.create_simplestream([ |
201 | BOOT_RESOURCE_FILE_TYPE.ARCHIVE_TAR_XZ, |
202 | ]) |
203 | data = src['products'][product]['versions'][version]['items'][ |
204 | @@ -2250,7 +2215,7 @@ |
205 | boot_resource_repo_writer = BootResourceRepoWriter( |
206 | BootResourceStore(), None) |
207 | unknown_ftype = factory.make_name('ftype') |
208 | - src, product, version = self.create_ubuntu_simplestream([ |
209 | + src, product, version = self.create_simplestream([ |
210 | unknown_ftype, |
211 | ]) |
212 | data = src['products'][product]['versions'][version]['items'][ |
213 | @@ -2263,43 +2228,105 @@ |
214 | def test_insert_validates_bootloader(self): |
215 | boot_resource_repo_writer = BootResourceRepoWriter( |
216 | BootResourceStore(), None) |
217 | - src, product, version = self.create_bootloader_simplestream() |
218 | + src, product, version = self.create_simplestream([ |
219 | + BOOT_RESOURCE_FILE_TYPE.BOOTLOADER, |
220 | + ]) |
221 | data = src['products'][product]['versions'][version]['items'][ |
222 | BOOT_RESOURCE_FILE_TYPE.BOOTLOADER] |
223 | pedigree = (product, version, BOOT_RESOURCE_FILE_TYPE.BOOTLOADER) |
224 | mock_insert = self.patch(boot_resource_repo_writer.store, 'insert') |
225 | + mock_validate_bootloader = self.patch( |
226 | + boot_resource_repo_writer, '_validate_bootloader') |
227 | boot_resource_repo_writer.insert_item(data, src, None, pedigree, None) |
228 | self.assertThat(mock_insert, MockCalledOnce()) |
229 | - |
230 | - def test_insert_validates_rejects_unknown_version(self): |
231 | - boot_resource_repo_writer = BootResourceRepoWriter( |
232 | - BootResourceStore(), None) |
233 | - src, product, version = self.create_bootloader_simplestream( |
234 | - factory.make_name('stream_version')) |
235 | - data = src['products'][product]['versions'][version]['items'][ |
236 | - BOOT_RESOURCE_FILE_TYPE.BOOTLOADER] |
237 | - pedigree = (product, version, BOOT_RESOURCE_FILE_TYPE.BOOTLOADER) |
238 | - mock_insert = self.patch(boot_resource_repo_writer.store, 'insert') |
239 | - boot_resource_repo_writer.insert_item(data, src, None, pedigree, None) |
240 | - self.assertThat(mock_insert, MockNotCalled()) |
241 | + self.assertThat(mock_validate_bootloader, MockCalledOnce()) |
242 | + |
243 | + def test_validate_bootloader_ignores_non_bootloaders(self): |
244 | + boot_resource_repo_writer = BootResourceRepoWriter( |
245 | + BootResourceStore(), None) |
246 | + self.assertTrue( |
247 | + boot_resource_repo_writer._validate_bootloader( |
248 | + {}, 'com.ubuntu.maas.daily:v3:boot:16.04:amd64:hwe-16.04')) |
249 | + |
250 | + def test_validate_bootloader_checks_version(self): |
251 | + boot_resource_repo_writer = BootResourceRepoWriter( |
252 | + BootResourceStore(), None) |
253 | + version = random.randint(2, 100) |
254 | + product_name = "com.ubuntu.maas.daily:%d:pxelinux:pxe:i386" % version |
255 | + self.assertFalse( |
256 | + boot_resource_repo_writer._validate_bootloader( |
257 | + {'bootloader-type': factory.make_name('bootloader-type')}, |
258 | + product_name)) |
259 | + |
260 | + def test_validate_bootloader_allows_acceptable_bootloaders(self): |
261 | + acceptable_bootloaders = [ |
262 | + { |
263 | + 'os': 'pxelinux', |
264 | + 'arch': 'i386', |
265 | + 'bootloader-type': 'pxe', |
266 | + }, |
267 | + { |
268 | + 'os': 'grub-efi-signed', |
269 | + 'arch': 'amd64', |
270 | + 'bootloader-type': 'uefi', |
271 | + }, |
272 | + { |
273 | + 'os': 'grub-efi', |
274 | + 'arch': 'arm64', |
275 | + 'bootloader-type': 'uefi', |
276 | + }, |
277 | + { |
278 | + 'os': 'grub-ieee1275', |
279 | + 'arch': 'ppc64el', |
280 | + 'bootloader-type': 'open-firmware', |
281 | + }, |
282 | + ] |
283 | + boot_resource_repo_writer = BootResourceRepoWriter( |
284 | + BootResourceStore(), None) |
285 | + for bootloader in acceptable_bootloaders: |
286 | + product_name = "com.ubuntu.maas.daily:1:%s:%s:%s" % ( |
287 | + bootloader['os'], bootloader['bootloader-type'], |
288 | + bootloader['arch']) |
289 | + self.assertTrue( |
290 | + boot_resource_repo_writer._validate_bootloader( |
291 | + bootloader, product_name), |
292 | + "Failed to validate %s" % product_name) |
293 | + |
294 | + def test_validate_bootloader_denies_unacceptable_bootloader(self): |
295 | + bootloader = { |
296 | + 'os': factory.make_name('os'), |
297 | + 'arch': factory.make_name('arch'), |
298 | + 'bootloader-type': factory.make_name('bootloader_type'), |
299 | + } |
300 | + product_name = "com.ubuntu.maas.daily:1:%s:%s:%s" % ( |
301 | + bootloader['os'], bootloader['bootloader-type'], |
302 | + bootloader['arch']) |
303 | + boot_resource_repo_writer = BootResourceRepoWriter( |
304 | + BootResourceStore(), None) |
305 | + self.assertFalse( |
306 | + boot_resource_repo_writer._validate_bootloader( |
307 | + bootloader, product_name)) |
308 | |
309 | def test_insert_validates_ubuntu(self): |
310 | boot_resource_repo_writer = BootResourceRepoWriter( |
311 | BootResourceStore(), None) |
312 | - src, product, version = self.create_ubuntu_simplestream([ |
313 | + src, product, version = self.create_simplestream([ |
314 | BOOT_RESOURCE_FILE_TYPE.SQUASHFS_IMAGE, |
315 | ]) |
316 | data = src['products'][product]['versions'][version]['items'][ |
317 | BOOT_RESOURCE_FILE_TYPE.SQUASHFS_IMAGE] |
318 | pedigree = (product, version, BOOT_RESOURCE_FILE_TYPE.SQUASHFS_IMAGE) |
319 | mock_insert = self.patch(boot_resource_repo_writer.store, 'insert') |
320 | + mock_validate_bootloader = self.patch( |
321 | + boot_resource_repo_writer, '_validate_ubuntu') |
322 | boot_resource_repo_writer.insert_item(data, src, None, pedigree, None) |
323 | self.assertThat(mock_insert, MockCalledOnce()) |
324 | + self.assertThat(mock_validate_bootloader, MockCalledOnce()) |
325 | |
326 | def test_validate_ubuntu_rejects_unknown_version(self): |
327 | boot_resource_repo_writer = BootResourceRepoWriter( |
328 | BootResourceStore(), None) |
329 | - src, product, version = self.create_ubuntu_simplestream( |
330 | + src, product, version = self.create_simplestream( |
331 | [BOOT_RESOURCE_FILE_TYPE.SQUASHFS_IMAGE], |
332 | factory.make_name('stream_version')) |
333 | data = src['products'][product]['versions'][version]['items'][ |
334 | |
335 | === modified file 'src/provisioningserver/import_images/download_descriptions.py' |
336 | --- src/provisioningserver/import_images/download_descriptions.py 2017-04-26 00:27:23 +0000 |
337 | +++ src/provisioningserver/import_images/download_descriptions.py 2017-04-26 19:10:13 +0000 |
338 | @@ -10,10 +10,8 @@ |
339 | |
340 | __all__ = [ |
341 | 'download_all_image_descriptions', |
342 | - 'validate_product', |
343 | ] |
344 | |
345 | -import re |
346 | |
347 | from provisioningserver.import_images.boot_image_mapping import ( |
348 | BootImageMapping, |
349 | @@ -33,13 +31,6 @@ |
350 | products_exdata, |
351 | ) |
352 | |
353 | -# Compile a regex to validate Ubuntu product names. This only allows V2 and V3 |
354 | -# Ubuntu images. |
355 | -UBUNTU_REGEX = re.compile('.*:v[23]:.*', re.IGNORECASE) |
356 | -# Compile a regex to validate bootloader product names. This only allows V1 |
357 | -# bootloaders. |
358 | -BOOTLOADER_REGEX = re.compile('.*:1:.*', re.IGNORECASE) |
359 | - |
360 | |
361 | def clean_up_repo_item(item): |
362 | """Return a subset of dict `item` for storing in a boot images dict.""" |
363 | @@ -55,67 +46,6 @@ |
364 | return compact_item |
365 | |
366 | |
367 | -def validate_ubuntu(data, product_name): |
368 | - osystem = data.get('os', '') |
369 | - if 'ubuntu' not in osystem.lower(): |
370 | - # It's not an Ubuntu product, nothing to validate. |
371 | - return True |
372 | - elif UBUNTU_REGEX.search(product_name) is None: |
373 | - # Only insert v2 or v3 Ubuntu products. |
374 | - return False |
375 | - else: |
376 | - return True |
377 | - |
378 | - |
379 | -def validate_bootloader(data, product_name): |
380 | - bootloader_type = data.get('bootloader-type') |
381 | - if bootloader_type is None: |
382 | - # It's not a bootloader, nothing to validate |
383 | - return True |
384 | - if BOOTLOADER_REGEX.search(product_name) is None: |
385 | - # Only insert V1 bootloaders from the stream |
386 | - return False |
387 | - # Validate MAAS supports the specific bootloader_type, os, arch |
388 | - # combination. |
389 | - SUPPORTED_BOOTLOADERS = { |
390 | - 'pxe': [ |
391 | - { |
392 | - 'os': 'pxelinux', |
393 | - 'arch': 'i386', |
394 | - } |
395 | - ], |
396 | - 'uefi': [ |
397 | - { |
398 | - 'os': 'grub-efi-signed', |
399 | - 'arch': 'amd64', |
400 | - }, |
401 | - { |
402 | - 'os': 'grub-efi', |
403 | - 'arch': 'arm64', |
404 | - } |
405 | - ], |
406 | - 'open-firmware': [ |
407 | - { |
408 | - 'os': 'grub-ieee1275', |
409 | - 'arch': 'ppc64el', |
410 | - } |
411 | - ], |
412 | - } |
413 | - for bootloader in SUPPORTED_BOOTLOADERS.get(bootloader_type, []): |
414 | - if ( |
415 | - data.get('os') == bootloader['os'] and |
416 | - data.get('arch') == bootloader['arch']): |
417 | - return True |
418 | - |
419 | - # Bootloader not supported, ignore |
420 | - return False |
421 | - |
422 | - |
423 | -def validate_product(data, product_name): |
424 | - return (validate_ubuntu(data, product_name) and |
425 | - validate_bootloader(data, product_name)) |
426 | - |
427 | - |
428 | class RepoDumper(BasicMirrorWriter): |
429 | """Gather metadata about boot images available in a Simplestreams repo. |
430 | |
431 | @@ -149,8 +79,6 @@ |
432 | def insert_item(self, data, src, target, pedigree, contentsource): |
433 | """Overridable from `BasicMirrorWriter`.""" |
434 | item = products_exdata(src, pedigree) |
435 | - if not validate_product(item, pedigree[0]): |
436 | - return |
437 | os = get_os_from_product(item) |
438 | arch = item['arch'] |
439 | subarches = item.get('subarches', 'generic') |
440 | |
441 | === modified file 'src/provisioningserver/import_images/tests/test_download_descriptions.py' |
442 | --- src/provisioningserver/import_images/tests/test_download_descriptions.py 2017-04-26 00:27:23 +0000 |
443 | +++ src/provisioningserver/import_images/tests/test_download_descriptions.py 2017-04-26 19:10:13 +0000 |
444 | @@ -6,7 +6,6 @@ |
445 | __all__ = [] |
446 | |
447 | import logging |
448 | -import random |
449 | from unittest.mock import ( |
450 | ANY, |
451 | call, |
452 | @@ -28,7 +27,6 @@ |
453 | from provisioningserver.import_images.download_descriptions import ( |
454 | clean_up_repo_item, |
455 | RepoDumper, |
456 | - validate_product, |
457 | ) |
458 | from provisioningserver.import_images.testing.factory import ( |
459 | make_image_spec, |
460 | @@ -36,78 +34,6 @@ |
461 | ) |
462 | |
463 | |
464 | -class TestValidateProduct(MAASTestCase): |
465 | - """Tests for `validate_product`.""" |
466 | - |
467 | - def test__ignores_random(self): |
468 | - self.assertTrue( |
469 | - validate_product({}, factory.make_name('product_name'))) |
470 | - |
471 | - def test__validates_ubuntu(self): |
472 | - self.assertTrue(validate_product( |
473 | - {'os': 'ubuntu'}, |
474 | - 'com.ubuntu.maas.daily:v%d:boot:%s:%s:%s' % ( |
475 | - random.choice([2, 3]), factory.make_name('version'), |
476 | - factory.make_name('arch'), factory.make_name('sub_arch')))) |
477 | - |
478 | - def test__rejects_unknown_ubuntu_version(self): |
479 | - self.assertFalse(validate_product( |
480 | - {'os': 'ubuntu'}, |
481 | - 'com.ubuntu.maas.daily:v%d:boot:%s:%s:%s' % ( |
482 | - random.randint(4, 100), factory.make_name('version'), |
483 | - factory.make_name('arch'), factory.make_name('sub_arch')))) |
484 | - |
485 | - def test__validates_bootloaders(self): |
486 | - acceptable_bootloaders = [ |
487 | - { |
488 | - 'os': 'pxelinux', |
489 | - 'arch': 'i386', |
490 | - 'bootloader-type': 'pxe', |
491 | - }, |
492 | - { |
493 | - 'os': 'grub-efi-signed', |
494 | - 'arch': 'amd64', |
495 | - 'bootloader-type': 'uefi', |
496 | - }, |
497 | - { |
498 | - 'os': 'grub-efi', |
499 | - 'arch': 'arm64', |
500 | - 'bootloader-type': 'uefi', |
501 | - }, |
502 | - { |
503 | - 'os': 'grub-ieee1275', |
504 | - 'arch': 'ppc64el', |
505 | - 'bootloader-type': 'open-firmware', |
506 | - }, |
507 | - ] |
508 | - for bootloader in acceptable_bootloaders: |
509 | - product_name = "com.ubuntu.maas.daily:1:%s:%s:%s" % ( |
510 | - bootloader['os'], bootloader['bootloader-type'], |
511 | - bootloader['arch']) |
512 | - self.assertTrue( |
513 | - validate_product(bootloader, product_name), |
514 | - "Failed to validate %s" % product_name) |
515 | - |
516 | - def test__rejects_unknown_bootloader_version(self): |
517 | - version = random.randint(2, 100) |
518 | - product_name = "com.ubuntu.maas.daily:%d:pxelinux:pxe:i386" % version |
519 | - self.assertFalse( |
520 | - validate_product( |
521 | - {'bootloader-type': factory.make_name('bootloader-type')}, |
522 | - product_name)) |
523 | - |
524 | - def test__rejects_unknown_bootloader(self): |
525 | - bootloader = { |
526 | - 'os': factory.make_name('os'), |
527 | - 'arch': factory.make_name('arch'), |
528 | - 'bootloader-type': factory.make_name('bootloader_type'), |
529 | - } |
530 | - product_name = "com.ubuntu.maas.daily:1:%s:%s:%s" % ( |
531 | - bootloader['os'], bootloader['bootloader-type'], |
532 | - bootloader['arch']) |
533 | - self.assertFalse(validate_product(bootloader, product_name)) |
534 | - |
535 | - |
536 | class TestValuePassesFilterList(MAASTestCase): |
537 | """Tests for `value_passes_filter_list`.""" |
538 | |
539 | @@ -354,10 +280,7 @@ |
540 | download_descriptions, 'products_exdata').return_value = item |
541 | dumper.insert_item( |
542 | sentinel.data, sentinel.src, sentinel.target, |
543 | - ( |
544 | - factory.make_name('product_name'), |
545 | - factory.make_name('product_version') |
546 | - ), sentinel.contentsource) |
547 | + sentinel.pedigree, sentinel.contentsource) |
548 | image_specs = [ |
549 | make_image_spec( |
550 | os=item['os'], release=item['release'], |
551 | @@ -383,10 +306,7 @@ |
552 | for _ in range(2): |
553 | dumper.insert_item( |
554 | sentinel.data, sentinel.src, sentinel.target, |
555 | - ( |
556 | - factory.make_name('product_name'), |
557 | - factory.make_name('product_version') |
558 | - ), sentinel.contentsource) |
559 | + sentinel.pedigree, sentinel.contentsource) |
560 | image_spec = make_image_spec( |
561 | os=item['os'], release=item['release'], |
562 | arch=item['arch'], subarch=compat_subarch, |
563 | @@ -417,11 +337,8 @@ |
564 | 'products_exdata').side_effect = [hwep_item, hwes_item] |
565 | for _ in range(2): |
566 | dumper.insert_item( |
567 | - {'os': 'ubuntu'}, sentinel.src, sentinel.target, |
568 | - ( |
569 | - 'com.ubuntu.maas.daily:v3:boot:12.04:amd64:hwe-p', |
570 | - factory.make_name('product_version'), |
571 | - ), sentinel.contentsource) |
572 | + sentinel.data, sentinel.src, sentinel.target, |
573 | + sentinel.pedigree, sentinel.contentsource) |
574 | image_spec = make_image_spec( |
575 | os=os, release=release, arch=arch, subarch='generic', |
576 | label=label) |
577 | @@ -451,11 +368,8 @@ |
578 | 'products_exdata').side_effect = [hwep_item, hwes_item] |
579 | for _ in range(2): |
580 | dumper.insert_item( |
581 | - {'os': 'ubuntu'}, sentinel.src, sentinel.target, |
582 | - ( |
583 | - 'com.ubuntu.maas.daily:v3:boot:12.04:amd64:hwe-p', |
584 | - factory.make_name('product_version'), |
585 | - ), sentinel.contentsource) |
586 | + sentinel.data, sentinel.src, sentinel.target, |
587 | + sentinel.pedigree, sentinel.contentsource) |
588 | image_spec = make_image_spec( |
589 | os=os, release=release, arch=arch, subarch='generic', |
590 | label=label) |
591 | @@ -464,42 +378,21 @@ |
592 | def test_insert_item_sets_release_to_bootloader_type(self): |
593 | boot_images_dict = BootImageMapping() |
594 | dumper = RepoDumper(boot_images_dict) |
595 | - item, _ = self.make_item( |
596 | - arch='amd64', bootloader_type='uefi', os='grub-efi-signed') |
597 | + bootloader_type = factory.make_name('bootloader-type') |
598 | + item, _ = self.make_item(bootloader_type=bootloader_type) |
599 | self.patch( |
600 | download_descriptions, 'products_exdata').return_value = item |
601 | dumper.insert_item( |
602 | - { |
603 | - 'bootloader_type': 'uefi', |
604 | - 'os': 'grub-efi-signed', |
605 | - 'arch': 'amd64', |
606 | - }, sentinel.src, sentinel.target, |
607 | - ( |
608 | - 'com.ubuntu.maas.daily:1:grub-efi-signed:uefi:amd64', |
609 | - factory.make_name('product_version'), |
610 | - ), sentinel.contentsource) |
611 | + sentinel.data, sentinel.src, sentinel.target, |
612 | + sentinel.pedigree, sentinel.contentsource) |
613 | image_specs = [ |
614 | make_image_spec( |
615 | - os=item['os'], release='uefi', arch=item['arch'], |
616 | + os=item['os'], release=bootloader_type, arch=item['arch'], |
617 | subarch=subarch, kflavor='bootloader', label=item['label']) |
618 | for subarch in item['subarches'].split(',') |
619 | ] |
620 | self.assertItemsEqual(image_specs, list(boot_images_dict.mapping)) |
621 | |
622 | - def test_insert_item_validates(self): |
623 | - boot_images_dict = BootImageMapping() |
624 | - dumper = RepoDumper(boot_images_dict) |
625 | - item, _ = self.make_item(os='ubuntu') |
626 | - self.patch( |
627 | - download_descriptions, 'products_exdata').return_value = item |
628 | - dumper.insert_item( |
629 | - {'os': 'ubuntu'}, sentinel.src, sentinel.target, |
630 | - ( |
631 | - factory.make_name('product_name'), |
632 | - factory.make_name('product_version'), |
633 | - ), sentinel.contentsource) |
634 | - self.assertItemsEqual([], list(boot_images_dict.mapping)) |
635 | - |
636 | def test_sync_does_propagate_ioerror(self): |
637 | io_error = factory.make_exception_type(bases=(IOError,)) |
638 |