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

Proposed by Julian Edwards
Status: Merged
Approved by: Julian Edwards
Approved revision: no longer in the source branch.
Merged at revision: 1290
Proposed branch: lp:~julian-edwards/maas/mipf-celery-job
Merge into: lp:~maas-committers/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) Approve
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.
Revision history for this message
Gavin Panella (allenap) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/provisioningserver/tasks.py'
--- src/provisioningserver/tasks.py 2012-10-11 13:25:43 +0000
+++ src/provisioningserver/tasks.py 2012-10-23 08:35:28 +0000
@@ -347,6 +347,11 @@
347UPDATE_NODE_TAGS_RETRY_DELAY = 2347UPDATE_NODE_TAGS_RETRY_DELAY = 2
348348
349349
350# =====================================================================
351# Tags-related tasks
352# =====================================================================
353
354
350@task(max_retries=UPDATE_NODE_TAGS_MAX_RETRY)355@task(max_retries=UPDATE_NODE_TAGS_MAX_RETRY)
351def update_node_tags(tag_name, tag_definition, retry=True):356def update_node_tags(tag_name, tag_definition, retry=True):
352 """Update the nodes for a new/changed tag definition.357 """Update the nodes for a new/changed tag definition.
@@ -363,3 +368,12 @@
363 exc=exc, countdown=UPDATE_NODE_TAGS_RETRY_DELAY)368 exc=exc, countdown=UPDATE_NODE_TAGS_RETRY_DELAY)
364 else:369 else:
365 raise370 raise
371
372
373# =====================================================================
374# Image importing-related tasks
375# =====================================================================
376
377@task
378def import_pxe_files():
379 check_call(['maas-import-pxe-files'])
366380
=== modified file 'src/provisioningserver/tests/test_tasks.py'
--- src/provisioningserver/tests/test_tasks.py 2012-10-08 08:24:11 +0000
+++ src/provisioningserver/tests/test_tasks.py 2012-10-23 08:35:28 +0000
@@ -24,6 +24,7 @@
24from apiclient.creds import convert_tuple_to_string24from apiclient.creds import convert_tuple_to_string
25from apiclient.maas_client import MAASClient25from apiclient.maas_client import MAASClient
26from apiclient.testing.credentials import make_api_credentials26from apiclient.testing.credentials import make_api_credentials
27from celery.task import Task
27from celery.app import app_or_default28from celery.app import app_or_default
28from maastesting.celery import CeleryFixture29from maastesting.celery import CeleryFixture
29from maastesting.factory import factory30from maastesting.factory import factory
@@ -59,6 +60,7 @@
59from provisioningserver.tags import MissingCredentials60from provisioningserver.tags import MissingCredentials
60from provisioningserver.tasks import (61from provisioningserver.tasks import (
61 add_new_dhcp_host_map,62 add_new_dhcp_host_map,
63 import_pxe_files,
62 Omshell,64 Omshell,
63 power_off,65 power_off,
64 power_on,66 power_on,
@@ -534,3 +536,12 @@
534 self.assertRaises(536 self.assertRaises(
535 MissingCredentials, update_node_tags.delay, tag,537 MissingCredentials, update_node_tags.delay, tag,
536 '//node', retry=True)538 '//node', retry=True)
539
540
541class TestImportPxeFiles(PservTestCase):
542
543 def test_import_pxe_files(self):
544 recorder = self.patch(tasks, 'check_call', Mock())
545 import_pxe_files()
546 recorder.assert_called_once_with(['maas-import-pxe-files'])
547 self.assertIsInstance(import_pxe_files, Task)