1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/compute/models/voxel/server.rb
2011-02-23 14:51:18 -08:00

58 lines
1.2 KiB
Ruby

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
attribute :image_id
#attribute :ip
attribute :status
attribute :facility
attribute :disk_size
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?
@status == 'SUCCEEDED'
end
def save
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
requires :name, :image_id, :processing_cores, :facility, :disk_size
options = { :hostname => name, :image_id => image_id, :processing_cores => processing_cores, :facility => facility, :disk_size => disk_size }
data = connection.voxcloud_create(options)
merge_attributes(data.first)
true
end
end
end
end
end