Class: Aws::Ec2::QEc2DescribeInstancesParser

Inherits:
AwsParser
  • Object
show all
Defined in:
lib/ec2/ec2.rb

Overview


PARSERS: Instances

Constant Summary

Constants inherited from AwsParser

AwsParser::DEFAULT_XML_LIBRARY

Instance Attribute Summary

Attributes inherited from AwsParser

#result, #xml_lib, #xmlpath

Instance Method Summary collapse

Methods inherited from AwsParser

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

Constructor Details

This class inherits a constructor from Aws::AwsParser

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Aws::AwsParser

Instance Method Details

#resetObject



1786
1787
1788
# File 'lib/ec2/ec2.rb', line 1786

def reset
  @result = []
end

#tagend(name) ⇒ Object



1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
# File 'lib/ec2/ec2.rb', line 1707

def tagend(name)
  case name
    when  'rootDeviceType' then
      @instance[:root_device_type] = @text
    when 'architecture' then
      @instance[:architecture] = @text
    when 'rootDeviceName' then
      @instance[:root_device_name] = @text
    # reservation
    when 'reservationId' then
      @reservation[:aws_reservation_id] = @text
    when 'ownerId' then
      @reservation[:aws_owner] = @text
    when 'groupId' then
      @reservation[:aws_groups] << @text
    # instance
    when 'instanceId' then
      @instance[:aws_instance_id] = @text
    when 'imageId' then
      @instance[:aws_image_id] = @text
    when 'dnsName' then
      @instance[:dns_name] = @text
    when 'privateDnsName' then
      @instance[:private_dns_name] = @text
    when 'reason' then
      @instance[:aws_reason] = @text
    when 'keyName' then
      @instance[:ssh_key_name] = @text
    when 'amiLaunchIndex' then
      @instance[:ami_launch_index] = @text
    when 'code' then
      @instance[:aws_state_code] = @text
    when 'name' then
      @instance[:aws_state] = @text
    when 'productCode' then
      @instance[:aws_product_codes] << @text
    when 'instanceType' then
      @instance[:aws_instance_type] = @text
    when 'launchTime' then
      @instance[:aws_launch_time] = @text
    when 'kernelId' then
      @instance[:aws_kernel_id] = @text
    when 'ramdiskId' then
      @instance[:aws_ramdisk_id] = @text
    when 'platform' then
      @instance[:aws_platform] = @text
    when 'availabilityZone' then
      @instance[:aws_availability_zone] = @text
    when 'privateIpAddress' then
      @instance[:aws_private_ip_address] = @text
    when 'key' then
      @tag_key = @text
    when 'value' then
      @tag_value = @text
    when 'deviceName' then
      @device_name = @text
    when 'volumeId' then
      @volume_id = @text
    when 'state'
      if @xmlpath == 'DescribeInstancesResponse/reservationSet/item/instancesSet/item/monitoring' || # DescribeInstances property
      @xmlpath == 'RunInstancesResponse/instancesSet/item/monitoring' # RunInstances property
        @instance[:monitoring_state] = @text
      end
    when 'item'
      if @xmlpath=='DescribeInstancesResponse/reservationSet/item/instancesSet/item/tagSet' # Tags
        @instance[:tags][@tag_key] = @tag_value
      elsif @xmlpath == 'DescribeInstancesResponse/reservationSet/item/instancesSet/item/blockDeviceMapping' # Block device mappings
        @instance[:block_device_mappings] << { @device_name => @volume_id }
      elsif @xmlpath == 'DescribeInstancesResponse/reservationSet/item/instancesSet' || # DescribeInstances property
      @xmlpath == 'RunInstancesResponse/instancesSet' # RunInstances property
        @reservation[:instances_set] << @instance
      elsif @xmlpath=='DescribeInstancesResponse/reservationSet' # DescribeInstances property
        @result << @reservation
      end
    when 'RunInstancesResponse' then
      @result << @reservation # RunInstances property
  end
end

#tagstart(name, attributes) ⇒ Object

:nodoc:



1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
# File 'lib/ec2/ec2.rb', line 1678

def tagstart(name, attributes)
  # DescribeInstances property
  if (name == 'item' && @xmlpath == 'DescribeInstancesResponse/reservationSet') ||
      # RunInstances property
  (name == 'RunInstancesResponse')
    @reservation = {:aws_groups    => [],
                    :instances_set => []}

  elsif (name == 'item') &&
      # DescribeInstances property
  (@xmlpath=='DescribeInstancesResponse/reservationSet/item/instancesSet' ||
      # RunInstances property
  @xmlpath=='RunInstancesResponse/instancesSet')
    # the optional params (sometimes are missing and we dont want them to be nil)
    @instance = {:aws_reason        => '',
                 :dns_name          => '',
                 :private_dns_name  => '',
                 :ami_launch_index  => '',
                 :ssh_key_name      => '',
                 :aws_state         => '',
                 :root_device_type  => '',
                 :root_device_name  => '',
                 :architecture      => '',
                 :block_device_mappings => [],
                 :aws_product_codes => [],
                 :tags              => {}}
  end
end