Meego Wiki
Views

Release Infrastructure/BOSS Participant

From MeeGo wiki
(Difference between revisions)
Jump to: navigation, search
(Class definition)
Line 21: Line 21:
==== Participant Naming Convenience ====
==== Participant Naming Convenience ====
The participant's name should give an indication of the function it does, usually in the form noun_verb.py
The participant's name should give an indication of the function it does, usually in the form noun_verb.py
 +
 +
==== Prerequisites ====
 +
You need to install two libraries:
 +
  * AIR: An RPC library used by BOSS
 +
  * route-amqp-pyclient : The Python client library for Ruoute::AMQP
 +
These libraries are open source and the code is published on gitorious :
 +
  * http://meego.gitorious.org/meego-infrastructure-tools/air
 +
  * http://meego.gitorious.org/meego-infrastructure-tools/ruote-amqp-pyclient
 +
 +
They are also packaged for OpenSuse ( and Debian soon ) on OBS https://build.opensuse.org/project/show?project=Maemo%3AMeeGo-Infra
==== Import ====
==== Import ====
 +
Once you have these libraries installed, you need to import them in your participant like this :
<pre>
<pre>
Line 30: Line 41:
==== Class definition ====
==== Class definition ====
 +
The parent class Participant defined in participant.py of the route-amqp-pyclient package takes care of most of the details needed to create a participant.
The parent class Participant defined in participant.py of the route-amqp-pyclient package takes care of most of the details needed to create a participant.
-
You just need to subclass it and define a "consume" member function.
+
You just need to subclass it and define a "consume" member function.
 +
 
 +
The received workitem is stored as an attribute, it contains the information that was passed from previous steps in the workflow. Usually you would read the workitem, do some processing, and then store results in the workitem.
 +
 
 +
That's all there is to it, the parent class will take care of putting the workitem back on the amqp queue.
<pre>
<pre>
-
class NotifierParticipant(Participant):  
+
class NotifierParticipant(Participant):
 +
    def consume(self):
 +
      """
 +
        look at self.workitem
 +
        do some work
 +
        write some results to self.workitem
 +
      """
</pre>
</pre>
==== Registering BOSS Participant to server ====
==== Registering BOSS Participant to server ====
 +
 +
To register your participant you need to have : a queue name, amqp host, and probably usrename and password for amqp authentication.
<pre>
<pre>

Revision as of 07:42, 13 August 2010

Contents

BOSS Participant

BOSS is a workflow orchestrator, a system that can be configured to automate your workflow requirements; it interacts with the OBS and with people and systems around it to apply your workflow steps. For more BOSS related general information, see Infrastructure/BOSS.


What is BOSS Participant

BOSS Participant is the actual actor in BOSS architecture. Participant wraps other systems and services related to software development, quality assurance and integration, allowing BOSS to interact with different parties in automated way.

BOSS Participant action explained in three simple steps:

  • Receive a workitem from BOSS server
  • Process it, interacting with underlying (read: wrapped) system or service
  • Return the filled worksheet back to BOSS server

Participant Coding Guidelines

BOSS participant is written in Python language (other bindings will be available later). Following code snippets are from Notifier Participant (see chapter Example Code).

Participant Naming Convenience

The participant's name should give an indication of the function it does, usually in the form noun_verb.py

Prerequisites

You need to install two libraries:

 * AIR: An RPC library used by BOSS
 * route-amqp-pyclient : The Python client library for Ruoute::AMQP

These libraries are open source and the code is published on gitorious :

 * http://meego.gitorious.org/meego-infrastructure-tools/air
 * http://meego.gitorious.org/meego-infrastructure-tools/ruote-amqp-pyclient

They are also packaged for OpenSuse ( and Debian soon ) on OBS https://build.opensuse.org/project/show?project=Maemo%3AMeeGo-Infra

Import

Once you have these libraries installed, you need to import them in your participant like this :

from  RuoteAMQP.workitem import Workitem
from  RuoteAMQP.participant import Participant

Class definition

The parent class Participant defined in participant.py of the route-amqp-pyclient package takes care of most of the details needed to create a participant. You just need to subclass it and define a "consume" member function.

The received workitem is stored as an attribute, it contains the information that was passed from previous steps in the workflow. Usually you would read the workitem, do some processing, and then store results in the workitem.

That's all there is to it, the parent class will take care of putting the workitem back on the amqp queue.

class NotifierParticipant(Participant):
    def consume(self):
       """ 
         look at self.workitem
         do some work 
         write some results to self.workitem
       """

Registering BOSS Participant to server

To register your participant you need to have : a queue name, amqp host, and probably usrename and password for amqp authentication.

if __name__ == "__main__":
    print "Notifier participant running"
    p = NotifierParticipant(ruote_queue="notifier", amqp_vhost="ruote-test")
    p.register("notifier", {'queue':'notifier'})
    p.run()

Participant Example Code

See following participants for example implementation: [notifier_participant.py] [build_ks_participant.py]

Personal tools