ede2ec4045bca7ea5d211a0c4572fae7f37566c5
[packages/precise/mcollective.git] / plugins / mcollective / agent / discovery.rb
1 module MCollective
2   module Agent
3     # Discovery agent for The Marionette Collective
4     #
5     # Released under the Apache License, Version 2
6     class Discovery
7       attr_reader :timeout, :meta
8
9       def initialize
10         config = Config.instance.pluginconf
11
12         @timeout = 5
13         @timeout = config["discovery.timeout"].to_i if config.include?("discovery.timeout")
14
15         @meta = {:license => "Apache License, Version 2",
16                  :author => "R.I.Pienaar <rip@devco.net>",
17                  :timeout => @timeout,
18                  :name => "Discovery Agent",
19                  :version => MCollective.version,
20                  :url => "http://www.marionette-collective.org",
21                  :description => "MCollective Discovery Agent"}
22       end
23
24       def handlemsg(msg, stomp)
25         reply = "unknown request"
26
27         case msg[:body]
28           when "ping"
29             reply = "pong"
30
31           else
32             reply = "Unknown Request: #{msg[:body]}"
33         end
34
35         reply
36       end
37     end
38   end
39 end