Merge lp:~jtv/maas/1.2-bug-1086239 into lp:maas/1.2
- 1.2-bug-1086239
- Merge into 1.2
Proposed by
Jeroen T. Vermeulen
Status: | Merged |
---|---|
Approved by: | Jeroen T. Vermeulen |
Approved revision: | no longer in the source branch. |
Merged at revision: | 1336 |
Proposed branch: | lp:~jtv/maas/1.2-bug-1086239 |
Merge into: | lp:maas/1.2 |
Diff against target: |
393 lines (+111/-68) 14 files modified
etc/democeleryconfig_cluster.py (+0/-4) services/cluster-worker/run (+5/-0) services/pserv/run (+5/-0) src/provisioningserver/auth.py (+0/-8) src/provisioningserver/boot_images.py (+5/-5) src/provisioningserver/cluster_config.py (+44/-0) src/provisioningserver/dhcp/leases.py (+2/-2) src/provisioningserver/dhcp/tests/test_leases.py (+0/-9) src/provisioningserver/start_cluster_controller.py (+1/-8) src/provisioningserver/tags.py (+2/-6) src/provisioningserver/tests/test_auth.py (+0/-12) src/provisioningserver/tests/test_boot_images.py (+0/-10) src/provisioningserver/tests/test_cluster_config.py (+46/-0) src/provisioningserver/tftp.py (+1/-4) |
To merge this branch: | bzr merge lp:~jtv/maas/1.2-bug-1086239 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jeroen T. Vermeulen (community) | Approve | ||
Review via email: mp+139498@code.launchpad.net |
Commit message
Backport trunk r1397: Take CLUSTER_UUID from maas_cluster.conf instead of maas_local_
Description of the change
Straight backport from trunk. Bug 1086239 is the capstone in the fix for bug 1084507.
Jeroen
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 'etc/democeleryconfig_cluster.py' | |||
2 | --- etc/democeleryconfig_cluster.py 2012-12-03 06:29:58 +0000 | |||
3 | +++ etc/democeleryconfig_cluster.py 2012-12-12 15:57:42 +0000 | |||
4 | @@ -26,10 +26,6 @@ | |||
5 | 26 | 26 | ||
6 | 27 | import_settings(democeleryconfig_common) | 27 | import_settings(democeleryconfig_common) |
7 | 28 | 28 | ||
8 | 29 | # Set a fixed CLUSTER_UUID. In production, this is taken from | ||
9 | 30 | # maas_local_celeryconfig. | ||
10 | 31 | CLUSTER_UUID = "adfd3977-f251-4f2c-8d61-745dbd690bfc" | ||
11 | 32 | |||
12 | 33 | CELERYD_LOG_FILE = os.path.join( | 29 | CELERYD_LOG_FILE = os.path.join( |
13 | 34 | DEV_ROOT_DIRECTORY, 'logs/cluster-worker/current') | 30 | DEV_ROOT_DIRECTORY, 'logs/cluster-worker/current') |
14 | 35 | 31 | ||
15 | 36 | 32 | ||
16 | === modified file 'services/cluster-worker/run' | |||
17 | --- services/cluster-worker/run 2012-10-03 11:39:37 +0000 | |||
18 | +++ services/cluster-worker/run 2012-12-12 15:57:42 +0000 | |||
19 | @@ -16,6 +16,11 @@ | |||
20 | 16 | 16 | ||
21 | 17 | export PYTHONPATH=etc/:src/ | 17 | export PYTHONPATH=etc/:src/ |
22 | 18 | export CELERY_CONFIG_MODULE=democeleryconfig_cluster | 18 | export CELERY_CONFIG_MODULE=democeleryconfig_cluster |
23 | 19 | |||
24 | 20 | # Set a fixed cluster UUID. This is identical for all cluster services | ||
25 | 21 | # running in the demo setup: they're all the same cluster. | ||
26 | 22 | export CLUSTER_UUID="adfd3977-f251-4f2c-8d61-745dbd690bfc" | ||
27 | 23 | |||
28 | 19 | script="$(readlink -f bin/maas-provision)" | 24 | script="$(readlink -f bin/maas-provision)" |
29 | 20 | exec fghack "${script}" start-cluster-controller \ | 25 | exec fghack "${script}" start-cluster-controller \ |
30 | 21 | http://0.0.0.0:5240/ -u "$(id -un)" -g "$(id -gn)" | 26 | http://0.0.0.0:5240/ -u "$(id -un)" -g "$(id -gn)" |
31 | 22 | 27 | ||
32 | === modified file 'services/pserv/run' | |||
33 | --- services/pserv/run 2012-09-26 14:16:33 +0000 | |||
34 | +++ services/pserv/run 2012-12-12 15:57:42 +0000 | |||
35 | @@ -17,5 +17,10 @@ | |||
36 | 17 | # Exec the Provisioning Server. | 17 | # Exec the Provisioning Server. |
37 | 18 | script="$(readlink -f bin/twistd.pserv)" | 18 | script="$(readlink -f bin/twistd.pserv)" |
38 | 19 | config="$(readlink -f etc/pserv.yaml)" | 19 | config="$(readlink -f etc/pserv.yaml)" |
39 | 20 | |||
40 | 21 | # Set a fixed cluster UUID. This is identical for all cluster services | ||
41 | 22 | # running in the demo setup: they're all the same cluster. | ||
42 | 23 | export CLUSTER_UUID="adfd3977-f251-4f2c-8d61-745dbd690bfc" | ||
43 | 24 | |||
44 | 20 | exec $(command -v authbind && echo --deep) \ | 25 | exec $(command -v authbind && echo --deep) \ |
45 | 21 | "${script}" --nodaemon --pidfile="" maas-pserv --config-file "${config}" | 26 | "${script}" --nodaemon --pidfile="" maas-pserv --config-file "${config}" |
46 | 22 | 27 | ||
47 | === modified file 'src/provisioningserver/auth.py' | |||
48 | --- src/provisioningserver/auth.py 2012-11-26 02:54:49 +0000 | |||
49 | +++ src/provisioningserver/auth.py 2012-12-12 15:57:42 +0000 | |||
50 | @@ -13,13 +13,10 @@ | |||
51 | 13 | __all__ = [ | 13 | __all__ = [ |
52 | 14 | 'get_recorded_api_credentials', | 14 | 'get_recorded_api_credentials', |
53 | 15 | 'get_recorded_nodegroup_uuid', | 15 | 'get_recorded_nodegroup_uuid', |
54 | 16 | 'get_recorded_maas_url', | ||
55 | 17 | 'record_api_credentials', | 16 | 'record_api_credentials', |
56 | 18 | 'record_nodegroup_uuid', | 17 | 'record_nodegroup_uuid', |
57 | 19 | ] | 18 | ] |
58 | 20 | 19 | ||
59 | 21 | import os | ||
60 | 22 | |||
61 | 23 | from apiclient.creds import convert_string_to_tuple | 20 | from apiclient.creds import convert_string_to_tuple |
62 | 24 | from provisioningserver import cache | 21 | from provisioningserver import cache |
63 | 25 | 22 | ||
64 | @@ -30,11 +27,6 @@ | |||
65 | 30 | NODEGROUP_UUID_CACHE_KEY = 'nodegroup_uuid' | 27 | NODEGROUP_UUID_CACHE_KEY = 'nodegroup_uuid' |
66 | 31 | 28 | ||
67 | 32 | 29 | ||
68 | 33 | def get_recorded_maas_url(): | ||
69 | 34 | """Return the base URL for the MAAS server.""" | ||
70 | 35 | return os.environ.get("MAAS_URL") | ||
71 | 36 | |||
72 | 37 | |||
73 | 38 | def record_api_credentials(api_credentials): | 30 | def record_api_credentials(api_credentials): |
74 | 39 | """Update the recorded API credentials. | 31 | """Update the recorded API credentials. |
75 | 40 | 32 | ||
76 | 41 | 33 | ||
77 | === modified file 'src/provisioningserver/boot_images.py' | |||
78 | --- src/provisioningserver/boot_images.py 2012-12-04 00:52:42 +0000 | |||
79 | +++ src/provisioningserver/boot_images.py 2012-12-12 15:57:42 +0000 | |||
80 | @@ -26,13 +26,13 @@ | |||
81 | 26 | MAASDispatcher, | 26 | MAASDispatcher, |
82 | 27 | MAASOAuth, | 27 | MAASOAuth, |
83 | 28 | ) | 28 | ) |
87 | 29 | from provisioningserver.auth import ( | 29 | from provisioningserver.auth import get_recorded_api_credentials |
88 | 30 | get_recorded_api_credentials, | 30 | from provisioningserver.cluster_config import ( |
89 | 31 | get_recorded_maas_url, | 31 | get_cluster_uuid, |
90 | 32 | get_maas_url, | ||
91 | 32 | ) | 33 | ) |
92 | 33 | from provisioningserver.config import Config | 34 | from provisioningserver.config import Config |
93 | 34 | from provisioningserver.pxe import tftppath | 35 | from provisioningserver.pxe import tftppath |
94 | 35 | from provisioningserver.start_cluster_controller import get_cluster_uuid | ||
95 | 36 | 36 | ||
96 | 37 | 37 | ||
97 | 38 | logger = getLogger(__name__) | 38 | logger = getLogger(__name__) |
98 | @@ -44,7 +44,7 @@ | |||
99 | 44 | :return: Tuple of cached items: (maas_url, api_credentials). Either may | 44 | :return: Tuple of cached items: (maas_url, api_credentials). Either may |
100 | 45 | be None if the information has not been received from the server yet. | 45 | be None if the information has not been received from the server yet. |
101 | 46 | """ | 46 | """ |
103 | 47 | maas_url = get_recorded_maas_url() | 47 | maas_url = get_maas_url() |
104 | 48 | if maas_url is None: | 48 | if maas_url is None: |
105 | 49 | logger.debug("Not reporting boot images: don't have API URL yet.") | 49 | logger.debug("Not reporting boot images: don't have API URL yet.") |
106 | 50 | api_credentials = get_recorded_api_credentials() | 50 | api_credentials = get_recorded_api_credentials() |
107 | 51 | 51 | ||
108 | === added file 'src/provisioningserver/cluster_config.py' | |||
109 | --- src/provisioningserver/cluster_config.py 1970-01-01 00:00:00 +0000 | |||
110 | +++ src/provisioningserver/cluster_config.py 2012-12-12 15:57:42 +0000 | |||
111 | @@ -0,0 +1,44 @@ | |||
112 | 1 | # Copyright 2012 Canonical Ltd. This software is licensed under the | ||
113 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | ||
114 | 3 | |||
115 | 4 | """Accessors for cluster configuration as set in `maas_cluster.conf`.""" | ||
116 | 5 | |||
117 | 6 | from __future__ import ( | ||
118 | 7 | absolute_import, | ||
119 | 8 | print_function, | ||
120 | 9 | unicode_literals, | ||
121 | 10 | ) | ||
122 | 11 | |||
123 | 12 | __metaclass__ = type | ||
124 | 13 | __all__ = [ | ||
125 | 14 | 'get_cluster_uuid', | ||
126 | 15 | 'get_maas_url', | ||
127 | 16 | ] | ||
128 | 17 | |||
129 | 18 | from os import environ | ||
130 | 19 | |||
131 | 20 | |||
132 | 21 | def get_cluster_variable(var): | ||
133 | 22 | """Obtain the given environment variable from maas_cluster.conf. | ||
134 | 23 | |||
135 | 24 | If the variable is not set, it probably means that whatever script | ||
136 | 25 | started the current process neglected to run maas_cluster.conf. | ||
137 | 26 | In that case, fail helpfully but utterly. | ||
138 | 27 | """ | ||
139 | 28 | value = environ.get(var) | ||
140 | 29 | if value is None: | ||
141 | 30 | raise AssertionError( | ||
142 | 31 | "%s is not set. This probably means that the script which " | ||
143 | 32 | "started this program failed to source maas_cluster.conf." | ||
144 | 33 | % var) | ||
145 | 34 | return value | ||
146 | 35 | |||
147 | 36 | |||
148 | 37 | def get_cluster_uuid(): | ||
149 | 38 | """Return the `CLUSTER_UUID` setting.""" | ||
150 | 39 | return get_cluster_variable('CLUSTER_UUID') | ||
151 | 40 | |||
152 | 41 | |||
153 | 42 | def get_maas_url(): | ||
154 | 43 | """Return the `MAAS_URL` setting.""" | ||
155 | 44 | return get_cluster_variable('MAAS_URL') | ||
156 | 0 | 45 | ||
157 | === modified file 'src/provisioningserver/dhcp/leases.py' | |||
158 | --- src/provisioningserver/dhcp/leases.py 2012-12-04 00:52:42 +0000 | |||
159 | +++ src/provisioningserver/dhcp/leases.py 2012-12-12 15:57:42 +0000 | |||
160 | @@ -49,9 +49,9 @@ | |||
161 | 49 | from provisioningserver import cache | 49 | from provisioningserver import cache |
162 | 50 | from provisioningserver.auth import ( | 50 | from provisioningserver.auth import ( |
163 | 51 | get_recorded_api_credentials, | 51 | get_recorded_api_credentials, |
164 | 52 | get_recorded_maas_url, | ||
165 | 53 | get_recorded_nodegroup_uuid, | 52 | get_recorded_nodegroup_uuid, |
166 | 54 | ) | 53 | ) |
167 | 54 | from provisioningserver.cluster_config import get_maas_url | ||
168 | 55 | from provisioningserver.dhcp.leases_parser import parse_leases | 55 | from provisioningserver.dhcp.leases_parser import parse_leases |
169 | 56 | 56 | ||
170 | 57 | 57 | ||
171 | @@ -150,7 +150,7 @@ | |||
172 | 150 | """Send lease updates to the server API.""" | 150 | """Send lease updates to the server API.""" |
173 | 151 | # Items that the server must have sent us before we can do this. | 151 | # Items that the server must have sent us before we can do this. |
174 | 152 | knowledge = { | 152 | knowledge = { |
176 | 153 | 'maas_url': get_recorded_maas_url(), | 153 | 'maas_url': get_maas_url(), |
177 | 154 | 'api_credentials': get_recorded_api_credentials(), | 154 | 'api_credentials': get_recorded_api_credentials(), |
178 | 155 | 'nodegroup_uuid': get_recorded_nodegroup_uuid(), | 155 | 'nodegroup_uuid': get_recorded_nodegroup_uuid(), |
179 | 156 | } | 156 | } |
180 | 157 | 157 | ||
181 | === modified file 'src/provisioningserver/dhcp/tests/test_leases.py' | |||
182 | --- src/provisioningserver/dhcp/tests/test_leases.py 2012-11-26 02:54:49 +0000 | |||
183 | +++ src/provisioningserver/dhcp/tests/test_leases.py 2012-12-12 15:57:42 +0000 | |||
184 | @@ -328,15 +328,6 @@ | |||
185 | 328 | (get_write_time(leases_file), {params['ip']: params['mac']}), | 328 | (get_write_time(leases_file), {params['ip']: params['mac']}), |
186 | 329 | parse_leases_file()) | 329 | parse_leases_file()) |
187 | 330 | 330 | ||
188 | 331 | def test_send_leases_does_nothing_without_maas_url(self): | ||
189 | 332 | self.patch(MAASClient, 'post', FakeMethod()) | ||
190 | 333 | self.set_lease_state() | ||
191 | 334 | self.set_items_needed_for_lease_update() | ||
192 | 335 | self.clear_maas_url() | ||
193 | 336 | leases = factory.make_random_leases() | ||
194 | 337 | send_leases(leases) | ||
195 | 338 | self.assertEqual([], MAASClient.post.calls) | ||
196 | 339 | |||
197 | 340 | def test_send_leases_does_nothing_without_credentials(self): | 331 | def test_send_leases_does_nothing_without_credentials(self): |
198 | 341 | self.patch(MAASClient, 'post', FakeMethod()) | 332 | self.patch(MAASClient, 'post', FakeMethod()) |
199 | 342 | self.set_items_needed_for_lease_update() | 333 | self.set_items_needed_for_lease_update() |
200 | 343 | 334 | ||
201 | === modified file 'src/provisioningserver/start_cluster_controller.py' | |||
202 | --- src/provisioningserver/start_cluster_controller.py 2012-12-04 00:52:42 +0000 | |||
203 | +++ src/provisioningserver/start_cluster_controller.py 2012-12-12 15:57:42 +0000 | |||
204 | @@ -32,6 +32,7 @@ | |||
205 | 32 | MAASDispatcher, | 32 | MAASDispatcher, |
206 | 33 | NoAuth, | 33 | NoAuth, |
207 | 34 | ) | 34 | ) |
208 | 35 | from provisioningserver.cluster_config import get_cluster_uuid | ||
209 | 35 | from provisioningserver.network import discover_networks | 36 | from provisioningserver.network import discover_networks |
210 | 36 | 37 | ||
211 | 37 | 38 | ||
212 | @@ -65,14 +66,6 @@ | |||
213 | 65 | return MAASClient(NoAuth(), MAASDispatcher(), server_url) | 66 | return MAASClient(NoAuth(), MAASDispatcher(), server_url) |
214 | 66 | 67 | ||
215 | 67 | 68 | ||
216 | 68 | def get_cluster_uuid(): | ||
217 | 69 | """Read this cluster's UUID from the config.""" | ||
218 | 70 | # Import this lazily. It reads config as a side effect, which can | ||
219 | 71 | # produce warnings. | ||
220 | 72 | from celery.app import app_or_default | ||
221 | 73 | return app_or_default().conf.CLUSTER_UUID | ||
222 | 74 | |||
223 | 75 | |||
224 | 76 | def register(server_url): | 69 | def register(server_url): |
225 | 77 | """Request Rabbit connection details from the domain controller. | 70 | """Request Rabbit connection details from the domain controller. |
226 | 78 | 71 | ||
227 | 79 | 72 | ||
228 | === modified file 'src/provisioningserver/tags.py' | |||
229 | --- src/provisioningserver/tags.py 2012-12-04 00:52:42 +0000 | |||
230 | +++ src/provisioningserver/tags.py 2012-12-12 15:57:42 +0000 | |||
231 | @@ -30,9 +30,9 @@ | |||
232 | 30 | from lxml import etree | 30 | from lxml import etree |
233 | 31 | from provisioningserver.auth import ( | 31 | from provisioningserver.auth import ( |
234 | 32 | get_recorded_api_credentials, | 32 | get_recorded_api_credentials, |
235 | 33 | get_recorded_maas_url, | ||
236 | 34 | get_recorded_nodegroup_uuid, | 33 | get_recorded_nodegroup_uuid, |
237 | 35 | ) | 34 | ) |
238 | 35 | from provisioningserver.cluster_config import get_maas_url | ||
239 | 36 | import simplejson as json | 36 | import simplejson as json |
240 | 37 | 37 | ||
241 | 38 | 38 | ||
242 | @@ -51,10 +51,6 @@ | |||
243 | 51 | 51 | ||
244 | 52 | :return: (client, nodegroup_uuid) | 52 | :return: (client, nodegroup_uuid) |
245 | 53 | """ | 53 | """ |
246 | 54 | maas_url = get_recorded_maas_url() | ||
247 | 55 | if maas_url is None: | ||
248 | 56 | logger.error("Not updating tags: don't have API URL yet.") | ||
249 | 57 | return None, None | ||
250 | 58 | api_credentials = get_recorded_api_credentials() | 54 | api_credentials = get_recorded_api_credentials() |
251 | 59 | if api_credentials is None: | 55 | if api_credentials is None: |
252 | 60 | logger.error("Not updating tags: don't have API key yet.") | 56 | logger.error("Not updating tags: don't have API key yet.") |
253 | @@ -64,7 +60,7 @@ | |||
254 | 64 | logger.error("Not updating tags: don't have UUID yet.") | 60 | logger.error("Not updating tags: don't have UUID yet.") |
255 | 65 | return None, None | 61 | return None, None |
256 | 66 | client = MAASClient(MAASOAuth(*api_credentials), MAASDispatcher(), | 62 | client = MAASClient(MAASOAuth(*api_credentials), MAASDispatcher(), |
258 | 67 | maas_url) | 63 | get_maas_url()) |
259 | 68 | return client, nodegroup_uuid | 64 | return client, nodegroup_uuid |
260 | 69 | 65 | ||
261 | 70 | 66 | ||
262 | 71 | 67 | ||
263 | === modified file 'src/provisioningserver/tests/test_auth.py' | |||
264 | --- src/provisioningserver/tests/test_auth.py 2012-12-04 03:33:53 +0000 | |||
265 | +++ src/provisioningserver/tests/test_auth.py 2012-12-12 15:57:42 +0000 | |||
266 | @@ -14,8 +14,6 @@ | |||
267 | 14 | 14 | ||
268 | 15 | from apiclient.creds import convert_tuple_to_string | 15 | from apiclient.creds import convert_tuple_to_string |
269 | 16 | from apiclient.testing.credentials import make_api_credentials | 16 | from apiclient.testing.credentials import make_api_credentials |
270 | 17 | from fixtures import EnvironmentVariableFixture | ||
271 | 18 | from maastesting.factory import factory | ||
272 | 19 | from provisioningserver import ( | 17 | from provisioningserver import ( |
273 | 20 | auth, | 18 | auth, |
274 | 21 | cache, | 19 | cache, |
275 | @@ -38,13 +36,3 @@ | |||
276 | 38 | 36 | ||
277 | 39 | def test_get_recorded_api_credentials_returns_None_without_creds(self): | 37 | def test_get_recorded_api_credentials_returns_None_without_creds(self): |
278 | 40 | self.assertIsNone(auth.get_recorded_api_credentials()) | 38 | self.assertIsNone(auth.get_recorded_api_credentials()) |
279 | 41 | |||
280 | 42 | def test_get_recorded_nodegroup_uuid_vs_record_nodegroup_uuid(self): | ||
281 | 43 | nodegroup_uuid = factory.make_name('nodegroupuuid') | ||
282 | 44 | auth.record_nodegroup_uuid(nodegroup_uuid) | ||
283 | 45 | self.assertEqual(nodegroup_uuid, auth.get_recorded_nodegroup_uuid()) | ||
284 | 46 | |||
285 | 47 | def test_get_recorded_maas_url_uses_environment_override(self): | ||
286 | 48 | required_url = factory.make_name("MAAS_URL") | ||
287 | 49 | self.useFixture(EnvironmentVariableFixture("MAAS_URL", required_url)) | ||
288 | 50 | self.assertEqual(required_url, auth.get_recorded_maas_url()) | ||
289 | 51 | 39 | ||
290 | === modified file 'src/provisioningserver/tests/test_boot_images.py' | |||
291 | --- src/provisioningserver/tests/test_boot_images.py 2012-11-26 02:54:49 +0000 | |||
292 | +++ src/provisioningserver/tests/test_boot_images.py 2012-12-12 15:57:42 +0000 | |||
293 | @@ -12,7 +12,6 @@ | |||
294 | 12 | __metaclass__ = type | 12 | __metaclass__ = type |
295 | 13 | __all__ = [] | 13 | __all__ = [] |
296 | 14 | 14 | ||
297 | 15 | import os | ||
298 | 16 | import json | 15 | import json |
299 | 17 | 16 | ||
300 | 18 | from apiclient.maas_client import MAASClient | 17 | from apiclient.maas_client import MAASClient |
301 | @@ -46,15 +45,6 @@ | |||
302 | 46 | self.assertIs(sentinel.uuid, kwargs["nodegroup"]) | 45 | self.assertIs(sentinel.uuid, kwargs["nodegroup"]) |
303 | 47 | self.assertItemsEqual([image], json.loads(kwargs['images'])) | 46 | self.assertItemsEqual([image], json.loads(kwargs['images'])) |
304 | 48 | 47 | ||
305 | 49 | def test_does_nothing_without_maas_url(self): | ||
306 | 50 | os.environ.pop("MAAS_URL") # Ensure nothing is set. | ||
307 | 51 | self.set_api_credentials() | ||
308 | 52 | self.patch( | ||
309 | 53 | tftppath, 'list_boot_images', | ||
310 | 54 | Mock(return_value=make_boot_image_params())) | ||
311 | 55 | boot_images.report_to_server() | ||
312 | 56 | self.assertItemsEqual([], tftppath.list_boot_images.call_args_list) | ||
313 | 57 | |||
314 | 58 | def test_does_nothing_without_credentials(self): | 48 | def test_does_nothing_without_credentials(self): |
315 | 59 | self.set_maas_url() | 49 | self.set_maas_url() |
316 | 60 | self.patch( | 50 | self.patch( |
317 | 61 | 51 | ||
318 | === added file 'src/provisioningserver/tests/test_cluster_config.py' | |||
319 | --- src/provisioningserver/tests/test_cluster_config.py 1970-01-01 00:00:00 +0000 | |||
320 | +++ src/provisioningserver/tests/test_cluster_config.py 2012-12-12 15:57:42 +0000 | |||
321 | @@ -0,0 +1,46 @@ | |||
322 | 1 | # Copyright 2012 Canonical Ltd. This software is licensed under the | ||
323 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | ||
324 | 3 | |||
325 | 4 | """Tests for `provisioningserver.cluster_config`.""" | ||
326 | 5 | |||
327 | 6 | from __future__ import ( | ||
328 | 7 | absolute_import, | ||
329 | 8 | print_function, | ||
330 | 9 | unicode_literals, | ||
331 | 10 | ) | ||
332 | 11 | |||
333 | 12 | __metaclass__ = type | ||
334 | 13 | __all__ = [] | ||
335 | 14 | |||
336 | 15 | from fixtures import EnvironmentVariableFixture | ||
337 | 16 | from maastesting.factory import factory | ||
338 | 17 | from maastesting.testcase import TestCase | ||
339 | 18 | from provisioningserver.cluster_config import ( | ||
340 | 19 | get_cluster_uuid, | ||
341 | 20 | get_cluster_variable, | ||
342 | 21 | get_maas_url, | ||
343 | 22 | ) | ||
344 | 23 | |||
345 | 24 | |||
346 | 25 | class TestClusterConfig(TestCase): | ||
347 | 26 | |||
348 | 27 | def test_get_cluster_variable_reads_env(self): | ||
349 | 28 | var = factory.make_name('variable') | ||
350 | 29 | value = factory.make_name('value') | ||
351 | 30 | self.useFixture(EnvironmentVariableFixture(var, value)) | ||
352 | 31 | self.assertEqual(value, get_cluster_variable(var)) | ||
353 | 32 | |||
354 | 33 | def test_get_cluster_variable_fails_if_not_set(self): | ||
355 | 34 | self.assertRaises( | ||
356 | 35 | AssertionError, | ||
357 | 36 | get_cluster_variable, factory.make_name('nonexistent-variable')) | ||
358 | 37 | |||
359 | 38 | def test_get_cluster_uuid_reads_CLUSTER_UUID(self): | ||
360 | 39 | uuid = factory.make_name('uuid') | ||
361 | 40 | self.useFixture(EnvironmentVariableFixture('CLUSTER_UUID', uuid)) | ||
362 | 41 | self.assertEqual(uuid, get_cluster_uuid()) | ||
363 | 42 | |||
364 | 43 | def test_get_maas_url_reads_MAAS_URL(self): | ||
365 | 44 | maas_url = factory.make_name('maas_url') | ||
366 | 45 | self.useFixture(EnvironmentVariableFixture('MAAS_URL', maas_url)) | ||
367 | 46 | self.assertEqual(maas_url, get_maas_url()) | ||
368 | 0 | 47 | ||
369 | === modified file 'src/provisioningserver/tftp.py' | |||
370 | --- src/provisioningserver/tftp.py 2012-12-11 12:00:25 +0000 | |||
371 | +++ src/provisioningserver/tftp.py 2012-12-12 15:57:42 +0000 | |||
372 | @@ -25,10 +25,10 @@ | |||
373 | 25 | urlparse, | 25 | urlparse, |
374 | 26 | ) | 26 | ) |
375 | 27 | 27 | ||
376 | 28 | from provisioningserver.cluster_config import get_cluster_uuid | ||
377 | 28 | from provisioningserver.enum import ARP_HTYPE | 29 | from provisioningserver.enum import ARP_HTYPE |
378 | 29 | from provisioningserver.kernel_opts import KernelParameters | 30 | from provisioningserver.kernel_opts import KernelParameters |
379 | 30 | from provisioningserver.pxe.config import render_pxe_config | 31 | from provisioningserver.pxe.config import render_pxe_config |
380 | 31 | from provisioningserver.start_cluster_controller import get_cluster_uuid | ||
381 | 32 | from provisioningserver.utils import deferred | 32 | from provisioningserver.utils import deferred |
382 | 33 | from tftp.backend import ( | 33 | from tftp.backend import ( |
383 | 34 | FilesystemSynchronousBackend, | 34 | FilesystemSynchronousBackend, |
384 | @@ -218,9 +218,6 @@ | |||
385 | 218 | params["local"] = local_host | 218 | params["local"] = local_host |
386 | 219 | remote_host, remote_port = get("remote", (None, None)) | 219 | remote_host, remote_port = get("remote", (None, None)) |
387 | 220 | params["remote"] = remote_host | 220 | params["remote"] = remote_host |
388 | 221 | # XXX 2012-12-04 JeroenVermeulen bug=1086239: move | ||
389 | 222 | # get_cluster_uuid to a properly reusable location, and | ||
390 | 223 | # implement it without the celery import (and side effects). | ||
391 | 224 | params["cluster_uuid"] = get_cluster_uuid() | 221 | params["cluster_uuid"] = get_cluster_uuid() |
392 | 225 | d = self.get_config_reader(params) | 222 | d = self.get_config_reader(params) |
393 | 226 | d.addErrback(self.get_page_errback, file_name) | 223 | d.addErrback(self.get_page_errback, file_name) |
Backports cleanly, and passes tests. The matching packaging changes have landed in the Quantal and Precise packaging branches. Self-approving.