Commit 025b59ff authored by John E. Vincent's avatar John E. Vincent

Adding a RunDeck agent

parent 71a5b6fd
......@@ -4,6 +4,7 @@ require 'noah'
require 'noah/agents/http_agent'
require 'noah/agents/https_agent'
require 'noah/agents/dummy_agent'
require 'noah/agents/rundeck_agent'
begin
candidates = []
Gem.source_index.find_all {|g| candidates << g[1].name if g[1].name =~ /^noah-agents-.*/}
......
require File.join(File.dirname(__FILE__), 'base_agent')
require 'em-http/middleware/cookie_jar'
require 'uri'
module Noah::Agents
class RunDeckAgent < Base
PREFIX = "rundeck://"
NAME = self.class.to_s
DEFAULT_CONCURRENCY = 50
def work!(ep, message)
logger.info("Sending message to (#{ep})")
uri = URI.parse(ep)
credentials = {:j_username => uri.user, :j_password => uri.password}
EM::HttpRequest.use EM::Middleware::CookieJar
conn = EM::HttpRequest.new("http://#{uri.host}:#{uri.port}/j_security_check")
http = conn.post :body => credentials
http.callback {
logger.info("Logged in to RunDeck. Calling path")
conn2 = EM::HttpRequest.new("http://#{uri.host}:#{uri.port}#{uri.path}?#{uri.query}")
exec = conn2.get
exec.callback {
logger.info("Successfully called #{ep}")
logger.info("Response from RunDeck:")
logger.info("#{exec.response}")
}
exec.errback {
logger.error("Something went wrong with #{ep}")
}
}
http.errback {
logger.error("Something went wrong with #{ep}")
}
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment