~ubuntu-branches/ubuntu/oneiric/mcollective/oneiric-proposed

« back to all changes in this revision

Viewing changes to ext/action_helpers/python/romke/README.markdown

  • Committer: Bazaar Package Importer
  • Author(s): Marc Cluet, Marc Cluet, Chuck Short
  • Date: 2011-05-05 07:37:54 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110505073754-klk1jkz8afi4fomx
Tags: 1.2.0-0ubuntu1
[Marc Cluet]
* Update to 1.2.0
* Build for Oneiric.

[Chuck Short]
* Drop ruby from mcollective, mcollective-middleware, mcollective-client
  since its a dependency of mcollective-common.
* Bump standards to 3.9.2.
* Fix up lintian warnings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
A simple helper to assist with writing MCollective actions in Python.
 
2
 
 
3
Given an action as below:
 
4
 
 
5
<pre>
 
6
action "echo" do
 
7
   validate :message, String
 
8
 
 
9
   implemented_by "/tmp/echo.py"
 
10
end
 
11
</pre>
 
12
 
 
13
The following Python script will implement the echo action externally
 
14
replying with _message_ and _timestamp_
 
15
 
 
16
<pre>
 
17
#!/bin/env python
 
18
import mcollectiveah
 
19
import time
 
20
 
 
21
mc = mcollectiveah.MCollectiveAction()
 
22
mc.reply['message'] = mc.request['message']
 
23
mc.reply['timestamp'] = time.strftime("%c")
 
24
mc.reply['info'] = "some text to info log in the server"
 
25
</pre>
 
26
 
 
27
Calling it with _mco rpc_ results in:
 
28
 
 
29
<pre>
 
30
$ mco rpc test echo message="hello world"
 
31
Determining the amount of hosts matching filter for 2 seconds .... 1
 
32
 
 
33
 * [ ============================================================> ] 1 / 1
 
34
 
 
35
 
 
36
nephilim.ml.org                         : OK
 
37
    {:message=>"hello world", :time=>"Tue Mar 15 19:20:53 +0000 2011"}
 
38
</pre>