2010-03-16 18:46:21 -04:00
|
|
|
require 'fog/collection'
|
|
|
|
require 'fog/aws/models/ec2/image'
|
|
|
|
|
2010-01-10 16:35:20 -05:00
|
|
|
module Fog
|
|
|
|
module AWS
|
2010-09-03 04:11:45 -04:00
|
|
|
class EC2
|
2010-01-10 16:35:20 -05:00
|
|
|
|
|
|
|
class Images < Fog::Collection
|
|
|
|
|
|
|
|
attribute :image_id
|
|
|
|
|
|
|
|
model Fog::AWS::EC2::Image
|
|
|
|
|
|
|
|
def initialize(attributes)
|
|
|
|
@image_id ||= []
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def all(image_id = @image_id)
|
|
|
|
@image_id = image_id
|
|
|
|
data = connection.describe_images('ImageId' => image_id).body
|
2010-03-06 23:02:10 -05:00
|
|
|
load(data['imagesSet'])
|
2010-01-10 16:35:20 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def get(image_id)
|
|
|
|
if image_id
|
|
|
|
all(image_id).first
|
|
|
|
end
|
2010-05-26 20:27:17 -04:00
|
|
|
rescue Fog::Errors::NotFound
|
2010-01-10 16:35:20 -05:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|