Ask Your Question
0

Executing python script using Mcollective

asked 2014-09-12 14:57:54 -0500

oracle_mcollective gravatar image

All,

I have a demo MCollective environment ( https://github.com/ripienaar/mcollect... ) on which I am trying to create an agent plugin that runs a simple python script:

#!/usr/bin/python
print "Hello, World!"

Here is the plugin code:

module MCollective
  module Agent
    class Testpy<RPC::Agent
      # Basic echo server
      action "echo" do
        implemented_by "testpy.py"
      end
    end
  end
end

and the DDL (which is same as the helloworld plugin from puppetlabs)

metadata :name        => "echo",

         :description => "Echo service for MCollective",

         :author      => "R.I.Pienaar",

         :license     => "GPLv2",

         :version     => "1.1",

         :url         => "http://projects.puppetlabs.com/projects/mcollective-pl
ugins/wiki",
         :timeout     => 60



action "echo", :description => "Echos back any message it receives" do

   input :msg,

         :prompt      => "Service Name",

         :description => "The service to get the status for",

         :type        => :string,

         :validation  => '^[a-zA-Z\-_\d]+$',

         :optional    => false,

         :maxlength   => 30



   output :msg,

          :description => "The message we received",

          :display_as  => "Message"

end

However, I get the below error when running the plugin

[vagrant@middleware vagrant]$ mco rpc -v --display=all testpy echo msg="hellowo
rld"
Discovering hosts using the redis method .... 1

 * [ ==========================================================> ] 1 / 1


middleware.example.net                  : Unexpected failure calling testpy.py:
MCollective::RPCAborted: Cannot execute testpy#echo command: testpy.py
    {:msg=>nil}



---- testpy#echo call stats ----
           Nodes: 1 / 1
     Pass / Fail: 0 / 1
      Start Time: Fri Sep 12 19:47:15 +0000 2014
  Discovery Time: 4.15ms
      Agent Time: 10.63ms
      Total Time: 14.78ms

Can you please help? If the above method is not the right/best one to run a python script using mcollecitve, please suggest me one. Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-10-13 08:45:09 -0500

pers gravatar image

run this chmod +x test.py

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-09-12 14:57:54 -0500

Seen: 474 times

Last updated: Sep 12 '14