Class: Rig::Command::Abstract

Inherits:
Clamp::Command
  • Object
show all
Defined in:
lib/rig/command/abstract.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



66
67
68
# File 'lib/rig/command/abstract.rb', line 66

def execute
  super
end

#instance_list(list, detailed = false) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/rig/command/abstract.rb', line 28

def instance_list(list, detailed=false)
  rows = []
  list.each do |server|
    r = []
    r << server.tags['Name']
    r << server.tags['Environment']
    r << (server.tags['Roles']||server.tags["Role"])
    r << (server.tags['Protected'] ? 'true' : '')
    r << server.public_ip_address.to_s
    if detailed
      r << server.private_ip_address.to_s
    end
    r << server.availability_zone
    r << server.flavor_id.to_s
    r << server.id.to_s
    r << server.state.to_s.downcase
    if detailed
      r << server.dns_name
    end
    rows << r
  end

  cols = []
  cols << "Name"
  cols << "Environment"
  cols << "Role"
  cols << "Protected"
  cols << "Public IP"
  cols << "Private IP" if detailed
  cols << "AZ"
  cols << "Size"
  cols << "Instance ID"
  cols << "State"
  cols << "DNS" if detailed

  print_table(cols, rows)
end


24
25
26
# File 'lib/rig/command/abstract.rb', line 24

def print_table(columns, rows)
  puts table(columns, *rows)
end