Class: Vaws::Aws::Ec2Describer
- Defined in:
- lib/vaws/aws/ec2_describer.rb
Instance Attribute Summary collapse
-
#term_table ⇒ Object
readonly
Returns the value of attribute term_table.
Instance Method Summary collapse
-
#initialize ⇒ Ec2Describer
constructor
A new instance of Ec2Describer.
- #set_basic_info ⇒ Object
Methods inherited from Describer
Constructor Details
#initialize ⇒ Ec2Describer
Returns a new instance of Ec2Describer.
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_table ⇒ Object (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_info ⇒ Object
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 40 41 42 43 44 45 46 47 |
# File 'lib/vaws/aws/ec2_describer.rb', line 15 def set_basic_info rows = [] next_token = nil sg_ids = "" begin param_args = { max_results: 1000 } param_args[:next_token] = next_token if next_token resp = @ec2_client.describe_instances(param_args) resp[:reservations].each do |reservation| reservation.instances.each do |instance| instance..each do |tag| @tag = tag.value if tag.key == 'Name' end instance.security_groups.each_with_index do |sg, index| sg_ids << "#{sg.group_id}, " sg_ids = sg_ids.gsub(/, $/, '') if index == instance.security_groups.size - 1 end instance_id = instance.instance_id instance_type = instance.instance_type public_ip = instance.public_ip_address private_ip = instance.private_ip_address state_name = instance.state.name rows << [@tag, instance_id, instance_type, public_ip, private_ip, state_name, sg_ids] sg_ids = '' end end next_token = resp.next_token end while next_token @term_table = Terminal::Table.new :headings => ['Name', 'Id', 'Type', 'GlobalIp', 'PrivateIp', 'Status', 'SecurityGroupId'], :rows => rows.sort end |