Merge lp:~gmb/maas/config-becomes-sources into lp:~maas-committers/maas/trunk

Proposed by Graham Binns
Status: Merged
Approved by: Jeroen T. Vermeulen
Approved revision: no longer in the source branch.
Merged at revision: 2356
Proposed branch: lp:~gmb/maas/config-becomes-sources
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 61 lines (+8/-8)
3 files modified
src/provisioningserver/import_images/boot_resources.py (+5/-5)
src/provisioningserver/import_images/download_descriptions.py (+2/-2)
src/provisioningserver/tasks.py (+1/-1)
To merge this branch: bzr merge lp:~gmb/maas/config-becomes-sources
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) Approve
Review via email: mp+220621@code.launchpad.net

Commit message

boot_resources.import_images() now accepts a 'sources' parameter where previously it accepted a 'config' parameter. This is because only the 'sources' parameter is actually needed.

To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

byuutifəl.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/provisioningserver/import_images/boot_resources.py'
2--- src/provisioningserver/import_images/boot_resources.py 2014-05-22 08:28:28 +0000
3+++ src/provisioningserver/import_images/boot_resources.py 2014-05-22 11:26:07 +0000
4@@ -199,18 +199,18 @@
5 return BootConfig.parse(config_stream)
6
7
8-def import_images(config):
9+def import_images(sources):
10 """Import images. Callable from both command line and Celery task.
11
12- :param config: A dict representing the boot-resources configuration.
13+ :param config: An iterable of dicts representing the sources from
14+ which boot images will be downloaded.
15 """
16 logger.info("Importing boot resources.")
17- sources = config['boot']['sources']
18 if len(sources) == 0:
19 logger.warn("Can't import: no Simplestreams sources configured.")
20 return
21
22- image_descriptions = download_all_image_descriptions(config)
23+ image_descriptions = download_all_image_descriptions(sources)
24 if image_descriptions.is_empty():
25 logger.warn(
26 "No boot resources found. Check configuration and connectivity.")
27@@ -264,4 +264,4 @@
28 config = read_config(args.config_file)
29 else:
30 raise NoConfig()
31- import_images(config=config)
32+ import_images(sources=config['boot']['sources'])
33
34=== modified file 'src/provisioningserver/import_images/download_descriptions.py'
35--- src/provisioningserver/import_images/download_descriptions.py 2014-05-16 05:51:06 +0000
36+++ src/provisioningserver/import_images/download_descriptions.py 2014-05-22 11:26:07 +0000
37@@ -183,10 +183,10 @@
38 return boot_images_dict
39
40
41-def download_all_image_descriptions(config):
42+def download_all_image_descriptions(sources):
43 """Download image metadata for all sources in `config`."""
44 boot = BootImageMapping()
45- for source in config['boot']['sources']:
46+ for source in sources:
47 repo_boot = download_image_descriptions(
48 source['path'], keyring=source['keyring'])
49 boot_merge(boot, repo_boot, source['selections'])
50
51=== modified file 'src/provisioningserver/tasks.py'
52--- src/provisioningserver/tasks.py 2014-05-21 17:03:00 +0000
53+++ src/provisioningserver/tasks.py 2014-05-22 11:26:07 +0000
54@@ -459,7 +459,7 @@
55 variables['http_proxy'] = http_proxy
56 variables['https_proxy'] = http_proxy
57 with environment_variables(variables):
58- boot_resources.import_images(config)
59+ boot_resources.import_images(config['boot']['sources'])
60 if callback is not None:
61 callback.delay()
62