Skip to content

Instantly share code, notes, and snippets.

@xcu
Created May 22, 2014 13:27
Show Gist options
  • Save xcu/509525c9e87e3ae5e180 to your computer and use it in GitHub Desktop.
Save xcu/509525c9e87e3ae5e180 to your computer and use it in GitHub Desktop.
Sample agent
metadata :name => "exampleagent",
:description => "Example agent that serves as an example",
:author => "Julio Iglesias",
:license => "Ericcson",
:version => "1.0",
:url => "http://badgerbadgerbadger.com",
:timeout => 10
action "serve_as_example", :description => "Be an illustration how to create an agent" do
display :always
input :echo_string,
:prompt => "String to echo",
:description => "String to echo",
:type => :string,
:validation => '^.+$',
:optional => false,
:maxlength => 300
output :status,
:description => "The output of the command",
:display_as => "Command result",
:default => "no output"
summarize do
aggregate summary(:status)
end
end
module MCollective
module Agent
class Exampleagent<RPC::Agent
# Basic echo example
action "serve_as_example" do
cmd = "echo \"#{request[:echo_string]}\" "
reply[:status] = run("#{cmd}",
:stdout => :out,
:stderr => :err,
:chomp => true)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment