apps/servant/lib/servant.rb in spiderfw-0.5.13 vs apps/servant/lib/servant.rb in spiderfw-0.5.14
- old
+ new
@@ -15,11 +15,11 @@
:config_file => '/etc/spider/servant.yml'
}
def initialize(config_file=nil)
@config = {
- :server_url => 'http://localhost:8989/spider/master/ping'
+ :server_url => 'http://localhost:8989/spider/master'
}
config_file ||= Servant::DEFAULTS[:config_file] if File.exists?(Servant::DEFAULTS[:config_file])
if config_file
y = YAML::load_file(config_file)
@config.merge!(y)
@@ -32,13 +32,19 @@
create_resources
end
def ping_server(url=nil)
url ||= @config[:server_url]
-
@system_status = @ohai.to_json
clnt = HTTPClient.new
- clnt.post(url, Spider::HTTP.params_to_hash(self.description))
+ res = clnt.post("#{url}/ping", Spider::HTTP.params_to_hash(self.description))
+ JSON.parse(res)
+ if res[:commands]
+ res[:commands].each do |command|
+ command_result = execute_command(command[:name], command[:arguments])
+ clnt.post()
+ end
+ end
end
def create_resources
@resources = {}
return unless @config['resources'].is_a?(Hash)
\ No newline at end of file