2010-10-11 02:16:40 -04:00
|
|
|
require 'fog/core/collection'
|
2011-08-24 21:27:03 -04:00
|
|
|
require 'fog/go_grid/models/compute/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
|
2012-12-22 18:26:52 -05:00
|
|
|
data = service.grid_image_list.body['list']
|
2010-10-11 02:16:40 -04:00
|
|
|
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)
|
2012-12-22 18:26:52 -05:00
|
|
|
response = service.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
|