Sha256: 0aa548f71b1a21fc7b20d0da85185ec14bb43603cd3b7b1052cb7787ba50c8c3

Contents?: true

Size: 1.31 KB

Versions: 12

Compression:

Stored size: 1.31 KB

Contents

require 'fog/model'

module Fog
  module AWS
    module EC2

      class Image < Fog::Model

        identity :id,                    'imageId'

        attribute :architecture
        attribute :block_device_mapping, 'blockDeviceMapping'
        attribute :location,             'imageLocation'
        attribute :owner_id,             'imageOwnerId'
        attribute :state,                'imageState'
        attribute :type,                 'imageType'
        attribute :is_public,            'isPublic'
        attribute :kernel_id,            'kernelId'
        attribute :platform
        attribute :product_codes,        'productCodes'
        attribute :ramdisk_id,           'ramdiskId'
        attribute :root_device_type,     'rootDeviceType'
        attribute :root_device_name,     'rootDeviceName'

        def deregister(delete_snapshot = false)
          connection.deregister_image(@id)

          if(delete_snapshot && @root_device_type=="ebs")
            @block_device_mapping.each do |block_device|
              next if block_device["deviceName"] != @root_device_name
              snapshot_id = block_device["snapshotId"]
              snapshot = @connection.snapshots.get(snapshot_id)
              return snapshot.destroy
            end
          end

          return true
        end

      end

    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

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