Change source structure according to OSCI-991
[packages/precise/mcollective.git] / mcollective-2.3.3 / ext / action_helpers / python / romke / README.markdown
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>