Sha256: 2898fe8261cd5a11099c27b3b8d735306ca99fa0858216b36d95ddd4a747a60a

Contents?: true

Size: 1.21 KB

Versions: 37

Compression:

Stored size: 1.21 KB

Contents

#
# Report
#
# :fields is a comma seperated list of fields to report on,
#
# Example: ip-address,name,href,private-ip-address,resource_uid,
# ec2-instance-type,datacenter,dns-name,locked,tag=foo
module Chimp
  class ExecReport < Executor
    attr_reader :server, :fields
    attr_writer :server, :fields

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

    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
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
right_chimp-2.4 lib/right_chimp/exec/exec_report.rb
right_chimp-2.3.2 lib/right_chimp/exec/exec_report.rb
right_chimp-2.3.1 lib/right_chimp/exec/exec_report.rb
right_chimp-2.3 lib/right_chimp/exec/exec_report.rb
right_chimp-2.2.2 lib/right_chimp/exec/exec_report.rb
right_chimp-2.2.1 lib/right_chimp/exec/exec_report.rb
right_chimp-2.2 lib/right_chimp/exec/exec_report.rb
right_chimp-2.1.28 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.1.27 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.1.26 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.1.25.2 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.1.25 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.1.24 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.1.22.2 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.1.22.1 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.1.22 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.1.21 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.1.19.1 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.1.19 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.1.18 lib/right_chimp/exec/ExecReport.rb