2010-10-04 14:02:08 -07:00
|
|
|
require 'fog/core/collection'
|
2011-08-24 20:16:01 -05:00
|
|
|
require 'fog/rackspace/models/compute/image'
|
2010-03-19 18:29:42 -07:00
|
|
|
|
2009-11-19 08:19:46 -08:00
|
|
|
module Fog
|
2011-06-16 16:28:54 -07:00
|
|
|
module Compute
|
|
|
|
class Rackspace
|
2009-11-19 08:19:46 -08:00
|
|
|
|
|
|
|
class Images < Fog::Collection
|
|
|
|
|
2011-06-16 16:28:54 -07:00
|
|
|
model Fog::Compute::Rackspace::Image
|
2009-11-19 08:19:46 -08:00
|
|
|
|
|
|
|
attribute :server
|
|
|
|
|
|
|
|
def all
|
2010-03-06 20:02:10 -08:00
|
|
|
data = connection.list_images_detail.body['images']
|
2010-03-16 23:36:45 -07:00
|
|
|
load(data)
|
2009-11-19 08:19:46 -08:00
|
|
|
if server
|
2010-03-06 20:02:10 -08:00
|
|
|
self.replace(self.select {|image| image.server_id == server.id})
|
2009-11-19 08:19:46 -08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(image_id)
|
2010-04-08 12:55:55 -07:00
|
|
|
data = connection.get_image_details(image_id).body['image']
|
|
|
|
new(data)
|
2011-06-16 16:28:54 -07:00
|
|
|
rescue Fog::Compute::Rackspace::NotFound
|
2009-11-19 08:19:46 -08:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|