Class: Demeter::Commands::Status

Inherits:
Base
  • Object
show all
Defined in:
lib/demeter/commands/status.rb

Instance Method Summary collapse

Methods inherited from Base

#check_path, #initialize

Constructor Details

This class inherits a constructor from Demeter::Commands::Base

Instance Method Details

#startObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/demeter/commands/status.rb', line 9

def start
  sgs_manager = Demeter::Aws::ManageSecurityGroups.new(ec2:@ec2, options:@options)
  status = sgs_manager.status
  rows = []
 
  rows << [{:value => "### MANAGED SECURITY GROUPS ###".colorize(:green), :colspan => 3, :alignment => :left}]
  rows << :separator
  rows << ['Name', 'Group Name', 'Group ID']
  rows << :separator
  
  status[:managed].each do |sg|
    rows << [sg[:name], sg[:group_name], sg[:group_id]]
  end 
  
  rows << :separator
  rows << [{:value => "### UNMANAGED SECURITY GROUPS ###".colorize(:red), :colspan => 3, :alignment => :left}]
  rows << :separator
  rows << ['Name', 'Group Name', 'Group ID']
  rows << :separator
  
  status[:unmanaged].each do |sg|
    rows << [sg[:name], sg[:group_name], sg[:group_id]]
  end 

  puts Terminal::Table.new :rows => rows
 
  puts ""
  puts "#{'MANAGED'.colorize(:green)}: #{status[:managed].count}" 
  puts "#{'UNMANAGED'.colorize(:red)}: #{status[:unmanaged].count}"
  puts ""
end