2010-10-04 17:02:08 -04:00
|
|
|
require 'fog/core/collection'
|
2011-08-24 21:37:00 -04:00
|
|
|
require 'fog/aws/models/compute/image'
|
2010-03-16 18:46:21 -04:00
|
|
|
|
2010-01-10 16:35:20 -05:00
|
|
|
module Fog
|
2011-06-16 19:28:54 -04:00
|
|
|
module Compute
|
|
|
|
class AWS
|
2010-01-10 16:35:20 -05:00
|
|
|
|
|
|
|
class Images < Fog::Collection
|
|
|
|
|
2010-10-04 18:46:12 -04:00
|
|
|
attribute :filters
|
2010-01-10 16:35:20 -05:00
|
|
|
|
2011-06-16 19:28:54 -04:00
|
|
|
model Fog::Compute::AWS::Image
|
2010-11-29 18:44:44 -05:00
|
|
|
|
|
|
|
# Creates a new Amazon machine image
|
|
|
|
#
|
|
|
|
# AWS.images.new
|
|
|
|
#
|
|
|
|
# ==== Returns
|
|
|
|
#
|
|
|
|
# Returns the details of the new image
|
|
|
|
#
|
|
|
|
#>> AWS.images.new
|
|
|
|
# <Fog::AWS::Compute::Image
|
|
|
|
# id=nil,
|
|
|
|
# architecture=nil,
|
|
|
|
# block_device_mapping=nil,
|
|
|
|
# location=nil,
|
|
|
|
# owner_id=nil,
|
|
|
|
# state=nil,
|
|
|
|
# type=nil,
|
|
|
|
# is_public=nil,
|
|
|
|
# kernel_id=nil,
|
|
|
|
# platform=nil,
|
|
|
|
# product_codes=nil,
|
|
|
|
# ramdisk_id=nil,
|
|
|
|
# root_device_type=nil,
|
|
|
|
# root_device_name=nil,
|
|
|
|
# tags=nil
|
|
|
|
# >
|
|
|
|
#
|
|
|
|
|
2010-01-10 16:35:20 -05:00
|
|
|
def initialize(attributes)
|
2010-11-19 16:45:45 -05:00
|
|
|
self.filters ||= {}
|
2010-01-10 16:35:20 -05:00
|
|
|
super
|
|
|
|
end
|
2010-12-03 13:23:05 -05:00
|
|
|
|
2010-12-04 18:38:29 -05:00
|
|
|
def all(filters = filters)
|
2010-11-19 16:45:45 -05:00
|
|
|
self.filters = filters
|
|
|
|
data = connection.describe_images(filters).body
|
2010-03-06 23:02:10 -05:00
|
|
|
load(data['imagesSet'])
|
2010-01-10 16:35:20 -05:00
|
|
|
end
|
2010-11-29 18:44:44 -05:00
|
|
|
|
2010-01-10 16:35:20 -05:00
|
|
|
def get(image_id)
|
|
|
|
if image_id
|
2010-10-04 18:46:12 -04:00
|
|
|
self.class.new(:connection => connection).all('image-id' => image_id).first
|
2010-01-10 16:35:20 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|