Class: Awshark::Rds::Subcommand

Inherits:
Thor
  • Object
show all
Includes:
ClassOptions
Defined in:
lib/awshark/rds/subcommand.rb

Instance Method Summary collapse

Methods included from ClassOptions

#process_class_options

Instance Method Details

#checkObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/awshark/rds/subcommand.rb', line 19

def check
  process_class_options

  puts "\n+++ Instances +++"
  list

  checks = manager.check_reservations
  pattern = "%-15s %-15s %-15s %-15s %s\n"
  puts "\n+++ Check +++"
  printf pattern, 'Reserved', 'Instances', 'Type', 'MultiAZ', 'Comment'
  checks.each do |c|
    printf pattern, c.reserved_count, c.instance_count, c.type, c.multi_az, comment(c)
  end
end

#listObject



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/awshark/rds/subcommand.rb', line 40

def list
  process_class_options

  instances = manager.instances
  instances = instances.sort_by(&:name)

  pattern = "%-30s %-15s %-20s %-10s %-10s %s\n"
  printf pattern, 'Name', 'Type', 'Engine (Version)', 'MultiAZ', 'Encrypted', 'State'
  instances.each do |i|
    printf pattern, i.name, i.type, "#{i.engine} (#{i.engine_version})", i.multi_az, i.encrypted, i.state
  end
end

#reservationsObject



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/awshark/rds/subcommand.rb', line 59

def reservations
  process_class_options

  reservations = manager.reservations

  pattern = "%-30s %-26s %-30s %s\n"
  printf pattern, 'Reserved', 'Type', 'MultiAZ', 'Offering'
  reservations.each do |r|
    printf pattern, r.count, r.type, r.multi_az, r.offering_type
  end
end