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
=== modified file 'src/maasserver/compose_preseed.py'
--- src/maasserver/compose_preseed.py 2015-10-30 18:12:45 +0000
+++ src/maasserver/compose_preseed.py 2015-11-12 19:17:29 +0000
@@ -43,6 +43,42 @@
43 return None43 return None
4444
4545
46def get_system_info():
47 """Return the system info which includes the APT mirror information."""
48 return {
49 "system_info": {
50 "package_mirrors": [
51 {
52 "arches": ["i386", "amd64"],
53 "search": {
54 "primary": [
55 Config.objects.get_config("main_archive")],
56 "security": [
57 Config.objects.get_config("main_archive")],
58 },
59 "failsafe": {
60 "primary": "http://archive.ubuntu.com/ubuntu",
61 "security": "http://security.ubuntu.com/ubuntu",
62 }
63 },
64 {
65 "arches": ["default"],
66 "search": {
67 "primary": [
68 Config.objects.get_config("ports_archive")],
69 "security": [
70 Config.objects.get_config("ports_archive")],
71 },
72 "failsafe": {
73 "primary": "http://ports.ubuntu.com/ubuntu-ports",
74 "security": "http://ports.ubuntu.com/ubuntu-ports",
75 }
76 },
77 ]
78 }
79 }
80
81
46def compose_cloud_init_preseed(node, token, base_url=''):82def compose_cloud_init_preseed(node, token, base_url=''):
47 """Compose the preseed value for a node in any state but Commissioning."""83 """Compose the preseed value for a node in any state but Commissioning."""
48 credentials = urlencode({84 credentials = urlencode({
@@ -75,8 +111,10 @@
75 'token_key': token.key,111 'token_key': token.key,
76 'token_secret': token.secret,112 'token_secret': token.secret,
77 }113 }
78 },114 }
79 }115 }
116 # Add the system configuration information.
117 config.update(get_system_info())
80 apt_proxy = get_apt_proxy_for_node(node)118 apt_proxy = get_apt_proxy_for_node(node)
81 use_apt_proxy = (119 use_apt_proxy = (
82 apt_proxy is not None and len(apt_proxy) > 0 and not120 apt_proxy is not None and len(apt_proxy) > 0 and not
@@ -146,6 +184,8 @@
146 },184 },
147 },185 },
148 }186 }
187 # Add the system configuration information.
188 cloud_config.update(get_system_info())
149 if apt_proxy:189 if apt_proxy:
150 cloud_config['apt_proxy'] = apt_proxy190 cloud_config['apt_proxy'] = apt_proxy
151 return "#cloud-config\n%s" % yaml.safe_dump(cloud_config)191 return "#cloud-config\n%s" % yaml.safe_dump(cloud_config)
152192
=== modified file 'src/maasserver/tests/test_compose_preseed.py'
--- src/maasserver/tests/test_compose_preseed.py 2015-10-30 16:03:19 +0000
+++ src/maasserver/tests/test_compose_preseed.py 2015-11-12 19:17:29 +0000
@@ -38,7 +38,11 @@
38)38)
39from provisioningserver.testing.os import make_osystem39from provisioningserver.testing.os import make_osystem
40from testtools.matchers import (40from testtools.matchers import (
41 ContainsDict,
42 Equals,
41 KeysEqual,43 KeysEqual,
44 MatchesDict,
45 MatchesListwise,
42 StartsWith,46 StartsWith,
43)47)
44import yaml48import yaml
@@ -46,6 +50,44 @@
4650
47class TestComposePreseed(MAASServerTestCase):51class TestComposePreseed(MAASServerTestCase):
4852
53 def assertSystemInfo(self, config):
54 self.assertThat(config, ContainsDict({
55 'system_info': MatchesDict({
56 'package_mirrors': MatchesListwise([
57 MatchesDict({
58 "arches": Equals(["i386", "amd64"]),
59 "search": MatchesDict({
60 "primary": Equals(
61 [Config.objects.get_config("main_archive")]),
62 "security": Equals(
63 [Config.objects.get_config("main_archive")]),
64 }),
65 "failsafe": MatchesDict({
66 "primary": Equals(
67 "http://archive.ubuntu.com/ubuntu"),
68 "security": Equals(
69 "http://security.ubuntu.com/ubuntu"),
70 })
71 }),
72 MatchesDict({
73 "arches": Equals(["default"]),
74 "search": MatchesDict({
75 "primary": Equals(
76 [Config.objects.get_config("ports_archive")]),
77 "security": Equals(
78 [Config.objects.get_config("ports_archive")]),
79 }),
80 "failsafe": MatchesDict({
81 "primary": Equals(
82 "http://ports.ubuntu.com/ubuntu-ports"),
83 "security": Equals(
84 "http://ports.ubuntu.com/ubuntu-ports"),
85 })
86 }),
87 ]),
88 }),
89 }))
90
49 def test_compose_preseed_for_commissioning_node_skips_apt_proxy(self):91 def test_compose_preseed_for_commissioning_node_skips_apt_proxy(self):
50 node = factory.make_Node(status=NODE_STATUS.COMMISSIONING)92 node = factory.make_Node(status=NODE_STATUS.COMMISSIONING)
51 Config.objects.set_config("enable_http_proxy", False)93 Config.objects.set_config("enable_http_proxy", False)
@@ -70,6 +112,7 @@
70 KeysEqual(112 KeysEqual(
71 'consumer_key', 'endpoint', 'token_key', 'token_secret',113 'consumer_key', 'endpoint', 'token_key', 'token_secret',
72 'type'))114 'type'))
115 self.assertSystemInfo(preseed)
73116
74 def test_compose_preseed_for_commissioning_node_has_header(self):117 def test_compose_preseed_for_commissioning_node_has_header(self):
75 node = factory.make_Node(status=NODE_STATUS.COMMISSIONING)118 node = factory.make_Node(status=NODE_STATUS.COMMISSIONING)
@@ -150,6 +193,7 @@
150 self.assertTrue(data["apt_preserve_sources_list"])193 self.assertTrue(data["apt_preserve_sources_list"])
151 self.assertEqual(apt_proxy, data["apt_proxy"])194 self.assertEqual(apt_proxy, data["apt_proxy"])
152 self.assertTrue(data["manual_cache_clean"])195 self.assertTrue(data["manual_cache_clean"])
196 self.assertSystemInfo(data)
153197
154 def test_compose_preseed_skips_apt_proxy(self):198 def test_compose_preseed_skips_apt_proxy(self):
155 node = factory.make_Node(status=NODE_STATUS.READY)199 node = factory.make_Node(status=NODE_STATUS.READY)
@@ -178,6 +222,7 @@
178 absolute_reverse('curtin-metadata'),222 absolute_reverse('curtin-metadata'),
179 preseed['datasource']['MAAS']['metadata_url'])223 preseed['datasource']['MAAS']['metadata_url'])
180 self.assertEqual(apt_proxy, preseed['apt_proxy'])224 self.assertEqual(apt_proxy, preseed['apt_proxy'])
225 self.assertSystemInfo(preseed)
181226
182 def test_compose_preseed_with_curtin_installer_skips_apt_proxy(self):227 def test_compose_preseed_with_curtin_installer_skips_apt_proxy(self):
183 node = factory.make_Node(228 node = factory.make_Node(