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