2011-01-19 17:07:04 -05:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Voxel
|
|
|
|
class Compute
|
|
|
|
|
|
|
|
class BlockInstantiationError < StandardError; end
|
|
|
|
|
|
|
|
class Server < Fog::Model
|
|
|
|
|
|
|
|
identity :id
|
|
|
|
|
|
|
|
attribute :name
|
|
|
|
attribute :processing_cores
|
2011-01-19 19:17:23 -05:00
|
|
|
attribute :image_id
|
2011-01-19 17:07:04 -05:00
|
|
|
#attribute :ip
|
|
|
|
attribute :status
|
|
|
|
attribute :facility
|
2011-01-19 19:17:23 -05:00
|
|
|
attribute :disk_size
|
2011-02-09 18:18:48 -05:00
|
|
|
attribute :addresses
|
|
|
|
attribute :password
|
2011-01-19 17:07:04 -05:00
|
|
|
|
|
|
|
def initialize(attributes={})
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
requires :id
|
|
|
|
connection.voxcloud_delete(id)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def image
|
|
|
|
requires :image_id
|
|
|
|
connection.images_list(image_id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def ready?
|
2011-02-11 13:04:05 -05:00
|
|
|
status == 'SUCCEEDED'
|
2011-01-19 17:07:04 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
|
|
|
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
2011-01-19 19:17:23 -05:00
|
|
|
requires :name, :image_id, :processing_cores, :facility, :disk_size
|
2011-01-19 17:07:04 -05:00
|
|
|
|
2011-01-19 19:17:23 -05:00
|
|
|
options = { :hostname => name, :image_id => image_id, :processing_cores => processing_cores, :facility => facility, :disk_size => disk_size }
|
2011-01-19 17:07:04 -05:00
|
|
|
|
|
|
|
data = connection.voxcloud_create(options)
|
|
|
|
|
2011-01-19 19:17:23 -05:00
|
|
|
merge_attributes(data.first)
|
2011-01-19 17:07:04 -05:00
|
|
|
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|