Class: VolumesStatus

Inherits:
VolumesCommand show all
Defined in:
lib/maws/commands/volumes-status.rb

Instance Attribute Summary

Attributes inherited from Command

#connection, #maws

Instance Method Summary collapse

Methods inherited from VolumesCommand

#create_ebs_from_descriptions

Methods inherited from Command

#add_generic_options, #add_specific_options, #initialize, #instances, #process_options, #verify_configs, #verify_options

Constructor Details

This class inherits a constructor from Command

Instance Method Details

#descriptionObject



6
7
8
# File 'lib/maws/commands/volumes-status.rb', line 6

def description
   "volumes-status - show brief status information for EBS volumes for specified roles"
end

#list_ebs_instances(instances) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/maws/commands/volumes-status.rb', line 22

def list_ebs_instances(instances)
  if instances.empty?
    info "none available"
    return
  end

  headers = instances.first.display.headers
  table_rows = []
  grouped_instances = instances.
                          group_by{|i| i.name}.
                          to_a.sort_by {|group| group[0]} # sort by name

  grouped_instances.each_with_index do |(name, instances), i|
    instances.each {|instance|
      table_rows << instance.display.values
    }

  end

  info table(headers, *table_rows)
end

#run!Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/maws/commands/volumes-status.rb', line 10

def run!
  super
  attached = instances.specified.ebs.matching(:attached? => true)
  unattached = instances.specified.ebs.matching(:attached? => false)

  info "\n**** " + "ATTACHED EBS VOLUMES" + " *****************"
  list_ebs_instances(attached)

  info "\n\n**** " + "UNATTACHED EBS VOLUMES" + " *****************"
  list_ebs_instances(unattached)
end