2010-10-11 02:16:40 -04:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
2011-06-16 19:28:54 -04:00
|
|
|
module Compute
|
|
|
|
class GoGrid
|
2010-10-11 02:16:40 -04:00
|
|
|
|
|
|
|
class Image < Fog::Model
|
|
|
|
|
|
|
|
identity :id
|
|
|
|
|
|
|
|
attribute :name
|
2010-10-11 22:53:24 -04:00
|
|
|
attribute :description
|
2010-10-11 02:16:40 -04:00
|
|
|
attribute :friendly_name, :aliases => 'friendlyName'
|
|
|
|
attribute :created_at, :aliases => 'createdTime'
|
|
|
|
attribute :updated_at, :aliases => 'updatedTime'
|
|
|
|
attribute :server_id, :aliases => 'id'
|
2010-10-11 22:53:24 -04:00
|
|
|
attribute :state
|
|
|
|
attribute :price
|
|
|
|
attribute :location
|
|
|
|
attribute :billingtokens
|
|
|
|
attribute :os
|
|
|
|
attribute :architecture
|
|
|
|
attribute :type
|
|
|
|
attribute :active, :aliases => 'isActive'
|
|
|
|
attribute :public, :aliases => 'isPublic'
|
|
|
|
attribute :object_type, :aliases => 'object'
|
|
|
|
attribute :owner
|
|
|
|
|
2010-10-11 02:16:40 -04:00
|
|
|
|
|
|
|
def server=(new_server)
|
|
|
|
requires :id
|
|
|
|
|
|
|
|
@server_id = new_server.id
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
requires :id
|
|
|
|
|
2012-12-22 18:26:52 -05:00
|
|
|
service.grid_server_delete(id)
|
2010-10-11 02:16:40 -04:00
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def ready?
|
|
|
|
status == 'Available'
|
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
2012-12-22 21:45:05 -05:00
|
|
|
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
|
2010-10-11 02:16:40 -04:00
|
|
|
requires :server_id
|
|
|
|
|
2012-12-22 18:26:52 -05:00
|
|
|
data = service.grid_server_add(server_id, 'name' => name)
|
2010-10-11 02:16:40 -04:00
|
|
|
merge_attributes(data.body['image'])
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|