From patchwork Thu Jul 7 09:59:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael-Doyle Hudson X-Patchwork-Id: 2517 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id DCCD624135 for ; Thu, 7 Jul 2011 09:59:16 +0000 (UTC) Received: from mail-qy0-f180.google.com (mail-qy0-f180.google.com [209.85.216.180]) by fiordland.canonical.com (Postfix) with ESMTP id 95934A182BC for ; Thu, 7 Jul 2011 09:59:16 +0000 (UTC) Received: by qyk30 with SMTP id 30so542311qyk.11 for ; Thu, 07 Jul 2011 02:59:16 -0700 (PDT) Received: by 10.229.102.98 with SMTP id f34mr451640qco.42.1310032756043; Thu, 07 Jul 2011 02:59:16 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.48.135 with SMTP id r7cs103916qcf; Thu, 7 Jul 2011 02:59:15 -0700 (PDT) Received: by 10.217.3.80 with SMTP id q58mr517810wes.53.1310032753858; Thu, 07 Jul 2011 02:59:13 -0700 (PDT) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id q46si12633767wec.131.2011.07.07.02.59.13; Thu, 07 Jul 2011 02:59:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) client-ip=91.189.90.139; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) smtp.mail=bounces@canonical.com Received: from loganberry.canonical.com ([91.189.90.37]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1QelMX-0001YU-3m for ; Thu, 07 Jul 2011 09:59:13 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 1A2492E84FB for ; Thu, 7 Jul 2011 09:59:13 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-scheduler X-Launchpad-Branch: ~linaro-validation/lava-scheduler/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 15 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-scheduler/trunk] Rev 15: convert to a twistd plugin Message-Id: <20110707095913.31225.38206.launchpad@loganberry.canonical.com> Date: Thu, 07 Jul 2011 09:59:13 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13376"; Instance="initZopeless config overlay" X-Launchpad-Hash: 1c27a530a0782a9d6976ecffa74dd56419336f16 ------------------------------------------------------------ revno: 15 committer: Michael-Doyle Hudson branch nick: trunk timestamp: Thu 2011-07-07 16:09:01 +1200 message: convert to a twistd plugin added: twisted/ twisted/plugins/ renamed: lava-scheduler-daemon.tac => twisted/plugins/twisted_lava_scheduler_daemon.py modified: .bzrignore twisted/plugins/twisted_lava_scheduler_daemon.py --- lp:lava-scheduler https://code.launchpad.net/~linaro-validation/lava-scheduler/trunk You are subscribed to branch lp:lava-scheduler. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-scheduler/trunk/+edit-subscription === modified file '.bzrignore' --- .bzrignore 2011-06-21 00:58:19 +0000 +++ .bzrignore 2011-07-07 04:09:01 +0000 @@ -1,3 +1,4 @@ *.egg-info ./twistd.pid ./_trial_temp +./twisted/plugins/dropin.cache === added directory 'twisted' === added directory 'twisted/plugins' === renamed file 'lava-scheduler-daemon.tac' => 'twisted/plugins/twisted_lava_scheduler_daemon.py' --- lava-scheduler-daemon.tac 2011-06-21 03:29:46 +0000 +++ twisted/plugins/twisted_lava_scheduler_daemon.py 2011-07-07 04:09:01 +0000 @@ -1,26 +1,32 @@ -import logging import os -import sys - -from twisted.application import service -from twisted.application import internet -from twisted.python import filepath -from twisted.internet import reactor + +from twisted.python import usage +from twisted.plugin import IPlugin +from twisted.application.service import IServiceMaker + +from zope.interface import implements from lava_scheduler_daemon.service import BoardSet -os.environ['DJANGO_SETTINGS_MODULE'] = 'lava_server.settings.development' -from lava_scheduler_daemon.dbjobsource import DatabaseJobSource - -application = service.Application("lava scheduler daemon") - - -#source = DirectoryJobSource(filepath.FilePath('/tmp/lava-jobs')) -source = DatabaseJobSource() -board_set = BoardSet(source, 'fake-dispatcher', reactor) -board_set.setServiceParent(application) - -logger = logging.getLogger('') -handler = logging.StreamHandler(sys.stdout) -handler.setFormatter(logging.Formatter("[%(name)s] %(message)s")) -logger.addHandler(handler) -logger.setLevel(logging.DEBUG) + +class MyServiceMaker(object): + implements(IServiceMaker, IPlugin) + tapname = "lava-scheduler-daemon" + description = "Run the LAVA Scheduler Daemon" + options = usage.Options + + def makeService(self, options): + """ + Construct a TCPServer from a factory defined in myproject. + """ + os.environ['DJANGO_SETTINGS_MODULE'] = 'lava_server.settings.development' + from lava_scheduler_daemon.dbjobsource import DatabaseJobSource + from twisted.internet import reactor + source = DatabaseJobSource() + return BoardSet(source, 'lava-dispatch', reactor) + + +# Now construct an object which *provides* the relevant interfaces +# The name of this variable is irrelevant, as long as there is *some* +# name bound to a provider of IPlugin and IServiceMaker. + +serviceMaker = MyServiceMaker()