Class: RightAws::Ec2::QEc2DescribeInstancesParser

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

Overview


PARSERS: Instances

Constant Summary

Constants inherited from RightAWSParser

RightAWSParser::DEFAULT_XML_LIBRARY

Instance Attribute Summary

Attributes inherited from RightAWSParser

#result, #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



1463
1464
1465
# File 'lib/ec2/right_ec2.rb', line 1463

def reset
  @result = []
end

#tagend(name) ⇒ Object



1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
# File 'lib/ec2/right_ec2.rb', line 1430

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 'item'
      if @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:



1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
# File 'lib/ec2/right_ec2.rb', line 1407

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 => [] }
  end
end