1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Add new request methods to server object.

This commit is contained in:
Sean Handley 2012-07-15 13:40:03 +02:00
parent b670d5e719
commit c74e39d9a8
2 changed files with 32 additions and 5 deletions

View file

@ -20,6 +20,14 @@ module Fog
# Server
request :get_servers
request :get_server
request :destroy_server
request :create_server
request :update_server
request :start_server
request :stop_server
request :shutdown_server
request :reset_server
model_path 'fog/serverlove/models/compute'

View file

@ -6,22 +6,41 @@ module Fog
class Server < Fog::Model
identity :server
identity :id, :aliases => 'server'
attribute :server
attribute :name
attribute :cpu
attribute :persistent
attribute :vnc_password, :aliases => 'vnc:password'
attribute :status
attribute :user
attribute :started
def save
# TODO
attributes = {}
if(identity)
attributes = connection.update_server(identity, allowed_attributes).body
else
requires :name
requires :cpu
attributes = connection.create_server(allowed_attributes).body
end
merge_attributes(attributes)
self
end
def destroy
requires :identity
connection.destroy_server(identity)
true
end
self
end
def allowed_attributes
allowed = [:name, :cpu, :persistent, :vnc_password]
attributes.select {|k,v| allowed.include? k}
end
end
end
end