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
|
2011-06-16 19:28:54 -04:00
|
|
|
module Compute
|
|
|
|
class GoGrid
|
2010-10-11 02:16:40 -04:00
|
|
|
|
|
|
|
class Images < Fog::Collection
|
|
|
|
|
2011-06-16 19:28:54 -04:00
|
|
|
model Fog::Compute::GoGrid::Image
|
2010-10-11 02:16:40 -04:00
|
|
|
|
|
|
|
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)
|
2011-06-16 19:28:54 -04:00
|
|
|
rescue Fog::Compute::GoGrid::NotFound
|
2010-10-11 02:16:40 -04:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|