Merge lp:~andreserl/maas/lp1646955 into lp:~maas-committers/maas/trunk
- lp1646955
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 5603 | ||||
Proposed branch: | lp:~andreserl/maas/lp1646955 | ||||
Merge into: | lp:~maas-committers/maas/trunk | ||||
Diff against target: |
162 lines (+102/-1) 2 files modified
src/maasserver/preseed.py (+57/-1) src/maasserver/tests/test_preseed.py (+45/-0) |
||||
To merge this branch: | bzr merge lp:~andreserl/maas/lp1646955 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Andres Rodriguez (community) | Approve | ||
Blake Rouse (community) | Approve | ||
Review via email: mp+312851@code.launchpad.net |
Commit message
Re-add deprecated variables to the curtin preseed context so that MAAS doesn't fail rendering on machine deployment, causing machines to fail to deploy.
Description of the change
Mike Pontillo (mpontillo) wrote : | # |
Gavin Panella (allenap) : | # |
Blake Rouse (blake-rouse) wrote : | # |
Also missing commit message.
MAAS Lander (maas-lander) wrote : | # |
The attempt to merge lp:~andreserl/maas/lp1646955 into lp:maas failed. Below is the output from the failed tests.
Hit:1 http://
Get:2 http://
Get:3 http://
Get:4 http://
Fetched 306 kB in 0s (612 kB/s)
Reading package lists...
sudo DEBIAN_
--no-
Reading package lists...
Building dependency tree...
Reading state information...
authbind is already the newest version (2.1.1+nmu1).
avahi-utils is already the newest version (0.6.32~
build-essential is already the newest version (12.1ubuntu2).
debhelper is already the newest version (9.20160115ubun
distro-info is already the newest version (0.14build1).
git is already the newest version (1:2.7.4-0ubuntu1).
libjs-angularjs is already the newest version (1.2.28-1ubuntu2).
libjs-jquery is already the newest version (1.11.3+dfsg-4).
libjs-yui3-full is already the newest version (3.5.1-1ubuntu3).
libjs-yui3-min is already the newest version (3.5.1-1ubuntu3).
make is already the newest version (4.1-6).
postgresql is already the newest version (9.5+173).
pxelinux is already the newest version (3:6.03+
python-formencode is already the newest version (1.3.0-0ubuntu5).
python-lxml is already the newest version (3.5.0-1build1).
python-netaddr is already the newest version (0.7.18-1).
python-netifaces is already the newest version (0.10.4-0.1build2).
python-psycopg2 is...
MAAS Lander (maas-lander) wrote : | # |
There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.
Andres Rodriguez (andreserl) : | # |
MAAS Lander (maas-lander) wrote : | # |
The attempt to merge lp:~andreserl/maas/lp1646955 into lp:maas failed. Below is the output from the failed tests.
Hit:1 http://
Get:2 http://
Get:3 http://
Get:4 http://
Fetched 306 kB in 2s (124 kB/s)
Reading package lists...
sudo DEBIAN_
--no-
Reading package lists...
Building dependency tree...
Reading state information...
authbind is already the newest version (2.1.1+nmu1).
avahi-utils is already the newest version (0.6.32~
build-essential is already the newest version (12.1ubuntu2).
debhelper is already the newest version (9.20160115ubun
distro-info is already the newest version (0.14build1).
git is already the newest version (1:2.7.4-0ubuntu1).
libjs-angularjs is already the newest version (1.2.28-1ubuntu2).
libjs-jquery is already the newest version (1.11.3+dfsg-4).
libjs-yui3-full is already the newest version (3.5.1-1ubuntu3).
libjs-yui3-min is already the newest version (3.5.1-1ubuntu3).
make is already the newest version (4.1-6).
postgresql is already the newest version (9.5+173).
pxelinux is already the newest version (3:6.03+
python-formencode is already the newest version (1.3.0-0ubuntu5).
python-lxml is already the newest version (3.5.0-1build1).
python-netaddr is already the newest version (0.7.18-1).
python-netifaces is already the newest version (0.10.4-0.1build2).
python-psycopg2 is...
Andres Rodriguez (andreserl) : | # |
MAAS Lander (maas-lander) wrote : | # |
There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.
Andres Rodriguez (andreserl) : | # |
Preview Diff
1 | === modified file 'src/maasserver/preseed.py' |
2 | --- src/maasserver/preseed.py 2016-12-08 09:10:54 +0000 |
3 | +++ src/maasserver/preseed.py 2016-12-12 17:30:38 +0000 |
4 | @@ -62,7 +62,10 @@ |
5 | from metadataserver.models import NodeKey |
6 | from metadataserver.user_data.snippets import get_snippet_context |
7 | from provisioningserver.drivers.osystem.ubuntu import UbuntuOS |
8 | -from provisioningserver.logger import get_maas_logger |
9 | +from provisioningserver.logger import ( |
10 | + get_maas_logger, |
11 | + LegacyLogger, |
12 | +) |
13 | from provisioningserver.rpc.exceptions import NoConnectionsAvailable |
14 | from provisioningserver.utils import typed |
15 | from provisioningserver.utils.url import compose_URL |
16 | @@ -72,6 +75,8 @@ |
17 | |
18 | maaslog = get_maas_logger("preseed") |
19 | |
20 | +log = LegacyLogger() |
21 | + |
22 | GENERIC_FILENAME = 'generic' |
23 | |
24 | |
25 | @@ -417,9 +422,36 @@ |
26 | get_node_preseed_context( |
27 | node, osystem, series, rack_controller=rack_controller)) |
28 | context.update(get_curtin_context(node, rack_controller=rack_controller)) |
29 | + deprecated_context_variables = [ |
30 | + 'main_archive_hostname', 'main_archive_directory', |
31 | + 'ports_archive_hostname', 'ports_archive_directory', |
32 | + 'enable_http_proxy', 'http_proxy'] |
33 | + deprecated_config_variables = [] |
34 | + for var in deprecated_context_variables: |
35 | + if var not in context: |
36 | + deprecated_context_variables.remove(var) |
37 | + context.update(get_node_deprecated_preseed_context()) |
38 | config = yaml.load(template.substitute(**context)) |
39 | + # Remove deprecated config from the curtin preseed. |
40 | if 'power_state' in config: |
41 | del config['power_state'] |
42 | + deprecated_config_variables.append('power_state') |
43 | + if 'apt_proxy' in config: |
44 | + deprecated_config_variables.append('apt_proxy') |
45 | + del config['apt_proxy'] |
46 | + if 'apt_mirrors' in config: |
47 | + deprecated_config_variables.append('apt_mirrors') |
48 | + del config['apt_mirrors'] |
49 | + if deprecated_context_variables: |
50 | + log.warn( |
51 | + "WARNING: '%s' contains deprecated preseed " |
52 | + "variables. Please remove - %s" % ( |
53 | + template.name, ",".join(deprecated_context_variables))) |
54 | + if deprecated_config_variables: |
55 | + log.warn( |
56 | + "WARNING: '%s' contains deprecated preseed " |
57 | + "configuration. Please remove - %s" % ( |
58 | + template.name, ",".join(deprecated_config_variables))) |
59 | # Precise does not support cloud-init performing the reboot, so curtin |
60 | # must have this statement. |
61 | if node.distro_series == "precise": |
62 | @@ -721,6 +753,30 @@ |
63 | } |
64 | |
65 | |
66 | +def get_node_deprecated_preseed_context(): |
67 | + """Return the node-dependent context dictionary to be used to render |
68 | + preseed template. This includes all the context variables that have |
69 | + been deprecated, but allows for backwards compatibility for those |
70 | + preseeds that still contain old variables. |
71 | + |
72 | + :return: The context dictionary. |
73 | + :rtype: dict. |
74 | + """ |
75 | + main_archive_hostname, main_archive_directory = get_netloc_and_path( |
76 | + PackageRepository.get_main_archive().url) |
77 | + ports_archive_hostname, ports_archive_directory = get_netloc_and_path( |
78 | + PackageRepository.get_ports_archive().url) |
79 | + |
80 | + return { |
81 | + 'main_archive_hostname': main_archive_hostname, |
82 | + 'main_archive_directory': main_archive_directory, |
83 | + 'ports_archive_hostname': ports_archive_hostname, |
84 | + 'ports_archive_directory': ports_archive_directory, |
85 | + 'enable_http_proxy': Config.objects.get_config('enable_http_proxy'), |
86 | + 'http_proxy': Config.objects.get_config('http_proxy'), |
87 | + } |
88 | + |
89 | + |
90 | def render_enlistment_preseed( |
91 | prefix, osystem='', release='', rack_controller=None): |
92 | """Return the enlistment preseed. |
93 | |
94 | === modified file 'src/maasserver/tests/test_preseed.py' |
95 | --- src/maasserver/tests/test_preseed.py 2016-12-08 09:10:54 +0000 |
96 | +++ src/maasserver/tests/test_preseed.py 2016-12-12 17:30:38 +0000 |
97 | @@ -54,6 +54,7 @@ |
98 | get_enlist_preseed, |
99 | get_enlist_userdata, |
100 | get_netloc_and_path, |
101 | + get_node_deprecated_preseed_context, |
102 | get_node_preseed_context, |
103 | get_preseed, |
104 | get_preseed_context, |
105 | @@ -460,6 +461,23 @@ |
106 | context) |
107 | |
108 | |
109 | +class TestNodeDeprecatedPreseedContext( |
110 | + PreseedRPCMixin, BootImageHelperMixin, MAASTransactionServerTestCase): |
111 | + """Test for `get_node_deprecated_preseed_context`.""" |
112 | + |
113 | + def test_get_node_deprecated_preseed_context_contains_keys(self): |
114 | + node = factory.make_Node_with_Interface_on_Subnet( |
115 | + primary_rack=self.rpc_rack_controller) |
116 | + self.configure_get_boot_images_for_node(node, 'install') |
117 | + context = get_node_deprecated_preseed_context() |
118 | + self.assertItemsEqual( |
119 | + ['main_archive_hostname', 'main_archive_directory', |
120 | + 'ports_archive_hostname', 'ports_archive_directory', |
121 | + 'enable_http_proxy', 'http_proxy' |
122 | + ], |
123 | + context) |
124 | + |
125 | + |
126 | class TestNodePreseedContext( |
127 | PreseedRPCMixin, BootImageHelperMixin, MAASTransactionServerTestCase): |
128 | """Tests for `get_node_preseed_context`.""" |
129 | @@ -880,6 +898,33 @@ |
130 | config = get_curtin_config(node) |
131 | self.assertThat(config, Not(Contains('mode: reboot'))) |
132 | |
133 | + def test_get_curtin_config_removes_apt_mirrors(self): |
134 | + node = factory.make_Node_with_Interface_on_Subnet( |
135 | + primary_rack=self.rpc_rack_controller) |
136 | + self.configure_get_boot_images_for_node(node, 'xinstall') |
137 | + apt_mirrors_template = dedent("""\ |
138 | + apt_mirrors: |
139 | + ubuntu_archive: |
140 | + ubuntu_security: |
141 | + """) |
142 | + self.patch(preseed_module, "get_preseed_template").return_value = ( |
143 | + factory.make_name("filename"), apt_mirrors_template) |
144 | + config = get_curtin_config(node) |
145 | + self.assertThat(config, Not(Contains('ubuntu_archive'))) |
146 | + self.assertThat(config, Not(Contains('ubuntu_security'))) |
147 | + |
148 | + def test_get_curtin_config_removes_apt_proxy(self): |
149 | + node = factory.make_Node_with_Interface_on_Subnet( |
150 | + primary_rack=self.rpc_rack_controller) |
151 | + self.configure_get_boot_images_for_node(node, 'xinstall') |
152 | + apt_proxy_template = dedent("""\ |
153 | + apt_proxy: http://127.0.0.1:8000/ |
154 | + """) |
155 | + self.patch(preseed_module, "get_preseed_template").return_value = ( |
156 | + factory.make_name("filename"), apt_proxy_template) |
157 | + config = get_curtin_config(node) |
158 | + self.assertThat(config, Not(Contains('127.0.0.1'))) |
159 | + |
160 | def test_get_curtin_config_contains_reboot_for_precise(self): |
161 | node = factory.make_Node_with_Interface_on_Subnet( |
162 | primary_rack=self.rpc_rack_controller) |
Some minor nits below.