Class MCollective::RPC::Agent
In: lib/mcollective/rpc/agent.rb
Parent: Object

A wrapper around the traditional agent, it takes care of a lot of the tedious setup you would do for each agent allowing you to just create methods following a naming standard leaving the heavy lifting up to this clas.

See docs.puppetlabs.com/mcollective/simplerpc/agents.html

It only really makes sense to use this with a Simple RPC client on the other end, basic usage would be:

   module MCollective
     module Agent
       class Helloworld<RPC::Agent
         action "hello" do
           reply[:msg] = "Hello #{request[:name]}"
         end

         action "foo" do
           implemented_by "/some/script.sh"
         end
       end
     end
   end

If you wish to implement the logic for an action using an external script use the implemented_by method that will cause your script to be run with 2 arguments.

The first argument is a file containing JSON with the request and the 2nd argument is where the script should save its output as a JSON hash.

We also currently have the validation code in here, this will be moved to plugins soon.

Methods

actions   activate?   handlemsg   load_ddl   new  

Attributes

agent_name  [RW] 
config  [R] 
ddl  [R] 
logger  [R] 
meta  [R] 
reply  [RW] 
request  [RW] 
timeout  [R] 

Public Class methods

Returns an array of actions this agent support

By default RPC Agents support a toggle in the configuration that can enable and disable them based on the agent name

Example an agent called Foo can have:

plugin.foo.activate_agent = false

and this will prevent the agent from loading on this particular machine.

Agents can use the activate_when helper to override this for example:

activate_when do

   File.exist?("/usr/bin/puppet")

end

Public Instance methods

[Validate]