diff --git a/lib/fog/serverlove/compute.rb b/lib/fog/serverlove/compute.rb index e2a1e4c59..5b7c97bb1 100644 --- a/lib/fog/serverlove/compute.rb +++ b/lib/fog/serverlove/compute.rb @@ -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' diff --git a/lib/fog/serverlove/models/compute/server.rb b/lib/fog/serverlove/models/compute/server.rb index cabb28875..03e10cba9 100644 --- a/lib/fog/serverlove/models/compute/server.rb +++ b/lib/fog/serverlove/models/compute/server.rb @@ -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