Sha256: 4d7e8cdcc1bb8c30fc1a78aa2c31d3d272e663746d737cfdb3e3c1eac8ac73dd

Contents?: true

Size: 1.9 KB

Versions: 12

Compression:

Stored size: 1.9 KB

Contents

module Fog
  module Parsers
    module AWS
      module EC2

        class DescribeImages < Fog::Parsers::Base

          def reset
            @image = { 'productCodes' => [], 'blockDeviceMapping' => nil }
            @response = { 'imagesSet' => [] }
          end

          def start_element(name, attrs = [])
            super
            if name == 'productCodes'
              @in_product_codes = true
            elsif name == 'blockDeviceMapping'
              @in_block_device_mapping = true
              @image['blockDeviceMapping'] = []
             elsif name == 'item' && @in_block_device_mapping
              @image['blockDeviceMapping'] << {}
            end
          end
          
          def end_element(name)
            case name
            when 'architecture',  'imageId', 'imageLocation', 'imageOwnerId', 'imageState', 'imageType', 'kernelId', 'platform', 'ramdiskId', 'rootDeviceType','rootDeviceName'
              @image[name] = @value
            when 'isPublic'
              if @value == 'true'
                @image[name] = true
              else
                @image[name] = false
              end
            when 'item'
              if @in_block_device_mapping
              elsif !@in_product_codes
                @response['imagesSet'] << @image
                @image = { 'productCodes' => [] }
              end
            when 'productCode'
              @image['productCodes'] << @value
            when 'productCodes'
              @in_product_codes = false
            when 'blockDeviceMapping'
              @in_block_device_mapping = false
            when 'requestId'
              @response[name] = @value
            when 'deviceName','virtualName','snapshotId','volumeSize','deleteOnTermination'
              l = @image['blockDeviceMapping'].length
              @image['blockDeviceMapping'][l-1].store(name,@value)
            end
          end

        end

      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
fog-0.2.30 lib/fog/aws/parsers/ec2/describe_images.rb
fog-0.2.28 lib/fog/aws/parsers/ec2/describe_images.rb
fog-0.2.27 lib/fog/aws/parsers/ec2/describe_images.rb
fog-0.2.26 lib/fog/aws/parsers/ec2/describe_images.rb
fog-0.2.25 lib/fog/aws/parsers/ec2/describe_images.rb
fog-0.2.24 lib/fog/aws/parsers/ec2/describe_images.rb
tecnh-fog-0.2.23.vpc lib/fog/aws/parsers/ec2/describe_images.rb
fog-0.2.23 lib/fog/aws/parsers/ec2/describe_images.rb
fog-0.2.22 lib/fog/aws/parsers/ec2/describe_images.rb
fog-0.2.21 lib/fog/aws/parsers/ec2/describe_images.rb
fog-0.2.20 lib/fog/aws/parsers/ec2/describe_images.rb
fog-0.2.19 lib/fog/aws/parsers/ec2/describe_images.rb