Class: RightAws::Ec2::QEc2DescribeInstancesParser

Inherits:
RightAWSParser show all
Defined in:
lib/ec2/right_ec2_instances.rb

Overview


PARSERS: Instances

Constant Summary

Constants inherited from RightAWSParser

RightAWSParser::DEFAULT_XML_LIBRARY

Instance Attribute Summary

Attributes inherited from RightAWSParser

#full_tag_name, #result, #tag, #xml_lib, #xmlpath

Instance Method Summary collapse

Methods inherited from RightAWSParser

#initialize, #method_missing, #parse, #tag_end, #tag_start, #tagtext, #text, xml_lib, xml_lib=

Constructor Details

This class inherits a constructor from RightAws::RightAWSParser

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RightAws::RightAWSParser

Instance Method Details

#resetObject



642
643
644
# File 'lib/ec2/right_ec2_instances.rb', line 642

def reset
  @result = []
end

#tagend(name) ⇒ Object



581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
# File 'lib/ec2/right_ec2_instances.rb', line 581

def tagend(name)
  case name
  when 'reservationId'    then @reservation[:aws_reservation_id] = @text
  when 'ownerId'          then @reservation[:aws_owner]          = @text
  when 'groupId'          then @reservation[:aws_groups]        << @text
  when 'instanceId'       then @item[:aws_instance_id]       = @text
  when 'imageId'          then @item[:aws_image_id]          = @text
  when 'privateDnsName'   then @item[:private_dns_name]      = @text
  when 'dnsName'          then @item[:dns_name]              = @text
  when 'reason'           then @item[:aws_reason]            = @text
  when 'keyName'          then @item[:ssh_key_name]          = @text
  when 'amiLaunchIndex'   then @item[:ami_launch_index]      = @text
  when 'productCode'      then @item[:aws_product_codes]    << @text
  when 'instanceType'     then @item[:aws_instance_type]     = @text
  when 'launchTime'       then @item[:aws_launch_time]       = @text
  when 'availabilityZone' then @item[:aws_availability_zone] = @text
  when 'kernelId'         then @item[:aws_kernel_id]         = @text
  when 'ramdiskId'        then @item[:aws_ramdisk_id]        = @text
  when 'platform'         then @item[:aws_platform]          = @text
  when 'subnetId'         then @item[:subnet_id]             = @text
  when 'vpcId'            then @item[:vpc_id]                = @text
  when 'privateIpAddress' then @item[:private_ip_address]    = @text
  when 'ipAddress'        then @item[:ip_address]            = @text
  when 'architecture'     then @item[:architecture]          = @text
  when 'rootDeviceType'   then @item[:root_device_type]      = @text
  when 'rootDeviceName'   then @item[:root_device_name]      = @text
  when 'instanceClass'    then @item[:instance_class]        = @text
  when 'instanceLifecycle'     then @item[:instance_lifecycle]       = @text
  when 'spotInstanceRequestId' then @item[:spot_instance_request_id] = @text
  when 'requesterId'           then @item[:requester_id]             = @text
  when 'groupName'             then @item[:placement_group_name]     = @text 
  when 'virtualizationType'    then @item[:virtualization_type]      = @text
  when 'clientToken'           then @item[:client_token]     = @text
  else
    case full_tag_name
    when %r{/stateReason/code$}    then @item[:state_reason_code]    = @text
    when %r{/stateReason/message$} then @item[:state_reason_message] = @text
    when %r{/instanceState/code$}  then @item[:aws_state_code]       = @text.to_i
    when %r{/instanceState/name$}  then @item[:aws_state]            = @text
    when %r{/monitoring/state$}    then @item[:monitoring_state]     = @text
    when %r{/license/pool$}        then @item[:license_pool]         = @text
    when %r{/blockDeviceMapping/item} # no trailing $
      case name
      when 'deviceName'          then @block_device_mapping[:device_name]                = @text
      when 'virtualName'         then @block_device_mapping[:virtual_name]               = @text
      when 'volumeId'            then @block_device_mapping[:ebs_volume_id]              = @text
      when 'status'              then @block_device_mapping[:ebs_status]                 = @text
      when 'attachTime'          then @block_device_mapping[:ebs_attach_time]            = @text
      when 'deleteOnTermination' then @block_device_mapping[:ebs_delete_on_termination]  = @text == 'true' ? true : false
      when 'item'                then @item[:block_device_mappings]                     << @block_device_mapping
      end
    when %r{/instancesSet/item$} then @reservation[:instances_set] << @item
    when %r{/tagSet/item/key$}   then @aws_tag[:key]               = @text
    when %r{/tagSet/item/value$} then @aws_tag[:value]             = @text
    when %r{/tagSet/item$}       then @item[:tags][@aws_tag[:key]] = @aws_tag[:value]
    when 'DescribeInstancesResponse/reservationSet/item',
         'RunInstancesResponse'
      @result << @reservation
    end
  end
end

#tagstart(name, attributes) ⇒ Object

:nodoc:



557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
# File 'lib/ec2/right_ec2_instances.rb', line 557

def tagstart(name, attributes)
     # DescribeInstances property
  case full_tag_name
  when 'DescribeInstancesResponse/reservationSet/item',
       'RunInstancesResponse'
    @reservation = { :aws_groups    => [],
                     :instances_set => [] }
  when %r{instancesSet/item$}
      # the optional params (sometimes are missing and we dont want them to be nil)
    @item = { :aws_reason       => '',
              :dns_name         => '',
              :private_dns_name => '',
              :ami_launch_index => '',
              :ssh_key_name     => '',
              :aws_state        => '',
              :aws_product_codes => [],
              :tags              => {} }
  when %r{blockDeviceMapping/item$}
    @item[:block_device_mappings] ||= []
    @block_device_mapping = {}
  when %r{/tagSet/item$}
    @aws_tag = {}
  end
end