class Rundeck::Execution
Attributes
args[R]
date_ended[R]
date_started[R]
id[R]
job[R]
session[R]
status[R]
url[R]
user[R]
Public Class Methods
find(session, id)
click to toggle source
# File lib/rundeck-ruby/execution.rb, line 42 def self.find(session, id) result = session.get("api/1/execution/#{id}", *%w(result executions execution)) return nil unless result job = Job.find(session, result['job']['id']) return nil unless job Execution.new(session, result, job) end
from_hash(session, hash)
click to toggle source
# File lib/rundeck-ruby/execution.rb, line 21 def self.from_hash(session, hash) job = Job.from_hash(session, hash['job']) new(session, hash, job) end
new(session, hash, job)
click to toggle source
# File lib/rundeck-ruby/execution.rb, line 26 def initialize(session, hash, job) @id = hash['id'] @url=hash['href'] @url = URI.join(session.server, URI.split(@url)[5]).to_s if @url # They always return a url of "localhost" for their executions. Replace it with the real URL @status=hash['status'].to_sym @date_started = hash['date_started'] @date_ended = hash['date_ended'] @user = hash['user'] @args = (hash['argstring'] || "").split .each_slice(2) .reduce({}){|acc,cur| acc[cur[0]] = cur[1]; acc} @job = job @session = session end
where(project) { |qb| ... }
click to toggle source
# File lib/rundeck-ruby/execution.rb, line 50 def self.where(project) qb = SearchQueryBuilder.new yield qb if block_given? endpoint = "api/5/executions?project=#{project.name}#{qb.query}" pp endpoint results = project.session.get(endpoint, 'result', 'executions', 'execution') || [] results = [results] if results.is_a?(Hash) #Work around an inconsistency in the API results.map {|hash| from_hash(project.session, hash)} end
Public Instance Methods
output()
click to toggle source
# File lib/rundeck-ruby/execution.rb, line 61 def output path = "api/9/execution/#{id}/output" ret = session.get(path) result = ret['result'] raise APIFailure.new(path, result) unless result && result['success']=='true' #sort the output by node ret = result['output'].slice(*%w(id completed hasFailedNodes)) ret['log'] = result['output']['entries']['entry'].group_by{|e| e['node']} ret end
wait_for_complete(poll_interval, timeout)
click to toggle source
# File lib/rundeck-ruby/execution.rb, line 73 def wait_for_complete(poll_interval, timeout) Timeout.timeout(timeout) do while (cur = self.class.find(session, id)).status != :succeeded raise ExecutionFailure.new(self) if cur.status == :failed sleep(poll_interval) end end rescue Timeout::Error raise ExecutionTimeout.new(self) end