Class: Vaws::Aws::Ec2Describer

Inherits:
Describer show all
Defined in:
lib/vaws/aws/ec2_describer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEc2Describer



9
10
11
12
13
# File 'lib/vaws/aws/ec2_describer.rb', line 9

def initialize
  @ec2_client = ::Aws::EC2::Client.new
  @tag        = 'No Name'
  @term_table = ''
end

Instance Attribute Details

#term_tableObject (readonly)

Returns the value of attribute term_table.



7
8
9
# File 'lib/vaws/aws/ec2_describer.rb', line 7

def term_table
  @term_table
end

Instance Method Details

#set_basic_infoObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/vaws/aws/ec2_describer.rb', line 15

def set_basic_info
  rows             = []
  ec2_reservations = @ec2_client.describe_instances.reservations
  ec2_reservations.each do |ec2_rsvn|
    ec2_rsvn.instances.each do |ec2_instance|
      ec2_instance.tags.each do |tag|
        @tag = tag.value if tag.key == 'Name'
      end
      instance_id   = ec2_instance.instance_id
      instance_type = ec2_instance.instance_type
      public_ip     = ec2_instance.public_ip_address
      private_ip    = ec2_instance.private_ip_address
      state_name    = ec2_instance.state.name
      rows << [@tag, instance_id, instance_type, public_ip, private_ip, state_name]
    end
  end
  @term_table = Terminal::Table.new :headings => ['Name', 'Id', 'Type', 'GlobalIp', 'PrivateIp', 'Status'], :rows => rows
end