1 A simple helper to assist with writing MCollective actions in Python.
3 Given an action as below:
7 validate :message, String
9 implemented_by "/tmp/echo.py"
13 The following Python script will implement the echo action externally
14 replying with _message_ and current _time_.
21 import mcollective_action as mc
23 if __name__ == '__main__':
24 mc = mc.MCollectiveAction()
25 request = mc.request()
26 mc.message = request['data']['message']
27 mc.time = time.strftime('%c')
28 mc.info("Some text to info log in the server")
33 Calling it with _mco rpc_ results in:
36 $ mco rpc test echo message="Hello World"
37 Determining the amount of hosts matching filter for 2 seconds .... 1
39 * [ ============================================================> ] 1 / 1
43 {:message=>"Hello World", :time=>"Tue Mar 15 19:20:53 +0000 2011"}
46 This implementation was successfully tested with Python 2.4 and 2.6.