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/rackspace/models/servers/server.rb

65 lines
1.4 KiB
Ruby
Raw Normal View History

module Fog
module Rackspace
2009-10-15 18:42:25 -04:00
class Servers
class Server < Fog::Model
identity :id
attribute :addresses
attribute :password, 'adminPass'
attribute :flavor_id, 'flavorId'
attribute :host_id, 'hostId'
attribute :image_id, 'imageId'
attribute :metadata
attribute :name
attribute :personality
attribute :progress
attribute :status
def destroy
requires :id
connection.delete_server(@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 images
requires :id
connection.images(:server => self)
end
def ready?
@status == 'ACTIVE'
end
def reboot(type = 'SOFT')
requires :id
connection.reboot_server(@id, type)
true
end
def save
requires :flavor_id, :image_id, :name
options = { 'metadata' => @metadata, 'personality' => @personality }
2009-10-15 18:06:50 -04:00
options = options.reject {|key, value| value.nil?}
data = connection.create_server(@flavor_id, @image_id, @name, options)
merge_attributes(data.body['server'])
true
end
end
end
end
end