Class: Annex::List

Inherits:
Command show all
Defined in:
lib/annex/list.rb

Instance Method Summary collapse

Methods inherited from Command

#initialize

Constructor Details

This class inherits a constructor from Annex::Command

Instance Method Details

#executeObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/annex/list.rb', line 3

def execute
  which = servers.select do |server|
    name_tag = server.tags["Name"]
    name_tag = name_tag.gsub(/-i-[0-9a-f]+$/, '') rescue ''

    choose = server.state == "running"
    choose = choose && name_tag =~ /^#{role}/ if role
    choose = choose && name_tag =~ /#{environment}$/ if environment
    choose
  end

  which.each do |server|
    @env.info(server.tags["Name"], :info)
    @env.info("  #{server.dns_name}\n  Public: #{server.public_ip_address}\n  Private: #{server.private_ip_address}\n", :notice)
  end
end