diff mbox

[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
State Accepted
Headers show

Commit Message

Paul Larson Nov. 17, 2011, 5:34 p.m. UTC
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 <paul.larson@canonical.com>
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
diff mbox

Patch

=== 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 <paul.larson@linaro.org>
+#
+# 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 <http://www.gnu.org/licenses>.
+
+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