Class: Chimp::ExecReport

Inherits:
Executor show all
Defined in:
lib/right_chimp/exec/exec_report.rb

Constant Summary

Constants inherited from Executor

Chimp::Executor::STATUS_DONE, Chimp::Executor::STATUS_ERROR, Chimp::Executor::STATUS_HOLDING, Chimp::Executor::STATUS_NONE, Chimp::Executor::STATUS_RETRYING, Chimp::Executor::STATUS_RUNNING

Instance Attribute Summary collapse

Attributes inherited from Executor

#array, #concurrency, #delay, #dry_run, #error, #exec, #group, #inputs, #job_id, #job_notes, #job_uuid, #owner, #quiet, #results, #retry_count, #retry_sleep, #status, #template, #time_end, #time_start, #timeout, #verbose

Instance Method Summary collapse

Methods inherited from Executor

#cancel, #get_total_exec_time, #initialize, #queue, #requeue, #target

Constructor Details

This class inherits a constructor from Chimp::Executor

Instance Attribute Details

#fieldsObject

Returns the value of attribute fields.



10
11
12
# File 'lib/right_chimp/exec/exec_report.rb', line 10

def fields
  @fields
end

#serverObject

Returns the value of attribute server.



10
11
12
# File 'lib/right_chimp/exec/exec_report.rb', line 10

def server
  @server
end

Instance Method Details

#infoObject



13
14
15
# File 'lib/right_chimp/exec/exec_report.rb', line 13

def info
  return "report on server #{fields.inspect}"
end

#runObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/right_chimp/exec/exec_report.rb', line 17

def run
  run_with_retry do
    output = []

    begin
      s=@server
      Log.debug "Making API 1.5 call: client.tags"
      response=Connection.client.tags.by_resource(:resource_hrefs => [@server.href]).first.tags
    rescue Exception => ex
      raise e
      s = @server
      response = nil
    end

    s.params["tags"] = [] unless s.params["tags"]
    response.each do |t|
      s.params["tags"] += [ t['name'] ]
    end

    @fields.split(",").each do |f|
      if f =~ /^tag=([^,]+)/
        tag_search_string = $1
        s.params["tags"].each do |tag|
          output << tag if tag =~ /^#{tag_search_string}/
        end
      else
        output << s.params[f]
      end
    end

    puts output.join(",")
  end
end