2009-10-15 01:03:16 -04:00
|
|
|
module Fog
|
|
|
|
module Rackspace
|
|
|
|
class Server
|
|
|
|
|
|
|
|
class Server < Fog::Model
|
|
|
|
|
|
|
|
attribute :admin_pass, 'adminPass'
|
|
|
|
attribute :id
|
|
|
|
attribute :name
|
|
|
|
attribute :image_id, 'imageId'
|
|
|
|
attribute :flavor_id, 'flavorId'
|
|
|
|
attribute :host_id, 'hostId'
|
|
|
|
attribute :status
|
|
|
|
attribute :personality
|
|
|
|
attribute :progress
|
|
|
|
attribute :addresses
|
|
|
|
attribute :metadata
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
connection.delete_server(@id)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def reload
|
|
|
|
new_attributes = servers.get(@id).attributes
|
|
|
|
merge_attributes(new_attributes)
|
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
2009-10-15 18:06:50 -04:00
|
|
|
options = { :metadata => @metadata, :name => @name, :personality => @personality }
|
|
|
|
options = options.reject {|key, value| value.nil?}
|
|
|
|
data = connection.create_server(@flavor_id, @image_id, options)
|
2009-10-15 01:03:16 -04:00
|
|
|
merge_attributes(data.body['server'])
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def servers
|
|
|
|
@servers
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def servers=(new_servers)
|
|
|
|
@servers = new_servers
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|