Merge lp:~julian-edwards/maas/mipf-celery-job into lp:maas/trunk

Proposed by Julian Edwards on 2012-10-23
Status: Merged
Approved by: Julian Edwards on 2012-10-23
Approved revision: 1290
Merged at revision: 1290
Proposed branch: lp:~julian-edwards/maas/mipf-celery-job
Merge into: lp:maas/trunk
Diff against target: 61 lines (+25/-0)
2 files modified
src/provisioningserver/tasks.py (+14/-0)
src/provisioningserver/tests/test_tasks.py (+11/-0)
To merge this branch: bzr merge lp:~julian-edwards/maas/mipf-celery-job
Reviewer Review Type Date Requested Status
Gavin Panella (community) 2012-10-23 Approve on 2012-10-23
Review via email: mp+130948@code.launchpad.net

Commit message

Add a celery task wrapper around maas-import-pxe-files so that future revisions can call this script in the cluster controller.

To post a comment you must log in.
Gavin Panella (allenap) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/provisioningserver/tasks.py'
2--- src/provisioningserver/tasks.py 2012-10-11 13:25:43 +0000
3+++ src/provisioningserver/tasks.py 2012-10-23 08:35:28 +0000
4@@ -347,6 +347,11 @@
5 UPDATE_NODE_TAGS_RETRY_DELAY = 2
6
7
8+# =====================================================================
9+# Tags-related tasks
10+# =====================================================================
11+
12+
13 @task(max_retries=UPDATE_NODE_TAGS_MAX_RETRY)
14 def update_node_tags(tag_name, tag_definition, retry=True):
15 """Update the nodes for a new/changed tag definition.
16@@ -363,3 +368,12 @@
17 exc=exc, countdown=UPDATE_NODE_TAGS_RETRY_DELAY)
18 else:
19 raise
20+
21+
22+# =====================================================================
23+# Image importing-related tasks
24+# =====================================================================
25+
26+@task
27+def import_pxe_files():
28+ check_call(['maas-import-pxe-files'])
29
30=== modified file 'src/provisioningserver/tests/test_tasks.py'
31--- src/provisioningserver/tests/test_tasks.py 2012-10-08 08:24:11 +0000
32+++ src/provisioningserver/tests/test_tasks.py 2012-10-23 08:35:28 +0000
33@@ -24,6 +24,7 @@
34 from apiclient.creds import convert_tuple_to_string
35 from apiclient.maas_client import MAASClient
36 from apiclient.testing.credentials import make_api_credentials
37+from celery.task import Task
38 from celery.app import app_or_default
39 from maastesting.celery import CeleryFixture
40 from maastesting.factory import factory
41@@ -59,6 +60,7 @@
42 from provisioningserver.tags import MissingCredentials
43 from provisioningserver.tasks import (
44 add_new_dhcp_host_map,
45+ import_pxe_files,
46 Omshell,
47 power_off,
48 power_on,
49@@ -534,3 +536,12 @@
50 self.assertRaises(
51 MissingCredentials, update_node_tags.delay, tag,
52 '//node', retry=True)
53+
54+
55+class TestImportPxeFiles(PservTestCase):
56+
57+ def test_import_pxe_files(self):
58+ recorder = self.patch(tasks, 'check_call', Mock())
59+ import_pxe_files()
60+ recorder.assert_called_once_with(['maas-import-pxe-files'])
61+ self.assertIsInstance(import_pxe_files, Task)