From patchwork Thu Nov 17 17:34:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Larson X-Patchwork-Id: 5186 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 BC50A23E0E for ; Thu, 17 Nov 2011 17:34:18 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id AE21FA18608 for ; Thu, 17 Nov 2011 17:34:18 +0000 (UTC) Received: by mail-fx0-f52.google.com with SMTP id a26so5694008faa.11 for ; Thu, 17 Nov 2011 09:34:18 -0800 (PST) Received: by 10.152.104.1 with SMTP id ga1mr23781603lab.40.1321551258407; Thu, 17 Nov 2011 09:34:18 -0800 (PST) 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.152.41.198 with SMTP id h6cs145711lal; Thu, 17 Nov 2011 09:34:18 -0800 (PST) Received: by 10.180.4.37 with SMTP id h5mr42976689wih.45.1321551256180; Thu, 17 Nov 2011 09:34:16 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id fa7si4712618wib.8.2011.11.17.09.34.15 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 17 Nov 2011 09:34:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1RR5qp-00036P-Kf for ; Thu, 17 Nov 2011 17:34:15 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 93D8BE017C for ; Thu, 17 Nov 2011 17:34:15 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-dispatcher X-Launchpad-Branch: ~linaro-validation/lava-dispatcher/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 161 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dispatcher/trunk] Rev 161: First pass at adding plugin support for lava actions Message-Id: <20111117173415.29183.45682.launchpad@ackee.canonical.com> Date: Thu, 17 Nov 2011 17:34:15 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="14291"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 87853bb32c2beb035b62ac57d0c336909cf971e2 Merge authors: Paul Larson (pwlars) Related merge proposals: https://code.launchpad.net/~pwlars/lava-dispatcher/action-plugins/+merge/82232 proposed by: Paul Larson (pwlars) ------------------------------------------------------------ revno: 161 [merge] committer: Paul Larson branch nick: lava-dispatcher timestamp: Thu 2011-11-17 11:32:00 -0600 message: First pass at adding plugin support for lava actions added: doc/examples/ doc/examples/plugins/ doc/examples/plugins/demo-action-plugin/ doc/examples/plugins/demo-action-plugin/README doc/examples/plugins/demo-action-plugin/demo-action-plugin.json doc/examples/plugins/demo-action-plugin/demo_action_plugin/ doc/examples/plugins/demo-action-plugin/demo_action_plugin/__init__.py doc/examples/plugins/demo-action-plugin/demo_action_plugin/foo.py doc/examples/plugins/demo-action-plugin/setup.py modified: lava_dispatcher/actions/__init__.py --- lp:lava-dispatcher https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk You are subscribed to branch lp:lava-dispatcher. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription === added directory 'doc/examples' === added directory 'doc/examples/plugins' === added directory 'doc/examples/plugins/demo-action-plugin' === added file 'doc/examples/plugins/demo-action-plugin/README' --- doc/examples/plugins/demo-action-plugin/README 1970-01-01 00:00:00 +0000 +++ doc/examples/plugins/demo-action-plugin/README 2011-11-14 23:09:29 +0000 @@ -0,0 +1,4 @@ +This is a simple example of how to write a plugin action for LAVA +Dispatcher. You will need to install both lava-dispatcher and +demo-action-plugin for it to work. The json file provided here will run +the action and exit. === added file 'doc/examples/plugins/demo-action-plugin/demo-action-plugin.json' --- doc/examples/plugins/demo-action-plugin/demo-action-plugin.json 1970-01-01 00:00:00 +0000 +++ doc/examples/plugins/demo-action-plugin/demo-action-plugin.json 2011-11-14 23:09:29 +0000 @@ -0,0 +1,10 @@ +{ + "job_name": "foo", + "target": "panda01", + "timeout": 18000, + "actions": [ + { + "command": "foo" + } + ] +} === added directory 'doc/examples/plugins/demo-action-plugin/demo_action_plugin' === added file 'doc/examples/plugins/demo-action-plugin/demo_action_plugin/__init__.py' === added file 'doc/examples/plugins/demo-action-plugin/demo_action_plugin/foo.py' --- doc/examples/plugins/demo-action-plugin/demo_action_plugin/foo.py 1970-01-01 00:00:00 +0000 +++ doc/examples/plugins/demo-action-plugin/demo_action_plugin/foo.py 2011-11-14 23:09:29 +0000 @@ -0,0 +1,29 @@ +#!/usr/bin/python + +# Copyright (C) 2011 Linaro Limited +# +# Author: Paul Larson +# +# This file is part of LAVA Dispatcher. +# +# LAVA Dispatcher is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# LAVA Dispatcher is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along +# with this program; if not, see . + +from lava_dispatcher.actions import BaseAction + +class cmd_foo(BaseAction): + def run(self): + """ do something """ + print("Hello from demo-action-plugin") + === added file 'doc/examples/plugins/demo-action-plugin/setup.py' --- doc/examples/plugins/demo-action-plugin/setup.py 1970-01-01 00:00:00 +0000 +++ doc/examples/plugins/demo-action-plugin/setup.py 2011-11-17 17:32:00 +0000 @@ -0,0 +1,19 @@ +#!/usr/bin/env python + +from setuptools import setup + +setup ( + name='demo-action-plugin', + version='0.0.1', + author='Paul Larson', + author_email='paul.larson@linaro.org', + url='', + description='LAVA Dispatcher plugin test', + packages = ['demo_action_plugin'], + entry_points=""" + [lava_dispatcher.actions] + foo = demo_action_plugin.foo:cmd_foo + """, + zip_safe=False, + include_package_data=True + ) === modified file 'lava_dispatcher/actions/__init__.py' --- lava_dispatcher/actions/__init__.py 2011-10-20 04:36:56 +0000 +++ lava_dispatcher/actions/__init__.py 2011-11-14 23:09:29 +0000 @@ -65,9 +65,13 @@ return cmds def get_all_cmds(): + import pkg_resources cmds = {} cmd_path = os.path.dirname(os.path.realpath(__file__)) for f in glob(os.path.join(cmd_path,"*.py")): module = imp.load_source("module", os.path.join(cmd_path,f)) cmds.update(_find_commands(module)) + for ep in pkg_resources.iter_entry_points(group="lava_dispatcher.actions"): + plugin = ep.load() + cmds[plugin.command_name] = plugin return cmds