Sha256: fcfbf5c8f62e3a8bd873024f9ae1ec102dd7823fa424799f47e5984a5ab05e11

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

require_relative "ec2"
require_relative "data"

module Gaptool
  module EC2
    def self.rehash()
      Gaptool::Data::servers.each do |inst|
        Gaptool::Data::rmserver inst
      end
      roles = Gaptool::Data::roles
      Gaptool::Data::zones.each do |zone|
        Gaptool::EC2::configure_ec2 zone
        @ec2 = AWS::EC2.new
        ilist = []
        @ec2.instances.each do |instance|
          if instance.tags['gaptool'] == 'yes' && instance.status == :running
            ilist << instance
          end
        end
        ilist.each do |instance|
          puts " - #{instance.tags['Name']}"
          role, environment, iid = instance.tags['Name'].split('-', 3)
          data = {
            "zone"=> instance.availability_zone,
            "role"=> role,
            "environment"=> environment,
            "hostname" => instance.public_dns_name,
            "launch_time" => instance.launch_time.to_s,
            "apps" => roles[role].to_s,
            "instance"=> instance.instance_id
          }
          Gaptool::Data::addserver(iid, data, nil)
        end
      end
      return {"action" => "complete"}
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gaptool-server-0.6.4 lib/helpers/rehash.rb
gaptool-server-0.6.3 lib/helpers/rehash.rb
gaptool-server-0.6.0 lib/helpers/rehash.rb