2010-03-17 20:51:55 -07:00
|
|
|
require 'fog/model'
|
|
|
|
|
2010-02-04 00:27:14 -08:00
|
|
|
module Fog
|
2010-03-17 20:51:55 -07:00
|
|
|
module Slicehost
|
2010-02-04 00:27:14 -08:00
|
|
|
|
|
|
|
class Server < Fog::Model
|
|
|
|
|
|
|
|
identity :id
|
|
|
|
|
|
|
|
attribute :addresses
|
2010-02-06 15:39:14 -08:00
|
|
|
attribute :backup_id, 'backup-id'
|
|
|
|
attribute :bandwidth_in, 'bw-in'
|
|
|
|
attribute :bandwidth_out, 'bw-out'
|
|
|
|
attribute :flavor_id, 'flavor-id'
|
|
|
|
attribute :image_id, 'image-id'
|
2010-02-04 00:27:14 -08:00
|
|
|
attribute :name
|
2010-02-06 15:39:14 -08:00
|
|
|
attribute :password, 'root-password'
|
2010-02-04 00:27:14 -08:00
|
|
|
attribute :progress
|
|
|
|
attribute :status
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
requires :id
|
|
|
|
connection.delete_slice(@id)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2010-02-06 15:39:14 -08:00
|
|
|
def flavor
|
|
|
|
requires :flavor_id
|
|
|
|
connection.flavors.get(@flavor_id)
|
|
|
|
end
|
2010-02-04 00:27:14 -08:00
|
|
|
|
2010-02-06 15:39:14 -08:00
|
|
|
def image
|
|
|
|
requires :image_id
|
|
|
|
connection.images.get(@image_id)
|
|
|
|
end
|
2010-02-04 00:27:14 -08:00
|
|
|
|
|
|
|
def ready?
|
|
|
|
@status == 'active'
|
|
|
|
end
|
|
|
|
|
2010-02-06 14:51:19 -08:00
|
|
|
def reboot(type = 'SOFT')
|
|
|
|
requires :id
|
|
|
|
connection.reboot_server(@id, type)
|
|
|
|
true
|
|
|
|
end
|
2010-02-04 00:27:14 -08:00
|
|
|
|
|
|
|
def save
|
|
|
|
requires :flavor_id, :image_id, :name
|
|
|
|
data = connection.create_slice(@flavor_id, @image_id, @name)
|
|
|
|
merge_attributes(data.body)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|