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.1.17 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.1.15 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.1.14 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.1.13 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.1.12 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.1.10 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.1.8 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.1.7 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.1.6 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.1.5 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.1.4 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.1.3 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.1.2 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.1.0 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.0.2 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.0.1 lib/right_chimp/exec/ExecReport.rb
right_chimp-2.0 lib/right_chimp/exec/ExecReport.rb