Class: Noah::Agents::RunDeckAgent

Inherits:
Base
  • Object
show all
Defined in:
lib/noah/agents/rundeck_agent.rb

Constant Summary collapse

PREFIX =
"rundeck://"
NAME =
self.class.to_s
DEFAULT_CONCURRENCY =
50

Constants inherited from Base

Base::NEEDS_TRANSFORM

Instance Method Summary collapse

Methods inherited from Base

inherited, #logger, #notify

Instance Method Details

#work!(ep, message) ⇒ Object


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/noah/agents/rundeck_agent.rb', line 12

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