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

Proposed by Blake Rouse on 2016-12-09
Status: Merged
Approved by: Blake Rouse on 2016-12-09
Approved revision: 5566
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) 2016-12-09 Approve on 2016-12-09
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.
Mike Pontillo (mpontillo) wrote :

LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/api/boot_resources.py'
2--- src/maasserver/api/boot_resources.py 2016-09-29 16:53:21 +0000
3+++ src/maasserver/api/boot_resources.py 2016-12-09 07:43:17 +0000
4@@ -25,6 +25,7 @@
5 from maasserver.api.utils import get_optional_param
6 from maasserver.bootresources import (
7 import_resources,
8+ is_import_resources_running,
9 stop_import_resources,
10 )
11 from maasserver.enum import (
12@@ -236,6 +237,11 @@
13 "Import of boot resources is being stopped",
14 content_type=("text/plain; charset=%s" % settings.DEFAULT_CHARSET))
15
16+ @operation(idempotent=True)
17+ def is_importing(self, request):
18+ """Return import status."""
19+ return is_import_resources_running()
20+
21 @classmethod
22 def resource_uri(cls, *args, **kwargs):
23 return ('boot_resources_handler', [])
24
25=== modified file 'src/maasserver/api/tests/test_boot_resources.py'
26--- src/maasserver/api/tests/test_boot_resources.py 2016-09-29 16:53:21 +0000
27+++ src/maasserver/api/tests/test_boot_resources.py 2016-12-09 07:43:17 +0000
28@@ -404,6 +404,16 @@
29 self.assertEqual(http.client.OK, response.status_code)
30 self.assertThat(mock_stop, MockCalledOnceWith())
31
32+ def test_is_importing_returns_import_status(self):
33+ mock_running = self.patch(
34+ boot_resources, "is_import_resources_running")
35+ mock_running.return_value = factory.pick_bool()
36+ response = self.client.get(
37+ reverse('boot_resources_handler'), {'op': 'is_importing'})
38+ self.assertEqual(http.client.OK, response.status_code)
39+ self.assertEqual(
40+ mock_running.return_value, json_load_bytes(response.content))
41+
42
43 class TestBootResourceAPI(APITestCase.ForUser):
44

Subscribers

People subscribed via source and target branches

to all changes: