Merge lp:~blake-rouse/maas/fix-1515671 into lp:~maas-committers/maas/trunk

Proposed by Blake Rouse
Status: Merged
Approved by: Blake Rouse
Approved revision: no longer in the source branch.
Merged at revision: 4494
Proposed branch: lp:~blake-rouse/maas/fix-1515671
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 152 lines (+86/-1)
2 files modified
src/maasserver/compose_preseed.py (+41/-1)
src/maasserver/tests/test_compose_preseed.py (+45/-0)
To merge this branch: bzr merge lp:~blake-rouse/maas/fix-1515671
Reviewer Review Type Date Requested Status
Mike Pontillo (community) Approve
Review via email: mp+277377@code.launchpad.net

Commit message

Add apt_mirror in the cloud-init preseed.

To post a comment you must log in.
Revision history for this message
Mike Pontillo (mpontillo) wrote :

Looks good. This is difficult to unit test, and I understand this code has already been tested at a customer site, so I'm approving.

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

The attempt to merge lp:~blake-rouse/maas/fix-1515671 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 [99.2 kB]
Get:4 http://nova.clouds.archive.ubuntu.com trusty-updates/main Sources [244 kB]
Get:5 http://security.ubuntu.com trusty-security/universe Sources [31.5 kB]
Get:6 http://security.ubuntu.com trusty-security/main amd64 Packages [370 kB]
Get:7 http://nova.clouds.archive.ubuntu.com trusty-updates/universe Sources [143 kB]
Get:8 http://security.ubuntu.com trusty-security/universe amd64 Packages [119 kB]
Get:9 http://security.ubuntu.com trusty-security/main Translation-en [200 kB]
Get:10 http://nova.clouds.archive.ubuntu.com trusty-updates/main amd64 Packages [652 kB]
Get:11 http://security.ubuntu.com trusty-security/universe Translation-en [69.6 kB]
Get:12 http://nova.clouds.archive.ubuntu.com trusty-updates/universe amd64 Packages [327 kB]
Get:13 http://nova.clouds.archive.ubuntu.com trusty-updates/main Translation-en [319 kB]
Get:14 http://nova.clouds.archive.ubuntu.com trusty-updates/universe Translation-en [172 kB]
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,877 kB in 4s (638 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 py...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/compose_preseed.py'
2--- src/maasserver/compose_preseed.py 2015-10-30 18:12:45 +0000
3+++ src/maasserver/compose_preseed.py 2015-11-12 19:17:29 +0000
4@@ -43,6 +43,42 @@
5 return None
6
7
8+def get_system_info():
9+ """Return the system info which includes the APT mirror information."""
10+ return {
11+ "system_info": {
12+ "package_mirrors": [
13+ {
14+ "arches": ["i386", "amd64"],
15+ "search": {
16+ "primary": [
17+ Config.objects.get_config("main_archive")],
18+ "security": [
19+ Config.objects.get_config("main_archive")],
20+ },
21+ "failsafe": {
22+ "primary": "http://archive.ubuntu.com/ubuntu",
23+ "security": "http://security.ubuntu.com/ubuntu",
24+ }
25+ },
26+ {
27+ "arches": ["default"],
28+ "search": {
29+ "primary": [
30+ Config.objects.get_config("ports_archive")],
31+ "security": [
32+ Config.objects.get_config("ports_archive")],
33+ },
34+ "failsafe": {
35+ "primary": "http://ports.ubuntu.com/ubuntu-ports",
36+ "security": "http://ports.ubuntu.com/ubuntu-ports",
37+ }
38+ },
39+ ]
40+ }
41+ }
42+
43+
44 def compose_cloud_init_preseed(node, token, base_url=''):
45 """Compose the preseed value for a node in any state but Commissioning."""
46 credentials = urlencode({
47@@ -75,8 +111,10 @@
48 'token_key': token.key,
49 'token_secret': token.secret,
50 }
51- },
52+ }
53 }
54+ # Add the system configuration information.
55+ config.update(get_system_info())
56 apt_proxy = get_apt_proxy_for_node(node)
57 use_apt_proxy = (
58 apt_proxy is not None and len(apt_proxy) > 0 and not
59@@ -146,6 +184,8 @@
60 },
61 },
62 }
63+ # Add the system configuration information.
64+ cloud_config.update(get_system_info())
65 if apt_proxy:
66 cloud_config['apt_proxy'] = apt_proxy
67 return "#cloud-config\n%s" % yaml.safe_dump(cloud_config)
68
69=== modified file 'src/maasserver/tests/test_compose_preseed.py'
70--- src/maasserver/tests/test_compose_preseed.py 2015-10-30 16:03:19 +0000
71+++ src/maasserver/tests/test_compose_preseed.py 2015-11-12 19:17:29 +0000
72@@ -38,7 +38,11 @@
73 )
74 from provisioningserver.testing.os import make_osystem
75 from testtools.matchers import (
76+ ContainsDict,
77+ Equals,
78 KeysEqual,
79+ MatchesDict,
80+ MatchesListwise,
81 StartsWith,
82 )
83 import yaml
84@@ -46,6 +50,44 @@
85
86 class TestComposePreseed(MAASServerTestCase):
87
88+ def assertSystemInfo(self, config):
89+ self.assertThat(config, ContainsDict({
90+ 'system_info': MatchesDict({
91+ 'package_mirrors': MatchesListwise([
92+ MatchesDict({
93+ "arches": Equals(["i386", "amd64"]),
94+ "search": MatchesDict({
95+ "primary": Equals(
96+ [Config.objects.get_config("main_archive")]),
97+ "security": Equals(
98+ [Config.objects.get_config("main_archive")]),
99+ }),
100+ "failsafe": MatchesDict({
101+ "primary": Equals(
102+ "http://archive.ubuntu.com/ubuntu"),
103+ "security": Equals(
104+ "http://security.ubuntu.com/ubuntu"),
105+ })
106+ }),
107+ MatchesDict({
108+ "arches": Equals(["default"]),
109+ "search": MatchesDict({
110+ "primary": Equals(
111+ [Config.objects.get_config("ports_archive")]),
112+ "security": Equals(
113+ [Config.objects.get_config("ports_archive")]),
114+ }),
115+ "failsafe": MatchesDict({
116+ "primary": Equals(
117+ "http://ports.ubuntu.com/ubuntu-ports"),
118+ "security": Equals(
119+ "http://ports.ubuntu.com/ubuntu-ports"),
120+ })
121+ }),
122+ ]),
123+ }),
124+ }))
125+
126 def test_compose_preseed_for_commissioning_node_skips_apt_proxy(self):
127 node = factory.make_Node(status=NODE_STATUS.COMMISSIONING)
128 Config.objects.set_config("enable_http_proxy", False)
129@@ -70,6 +112,7 @@
130 KeysEqual(
131 'consumer_key', 'endpoint', 'token_key', 'token_secret',
132 'type'))
133+ self.assertSystemInfo(preseed)
134
135 def test_compose_preseed_for_commissioning_node_has_header(self):
136 node = factory.make_Node(status=NODE_STATUS.COMMISSIONING)
137@@ -150,6 +193,7 @@
138 self.assertTrue(data["apt_preserve_sources_list"])
139 self.assertEqual(apt_proxy, data["apt_proxy"])
140 self.assertTrue(data["manual_cache_clean"])
141+ self.assertSystemInfo(data)
142
143 def test_compose_preseed_skips_apt_proxy(self):
144 node = factory.make_Node(status=NODE_STATUS.READY)
145@@ -178,6 +222,7 @@
146 absolute_reverse('curtin-metadata'),
147 preseed['datasource']['MAAS']['metadata_url'])
148 self.assertEqual(apt_proxy, preseed['apt_proxy'])
149+ self.assertSystemInfo(preseed)
150
151 def test_compose_preseed_with_curtin_installer_skips_apt_proxy(self):
152 node = factory.make_Node(