1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/aws/models/ec2/image.rb

44 lines
1.3 KiB
Ruby

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