2010-10-11 02:16:40 -04:00
|
|
|
require 'fog/core/collection'
|
2011-01-25 18:46:00 -05:00
|
|
|
require 'fog/compute/models/go_grid/image'
|
2010-10-11 02:16:40 -04:00
|
|
|
|
|
|
|
module Fog
|
|
|
|
module GoGrid
|
|
|
|
class Compute
|
|
|
|
|
|
|
|
class Images < Fog::Collection
|
|
|
|
|
|
|
|
model Fog::GoGrid::Compute::Image
|
|
|
|
|
|
|
|
attribute :server
|
|
|
|
|
|
|
|
def all
|
|
|
|
data = connection.grid_image_list.body['list']
|
|
|
|
load(data)
|
2010-10-11 22:53:24 -04:00
|
|
|
if server
|
|
|
|
self.replace(self.select {|image| image.server_id == server.id})
|
|
|
|
end
|
2010-10-11 02:16:40 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def get(image_id)
|
|
|
|
response = connection.grid_image_get.body['list'][image_id]
|
2010-10-11 22:53:24 -04:00
|
|
|
new(data)
|
2010-10-11 02:16:40 -04:00
|
|
|
rescue Fog::GoGrid::Compute::NotFound
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|