mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
60 lines
1.1 KiB
Ruby
60 lines
1.1 KiB
Ruby
|
require 'fog/model'
|
||
|
|
||
|
module Fog
|
||
|
module Bluebox
|
||
|
|
||
|
class BlockInstantiationError < StandardError; end
|
||
|
|
||
|
class Server < Fog::Model
|
||
|
|
||
|
identity :id
|
||
|
|
||
|
attribute :memory
|
||
|
attribute :storage
|
||
|
attribute :hostname
|
||
|
attribute :cpu
|
||
|
attribute :ips
|
||
|
attribute :status
|
||
|
attribute :flavor_id
|
||
|
attribute :image_id
|
||
|
|
||
|
# Not reported by the API, but used at create time
|
||
|
attr_accessor :name, :password, :hash, :text, :error
|
||
|
|
||
|
def destroy
|
||
|
requires :id
|
||
|
connection.destroy_block(@id)
|
||
|
true
|
||
|
end
|
||
|
|
||
|
def flavor
|
||
|
requires :flavor_id
|
||
|
connection.flavors.get(@flavor_id)
|
||
|
end
|
||
|
|
||
|
def image
|
||
|
requires :image_id
|
||
|
connection.images.get(@image_id)
|
||
|
end
|
||
|
|
||
|
def ready?
|
||
|
@status == 'running'
|
||
|
end
|
||
|
|
||
|
def reboot(type = 'SOFT')
|
||
|
requires :id
|
||
|
connection.reboot_block(@id, type)
|
||
|
true
|
||
|
end
|
||
|
|
||
|
def save
|
||
|
requires :flavor_id, :image_id, :name, :password
|
||
|
data = connection.create_block(@flavor_id, @image_id, @name, @password)
|
||
|
merge_attributes(data.body)
|
||
|
true
|
||
|
end
|
||
|
end
|
||
|
|
||
|
end
|
||
|
end
|