Merge lp:~blake-rouse/maas/is-importing-2.1 into lp:maas/2.1

Proposed by Blake Rouse
Status: Merged
Approved by: Blake Rouse
Approved revision: no longer in the source branch.
Merged at revision: 5567
Proposed branch: lp:~blake-rouse/maas/is-importing-2.1
Merge into: lp:maas/2.1
Diff against target: 43 lines (+16/-0)
2 files modified
src/maasserver/api/boot_resources.py (+6/-0)
src/maasserver/api/tests/test_boot_resources.py (+10/-0)
To merge this branch: bzr merge lp:~blake-rouse/maas/is-importing-2.1
Reviewer Review Type Date Requested Status
Mike Pontillo (community) Approve
Review via email: mp+312885@code.launchpad.net

Commit message

Backport r5591: Add is_importing call to boot resources API.

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

LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/maasserver/api/boot_resources.py'
--- src/maasserver/api/boot_resources.py 2016-09-29 16:53:21 +0000
+++ src/maasserver/api/boot_resources.py 2016-12-09 07:43:17 +0000
@@ -25,6 +25,7 @@
25from maasserver.api.utils import get_optional_param25from maasserver.api.utils import get_optional_param
26from maasserver.bootresources import (26from maasserver.bootresources import (
27 import_resources,27 import_resources,
28 is_import_resources_running,
28 stop_import_resources,29 stop_import_resources,
29)30)
30from maasserver.enum import (31from maasserver.enum import (
@@ -236,6 +237,11 @@
236 "Import of boot resources is being stopped",237 "Import of boot resources is being stopped",
237 content_type=("text/plain; charset=%s" % settings.DEFAULT_CHARSET))238 content_type=("text/plain; charset=%s" % settings.DEFAULT_CHARSET))
238239
240 @operation(idempotent=True)
241 def is_importing(self, request):
242 """Return import status."""
243 return is_import_resources_running()
244
239 @classmethod245 @classmethod
240 def resource_uri(cls, *args, **kwargs):246 def resource_uri(cls, *args, **kwargs):
241 return ('boot_resources_handler', [])247 return ('boot_resources_handler', [])
242248
=== modified file 'src/maasserver/api/tests/test_boot_resources.py'
--- src/maasserver/api/tests/test_boot_resources.py 2016-09-29 16:53:21 +0000
+++ src/maasserver/api/tests/test_boot_resources.py 2016-12-09 07:43:17 +0000
@@ -404,6 +404,16 @@
404 self.assertEqual(http.client.OK, response.status_code)404 self.assertEqual(http.client.OK, response.status_code)
405 self.assertThat(mock_stop, MockCalledOnceWith())405 self.assertThat(mock_stop, MockCalledOnceWith())
406406
407 def test_is_importing_returns_import_status(self):
408 mock_running = self.patch(
409 boot_resources, "is_import_resources_running")
410 mock_running.return_value = factory.pick_bool()
411 response = self.client.get(
412 reverse('boot_resources_handler'), {'op': 'is_importing'})
413 self.assertEqual(http.client.OK, response.status_code)
414 self.assertEqual(
415 mock_running.return_value, json_load_bytes(response.content))
416
407417
408class TestBootResourceAPI(APITestCase.ForUser):418class TestBootResourceAPI(APITestCase.ForUser):
409419

Subscribers

People subscribed via source and target branches

to all changes: