Class: Aws::Ec2::QEc2DescribeInstancesParser

Inherits:
AwsParser 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



1648
1649
1650
# File 'lib/ec2/ec2.rb', line 1648

def reset
  @result = []
end

#tagend(name) ⇒ Object



1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
# File 'lib/ec2/ec2.rb', line 1581

def tagend(name)
  case name
    # 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 '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' || # 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:



1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
# File 'lib/ec2/ec2.rb', line 1556

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         => '',
                 :aws_product_codes => [],
                 :tags              => {}}
  end
end