From 873d969d9c1d57c3ac650f659b2468c29e00f8f4 Mon Sep 17 00:00:00 2001 From: James Rose Date: Fri, 22 Jun 2012 11:03:29 +0100 Subject: [PATCH] Merge changes. Begin server definitions. --- lib/fog/serverlove/compute.rb | 7 +++- lib/fog/serverlove/models/compute/drive.rb | 34 ------------------- lib/fog/serverlove/models/compute/server.rb | 28 +++++++++++++++ lib/fog/serverlove/models/compute/servers.rb | 25 ++++++++++++++ .../serverlove/requests/compute/get_server.rb | 13 +++++++ .../requests/compute/get_servers.rb | 13 +++++++ 6 files changed, 85 insertions(+), 35 deletions(-) delete mode 100644 lib/fog/serverlove/models/compute/drive.rb create mode 100644 lib/fog/serverlove/models/compute/server.rb create mode 100644 lib/fog/serverlove/models/compute/servers.rb create mode 100644 lib/fog/serverlove/requests/compute/get_server.rb create mode 100644 lib/fog/serverlove/requests/compute/get_servers.rb diff --git a/lib/fog/serverlove/compute.rb b/lib/fog/serverlove/compute.rb index c9fa8df0a..cb4069564 100644 --- a/lib/fog/serverlove/compute.rb +++ b/lib/fog/serverlove/compute.rb @@ -15,10 +15,14 @@ module Fog request :create_image request :update_image - model_path 'fog/serverlove/models/compute' model :image collection :images + + request :get_servers + model :server + collection :servers + class Mock def initialize(options) @@ -64,6 +68,7 @@ module Fog end.join("\n") end + # TODO def raise_if_error!(response) case response.status when 400 then diff --git a/lib/fog/serverlove/models/compute/drive.rb b/lib/fog/serverlove/models/compute/drive.rb deleted file mode 100644 index b9fab6574..000000000 --- a/lib/fog/serverlove/models/compute/drive.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'fog/core/model' - -module Fog - module Compute - class Serverlove - - class Drive < Fog::Model - - identity :drive - - attribute :name - attribute :user - attribute :size - attribute :claimed - attribute :status - attribute :encryption_cipher, :aliases => 'encryption:cipher' - - def save - - end - - def destroy - requires :identity - connection.destroy_drive(identity) - self - end - - def self.create(args) - - end - end - end - end -end diff --git a/lib/fog/serverlove/models/compute/server.rb b/lib/fog/serverlove/models/compute/server.rb new file mode 100644 index 000000000..cabb28875 --- /dev/null +++ b/lib/fog/serverlove/models/compute/server.rb @@ -0,0 +1,28 @@ +require 'fog/core/model' + +module Fog + module Compute + class Serverlove + + class Server < Fog::Model + + identity :server + + attribute :server + attribute :status + attribute :user + attribute :started + + def save + # TODO + end + + def destroy + requires :identity + connection.destroy_server(identity) + true + end + end + end + end +end diff --git a/lib/fog/serverlove/models/compute/servers.rb b/lib/fog/serverlove/models/compute/servers.rb new file mode 100644 index 000000000..096526fc0 --- /dev/null +++ b/lib/fog/serverlove/models/compute/servers.rb @@ -0,0 +1,25 @@ +require 'fog/core/collection' +require 'fog/serverlove/models/compute/drive' + +module Fog + module Compute + class Serverlove + + class Servers < Fog::Collection + + model Fog::Compute::Serverlove::Server + + def all + data = connection.get_servers.body + load(data) + end + + def get(server_id) + load(connection.get_drive(server_id).body) + end + + end + + end + end +end diff --git a/lib/fog/serverlove/requests/compute/get_server.rb b/lib/fog/serverlove/requests/compute/get_server.rb new file mode 100644 index 000000000..219ff8bb8 --- /dev/null +++ b/lib/fog/serverlove/requests/compute/get_server.rb @@ -0,0 +1,13 @@ +module Fog + module Compute + class Serverlove + class Real + + def get_server(server_id) + request(:method => "get", :path => "/servers/#{server_id}/info", :expects => 200) + end + + end + end + end +end \ No newline at end of file diff --git a/lib/fog/serverlove/requests/compute/get_servers.rb b/lib/fog/serverlove/requests/compute/get_servers.rb new file mode 100644 index 000000000..19d9bf387 --- /dev/null +++ b/lib/fog/serverlove/requests/compute/get_servers.rb @@ -0,0 +1,13 @@ +module Fog + module Compute + class Serverlove + class Real + + def get_servers + request(:method => "get", :path => "/servers/info", :expects => 200) + end + + end + end + end +end \ No newline at end of file