Merge ~ltrager/maas:remove_get_boot_sources_v1 into maas:master

Proposed by Lee Trager
Status: Merged
Approved by: Lee Trager
Approved revision: 4fd1831ecd69b9b74c0c6f76ca2f39ba6fb960d9
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~ltrager/maas:remove_get_boot_sources_v1
Merge into: maas:master
Diff against target: 316 lines (+8/-183)
5 files modified
src/maasserver/rpc/regionservice.py (+1/-14)
src/maasserver/rpc/tests/test_regionservice_calls.py (+0/-21)
src/provisioningserver/rackdservices/image_download_service.py (+4/-25)
src/provisioningserver/rackdservices/tests/test_image_download_service.py (+2/-85)
src/provisioningserver/rpc/region.py (+1/-38)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Björn Tillenius Approve
Review via email: mp+402296@code.launchpad.net

Commit message

Remove the GetBootSources V1 RPC call.

To post a comment you must log in.
Revision history for this message
Björn Tillenius (bjornt) wrote :

+1

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b remove_get_boot_sources_v1 lp:~ltrager/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 4fd1831ecd69b9b74c0c6f76ca2f39ba6fb960d9

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/maasserver/rpc/regionservice.py b/src/maasserver/rpc/regionservice.py
index 1ec0997..950b8d3 100644
--- a/src/maasserver/rpc/regionservice.py
+++ b/src/maasserver/rpc/regionservice.py
@@ -1,4 +1,4 @@
1# Copyright 2014-2018 Canonical Ltd. This software is licensed under the1# Copyright 2014-2021 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""RPC implementation for regions."""4"""RPC implementation for regions."""
@@ -207,19 +207,6 @@ class Region(RPCProtocol):
207207
208 @region.GetBootSources.responder208 @region.GetBootSources.responder
209 def get_boot_sources(self, uuid):209 def get_boot_sources(self, uuid):
210 """get_boot_sources()
211
212 Deprecated: get_boot_sources_v2() should be used instead.
213
214 Implementation of
215 :py:class:`~provisioningserver.rpc.region.GetBootSources`.
216 """
217 d = deferToDatabase(get_simplestream_endpoint)
218 d.addCallback(lambda source: {"sources": [source]})
219 return d
220
221 @region.GetBootSourcesV2.responder
222 def get_boot_sources_v2(self, uuid):
223 """get_boot_sources_v2()210 """get_boot_sources_v2()
224211
225 Implementation of212 Implementation of
diff --git a/src/maasserver/rpc/tests/test_regionservice_calls.py b/src/maasserver/rpc/tests/test_regionservice_calls.py
index 2949f9e..604b168 100644
--- a/src/maasserver/rpc/tests/test_regionservice_calls.py
+++ b/src/maasserver/rpc/tests/test_regionservice_calls.py
@@ -56,7 +56,6 @@ from provisioningserver.rpc.region import (
56 GetArchiveMirrors,56 GetArchiveMirrors,
57 GetBootConfig,57 GetBootConfig,
58 GetBootSources,58 GetBootSources,
59 GetBootSourcesV2,
60 GetControllerType,59 GetControllerType,
61 GetDNSConfiguration,60 GetDNSConfiguration,
62 GetProxies,61 GetProxies,
@@ -341,26 +340,6 @@ class TestRegionProtocol_GetBootSources(MAASTransactionServerTestCase):
341 return d.addCallback(check)340 return d.addCallback(check)
342341
343342
344class TestRegionProtocol_GetBootSourcesV2(MAASTransactionServerTestCase):
345 def test_get_boot_sources_v2_is_registered(self):
346 protocol = Region()
347 responder = protocol.locateResponder(GetBootSourcesV2.commandName)
348 self.assertIsNotNone(responder)
349
350 @wait_for_reactor
351 def test_get_boot_sources_v2_returns_simplestreams_endpoint(self):
352 uuid = factory.make_name("uuid")
353
354 d = call_responder(Region(), GetBootSourcesV2, {"uuid": uuid})
355
356 def check(response):
357 self.assertEqual(
358 {"sources": [get_simplestream_endpoint()]}, response
359 )
360
361 return d.addCallback(check)
362
363
364class TestRegionProtocol_GetArchiveMirrors(MAASTransactionServerTestCase):343class TestRegionProtocol_GetArchiveMirrors(MAASTransactionServerTestCase):
365 def test_get_archive_mirrors_is_registered(self):344 def test_get_archive_mirrors_is_registered(self):
366 protocol = Region()345 protocol = Region()
diff --git a/src/provisioningserver/rackdservices/image_download_service.py b/src/provisioningserver/rackdservices/image_download_service.py
index a86e879..87e8fb1 100644
--- a/src/provisioningserver/rackdservices/image_download_service.py
+++ b/src/provisioningserver/rackdservices/image_download_service.py
@@ -1,4 +1,4 @@
1# Copyright 2014-2016 Canonical Ltd. This software is licensed under the1# Copyright 2014-2021 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Service to periodically refresh the boot images."""4"""Service to periodically refresh the boot images."""
@@ -7,18 +7,13 @@
7from datetime import timedelta7from datetime import timedelta
88
9from twisted.application.internet import TimerService9from twisted.application.internet import TimerService
10from twisted.internet.defer import inlineCallbacks, returnValue10from twisted.internet.defer import inlineCallbacks
11from twisted.protocols.amp import UnhandledCommand
1211
13from provisioningserver.boot import tftppath12from provisioningserver.boot import tftppath
14from provisioningserver.logger import get_maas_logger, LegacyLogger13from provisioningserver.logger import get_maas_logger, LegacyLogger
15from provisioningserver.rpc.boot_images import import_boot_images14from provisioningserver.rpc.boot_images import import_boot_images
16from provisioningserver.rpc.exceptions import NoConnectionsAvailable15from provisioningserver.rpc.exceptions import NoConnectionsAvailable
17from provisioningserver.rpc.region import (16from provisioningserver.rpc.region import GetBootSources, GetProxies
18 GetBootSources,
19 GetBootSourcesV2,
20 GetProxies,
21)
22from provisioningserver.utils.twisted import pause, retries17from provisioningserver.utils.twisted import pause, retries
2318
24maaslog = get_maas_logger("boot_image_download_service")19maaslog = get_maas_logger("boot_image_download_service")
@@ -58,22 +53,6 @@ class ImageDownloadService(TimerService):
58 return self.maybe_start_download().addErrback(download_failure)53 return self.maybe_start_download().addErrback(download_failure)
5954
60 @inlineCallbacks55 @inlineCallbacks
61 def _get_boot_sources(self, client):
62 """Gets the boot sources from the region."""
63 try:
64 sources = yield client(GetBootSourcesV2, uuid=client.localIdent)
65 except UnhandledCommand:
66 # Region has not been upgraded to support the new call, use the
67 # old call. The old call did not provide the new os selection
68 # parameter. Region does not support boot source selection by os,
69 # so its set too allow all operating systems.
70 sources = yield client(GetBootSources, uuid=client.localIdent)
71 for source in sources["sources"]:
72 for selection in source["selections"]:
73 selection["os"] = "*"
74 returnValue(sources)
75
76 @inlineCallbacks
77 def _start_download(self):56 def _start_download(self):
78 client = None57 client = None
79 # Retry a few times, since this service usually comes up before58 # Retry a few times, since this service usually comes up before
@@ -91,7 +70,7 @@ class ImageDownloadService(TimerService):
91 return70 return
9271
93 # Get sources from region72 # Get sources from region
94 sources = yield self._get_boot_sources(client)73 sources = yield client(GetBootSources, uuid=client.localIdent)
95 # Get http proxy from region74 # Get http proxy from region
96 proxies = yield client(GetProxies)75 proxies = yield client(GetProxies)
9776
diff --git a/src/provisioningserver/rackdservices/tests/test_image_download_service.py b/src/provisioningserver/rackdservices/tests/test_image_download_service.py
index e4e2462..63254a1 100644
--- a/src/provisioningserver/rackdservices/tests/test_image_download_service.py
+++ b/src/provisioningserver/rackdservices/tests/test_image_download_service.py
@@ -1,24 +1,22 @@
1# Copyright 2014-2016 Canonical Ltd. This software is licensed under the1# Copyright 2014-2021 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Tests for provisioningserver.rackdservices.image_download_service"""4"""Tests for provisioningserver.rackdservices.image_download_service"""
55
66
7from datetime import timedelta7from datetime import timedelta
8from unittest.mock import call, Mock, sentinel8from unittest.mock import Mock, sentinel
9from urllib.parse import urlparse9from urllib.parse import urlparse
1010
11from fixtures import FakeLogger11from fixtures import FakeLogger
12from twisted.application.internet import TimerService12from twisted.application.internet import TimerService
13from twisted.internet import defer13from twisted.internet import defer
14from twisted.internet.task import Clock14from twisted.internet.task import Clock
15from twisted.protocols.amp import UnhandledCommand
1615
17from maastesting.factory import factory16from maastesting.factory import factory
18from maastesting.matchers import (17from maastesting.matchers import (
19 get_mock_calls,18 get_mock_calls,
20 MockCalledOnceWith,19 MockCalledOnceWith,
21 MockCallsMatch,
22 MockNotCalled,20 MockNotCalled,
23)21)
24from maastesting.testcase import MAASTestCase, MAASTwistedRunTest22from maastesting.testcase import MAASTestCase, MAASTwistedRunTest
@@ -30,7 +28,6 @@ from provisioningserver.rackdservices.image_download_service import (
30from provisioningserver.rpc import boot_images28from provisioningserver.rpc import boot_images
31from provisioningserver.rpc.boot_images import _run_import29from provisioningserver.rpc.boot_images import _run_import
32from provisioningserver.rpc.exceptions import NoConnectionsAvailable30from provisioningserver.rpc.exceptions import NoConnectionsAvailable
33from provisioningserver.rpc.region import GetBootSources, GetBootSourcesV2
3431
3532
36class TestPeriodicImageDownloadService(MAASTestCase):33class TestPeriodicImageDownloadService(MAASTestCase):
@@ -196,83 +193,3 @@ class TestPeriodicImageDownloadService(MAASTestCase):
196 """,193 """,
197 logger.output,194 logger.output,
198 )195 )
199
200
201class TestGetBootSources(MAASTestCase):
202
203 run_tests_with = MAASTwistedRunTest.make_factory(timeout=5)
204
205 @defer.inlineCallbacks
206 def test_get_boot_sources_calls_get_boot_sources_v2_before_v1(self):
207 clock = Clock()
208 client_call = Mock()
209 client_call.side_effect = [
210 defer.succeed(dict(sources=sentinel.sources))
211 ]
212 client_call.localIdent = factory.make_UUID()
213
214 service = ImageDownloadService(sentinel.rpc, sentinel.tftp_root, clock)
215 sources = yield service._get_boot_sources(client_call)
216 self.assertEqual(sources.get("sources"), sentinel.sources)
217 self.assertThat(
218 client_call,
219 MockCalledOnceWith(GetBootSourcesV2, uuid=client_call.localIdent),
220 )
221
222 @defer.inlineCallbacks
223 def test_get_boot_sources_calls_get_boot_sources_v1_on_v2_missing(self):
224 clock = Clock()
225 client_call = Mock()
226 client_call.side_effect = [
227 defer.fail(UnhandledCommand()),
228 defer.succeed(dict(sources=[])),
229 ]
230 client_call.localIdent = factory.make_UUID()
231
232 service = ImageDownloadService(sentinel.rpc, sentinel.tftp_root, clock)
233 yield service._get_boot_sources(client_call)
234 self.assertThat(
235 client_call,
236 MockCallsMatch(
237 call(GetBootSourcesV2, uuid=client_call.localIdent),
238 call(GetBootSources, uuid=client_call.localIdent),
239 ),
240 )
241
242 @defer.inlineCallbacks
243 def test_get_boot_sources_v1_sets_os_to_wildcard(self):
244 sources = [
245 {
246 "path": factory.make_url(),
247 "selections": [
248 {
249 "release": "trusty",
250 "arches": ["amd64"],
251 "subarches": ["generic"],
252 "labels": ["release"],
253 },
254 {
255 "release": "precise",
256 "arches": ["amd64"],
257 "subarches": ["generic"],
258 "labels": ["release"],
259 },
260 ],
261 }
262 ]
263
264 clock = Clock()
265 client_call = Mock()
266 client_call.side_effect = [
267 defer.fail(UnhandledCommand()),
268 defer.succeed(dict(sources=sources)),
269 ]
270
271 service = ImageDownloadService(sentinel.rpc, sentinel.tftp_root, clock)
272 sources = yield service._get_boot_sources(client_call)
273 os_selections = [
274 selection.get("os")
275 for source in sources["sources"]
276 for selection in source["selections"]
277 ]
278 self.assertEqual(["*", "*"], os_selections)
diff --git a/src/provisioningserver/rpc/region.py b/src/provisioningserver/rpc/region.py
index 6c1a741..990632a 100644
--- a/src/provisioningserver/rpc/region.py
+++ b/src/provisioningserver/rpc/region.py
@@ -1,4 +1,4 @@
1# Copyright 2014-2016 Canonical Ltd. This software is licensed under the1# Copyright 2014-2021 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""RPC declarations for the region.4"""RPC declarations for the region.
@@ -13,7 +13,6 @@ __all__ = [
13 "GetArchiveMirrors",13 "GetArchiveMirrors",
14 "GetBootConfig",14 "GetBootConfig",
15 "GetBootSources",15 "GetBootSources",
16 "GetBootSourcesV2",
17 "GetControllerType",16 "GetControllerType",
18 "GetDiscoveryState",17 "GetDiscoveryState",
19 "GetDNSConfiguration",18 "GetDNSConfiguration",
@@ -162,42 +161,6 @@ class GetBootConfig(amp.Command):
162class GetBootSources(amp.Command):161class GetBootSources(amp.Command):
163 """Report boot sources and selections for the given cluster.162 """Report boot sources and selections for the given cluster.
164163
165 :since: 1.6
166 :deprecated: 1.7
167 """
168
169 arguments = [
170 # The cluster UUID.
171 (b"uuid", amp.Unicode())
172 ]
173 response = [
174 (
175 b"sources",
176 AmpList(
177 [
178 (b"url", amp.Unicode()),
179 (b"keyring_data", Bytes()),
180 (
181 b"selections",
182 AmpList(
183 [
184 (b"release", amp.Unicode()),
185 (b"arches", amp.ListOf(amp.Unicode())),
186 (b"subarches", amp.ListOf(amp.Unicode())),
187 (b"labels", amp.ListOf(amp.Unicode())),
188 ]
189 ),
190 ),
191 ]
192 ),
193 )
194 ]
195 errors = []
196
197
198class GetBootSourcesV2(amp.Command):
199 """Report boot sources and selections for the given cluster.
200
201 Includes the new os field for the selections.164 Includes the new os field for the selections.
202165
203 :since: 1.7166 :since: 1.7

Subscribers

People subscribed via source and target branches