From 136442206f257ee0a739d2465ff97842d4dec059 Mon Sep 17 00:00:00 2001 From: geemus Date: Wed, 8 Sep 2010 15:00:47 -0700 Subject: [PATCH] [slicehost] rename slices to compute for consistency --- lib/fog/slicehost.rb | 93 ++----------------- lib/fog/slicehost/bin.rb | 14 ++- lib/fog/slicehost/compute.rb | 93 +++++++++++++++++++ lib/fog/slicehost/models/compute/flavor.rb | 45 +++++++++ lib/fog/slicehost/models/compute/flavors.rb | 27 ++++++ lib/fog/slicehost/models/compute/image.rb | 17 ++++ lib/fog/slicehost/models/compute/images.rb | 27 ++++++ lib/fog/slicehost/models/compute/server.rb | 64 +++++++++++++ lib/fog/slicehost/models/compute/servers.rb | 31 +++++++ lib/fog/slicehost/models/flavor.rb | 43 --------- lib/fog/slicehost/models/flavors.rb | 25 ----- lib/fog/slicehost/models/image.rb | 15 --- lib/fog/slicehost/models/images.rb | 25 ----- lib/fog/slicehost/models/server.rb | 62 ------------- lib/fog/slicehost/models/servers.rb | 29 ------ .../slicehost/parsers/compute/create_slice.rb | 31 +++++++ .../slicehost/parsers/compute/get_backups.rb | 32 +++++++ .../slicehost/parsers/compute/get_flavor.rb | 26 ++++++ .../slicehost/parsers/compute/get_flavors.rb | 30 ++++++ .../slicehost/parsers/compute/get_image.rb | 26 ++++++ .../slicehost/parsers/compute/get_images.rb | 30 ++++++ .../slicehost/parsers/compute/get_slice.rb | 31 +++++++ .../slicehost/parsers/compute/get_slices.rb | 35 +++++++ lib/fog/slicehost/parsers/create_slice.rb | 29 ------ lib/fog/slicehost/parsers/get_backups.rb | 30 ------ lib/fog/slicehost/parsers/get_flavor.rb | 24 ----- lib/fog/slicehost/parsers/get_flavors.rb | 28 ------ lib/fog/slicehost/parsers/get_image.rb | 24 ----- lib/fog/slicehost/parsers/get_images.rb | 28 ------ lib/fog/slicehost/parsers/get_slice.rb | 29 ------ lib/fog/slicehost/parsers/get_slices.rb | 33 ------- .../requests/compute/create_slice.rb | 49 ++++++++++ .../requests/compute/delete_slice.rb | 45 +++++++++ .../slicehost/requests/compute/get_backups.rb | 37 ++++++++ .../slicehost/requests/compute/get_flavor.rb | 40 ++++++++ .../slicehost/requests/compute/get_flavors.rb | 37 ++++++++ .../slicehost/requests/compute/get_image.rb | 38 ++++++++ .../slicehost/requests/compute/get_images.rb | 35 +++++++ .../slicehost/requests/compute/get_slice.rb | 46 +++++++++ .../slicehost/requests/compute/get_slices.rb | 43 +++++++++ .../requests/compute/reboot_slice.rb | 44 +++++++++ lib/fog/slicehost/requests/create_slice.rb | 47 ---------- lib/fog/slicehost/requests/delete_slice.rb | 43 --------- lib/fog/slicehost/requests/get_backups.rb | 35 ------- lib/fog/slicehost/requests/get_flavor.rb | 38 -------- lib/fog/slicehost/requests/get_flavors.rb | 35 ------- lib/fog/slicehost/requests/get_image.rb | 36 ------- lib/fog/slicehost/requests/get_images.rb | 33 ------- lib/fog/slicehost/requests/get_slice.rb | 44 --------- lib/fog/slicehost/requests/get_slices.rb | 41 -------- lib/fog/slicehost/requests/reboot_slice.rb | 42 --------- 51 files changed, 979 insertions(+), 905 deletions(-) create mode 100644 lib/fog/slicehost/compute.rb create mode 100644 lib/fog/slicehost/models/compute/flavor.rb create mode 100644 lib/fog/slicehost/models/compute/flavors.rb create mode 100644 lib/fog/slicehost/models/compute/image.rb create mode 100644 lib/fog/slicehost/models/compute/images.rb create mode 100644 lib/fog/slicehost/models/compute/server.rb create mode 100644 lib/fog/slicehost/models/compute/servers.rb delete mode 100644 lib/fog/slicehost/models/flavor.rb delete mode 100644 lib/fog/slicehost/models/flavors.rb delete mode 100644 lib/fog/slicehost/models/image.rb delete mode 100644 lib/fog/slicehost/models/images.rb delete mode 100644 lib/fog/slicehost/models/server.rb delete mode 100644 lib/fog/slicehost/models/servers.rb create mode 100644 lib/fog/slicehost/parsers/compute/create_slice.rb create mode 100644 lib/fog/slicehost/parsers/compute/get_backups.rb create mode 100644 lib/fog/slicehost/parsers/compute/get_flavor.rb create mode 100644 lib/fog/slicehost/parsers/compute/get_flavors.rb create mode 100644 lib/fog/slicehost/parsers/compute/get_image.rb create mode 100644 lib/fog/slicehost/parsers/compute/get_images.rb create mode 100644 lib/fog/slicehost/parsers/compute/get_slice.rb create mode 100644 lib/fog/slicehost/parsers/compute/get_slices.rb delete mode 100644 lib/fog/slicehost/parsers/create_slice.rb delete mode 100644 lib/fog/slicehost/parsers/get_backups.rb delete mode 100644 lib/fog/slicehost/parsers/get_flavor.rb delete mode 100644 lib/fog/slicehost/parsers/get_flavors.rb delete mode 100644 lib/fog/slicehost/parsers/get_image.rb delete mode 100644 lib/fog/slicehost/parsers/get_images.rb delete mode 100644 lib/fog/slicehost/parsers/get_slice.rb delete mode 100644 lib/fog/slicehost/parsers/get_slices.rb create mode 100644 lib/fog/slicehost/requests/compute/create_slice.rb create mode 100644 lib/fog/slicehost/requests/compute/delete_slice.rb create mode 100644 lib/fog/slicehost/requests/compute/get_backups.rb create mode 100644 lib/fog/slicehost/requests/compute/get_flavor.rb create mode 100644 lib/fog/slicehost/requests/compute/get_flavors.rb create mode 100644 lib/fog/slicehost/requests/compute/get_image.rb create mode 100644 lib/fog/slicehost/requests/compute/get_images.rb create mode 100644 lib/fog/slicehost/requests/compute/get_slice.rb create mode 100644 lib/fog/slicehost/requests/compute/get_slices.rb create mode 100644 lib/fog/slicehost/requests/compute/reboot_slice.rb delete mode 100644 lib/fog/slicehost/requests/create_slice.rb delete mode 100644 lib/fog/slicehost/requests/delete_slice.rb delete mode 100644 lib/fog/slicehost/requests/get_backups.rb delete mode 100644 lib/fog/slicehost/requests/get_flavor.rb delete mode 100644 lib/fog/slicehost/requests/get_flavors.rb delete mode 100644 lib/fog/slicehost/requests/get_image.rb delete mode 100644 lib/fog/slicehost/requests/get_images.rb delete mode 100644 lib/fog/slicehost/requests/get_slice.rb delete mode 100644 lib/fog/slicehost/requests/get_slices.rb delete mode 100644 lib/fog/slicehost/requests/reboot_slice.rb diff --git a/lib/fog/slicehost.rb b/lib/fog/slicehost.rb index 9a2c4d729..26eb78097 100644 --- a/lib/fog/slicehost.rb +++ b/lib/fog/slicehost.rb @@ -1,91 +1,18 @@ module Fog - class Slicehost < Fog::Service + module Slicehost - requires :slicehost_password + extend Fog::Provider - model_path 'fog/slicehost/models' - model :flavor - collection :flavors - model :image - collection :images - model :server - collection :servers - - request_path 'fog/slicehost/requests' - request :create_slice - request :delete_slice - request :get_backups - request :get_flavor - request :get_flavors - request :get_image - request :get_images - request :get_slice - request :get_slices - request :reboot_slice - - class Mock - include Collections - - def self.data - @data ||= Hash.new do |hash, key| - hash[key] = {} - end - end - - def self.reset_data(keys=data.keys) - for key in [*keys] - data.delete(key) - end - end - - def initialize(options={}) - @slicehost_password = options[:slicehost_password] - @data = self.class.data[@slicehost_password] - end + service_path 'fog/slicehost' + service :compute + def self.new(attributes = {}) + location = caller.first + warning = "[yellow][WARN] Fog::Slicehost#new is deprecated, use Fog::Bluebox::Compute#new instead[/]" + warning << " [light_black](" << location << ")[/] " + Formatador.display_line(warning) + Fog::Slicehost::Compute.new(attributes) end - class Real - include Collections - - def initialize(options={}) - @slicehost_password = options[:slicehost_password] - @host = options[:host] || "api.slicehost.com" - @port = options[:port] || 443 - @scheme = options[:scheme] || 'https' - @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent]) - end - - def reload - @connection.reset - end - - def request(params) - params[:headers] ||= {} - params[:headers].merge!({ - 'Authorization' => "Basic #{Base64.encode64(@slicehost_password).delete("\r\n")}" - }) - case params[:method] - when 'DELETE', 'GET', 'HEAD' - params[:headers]['Accept'] = 'application/xml' - when 'POST', 'PUT' - params[:headers]['Content-Type'] = 'application/xml' - end - - begin - response = @connection.request(params.merge!({:host => @host})) - rescue Excon::Errors::Error => error - raise case error - when Excon::Errors::NotFound - Fog::Slicehost::NotFound.slurp(error) - else - error - end - end - - response - end - - end end end diff --git a/lib/fog/slicehost/bin.rb b/lib/fog/slicehost/bin.rb index 7df93b21d..599facbd4 100644 --- a/lib/fog/slicehost/bin.rb +++ b/lib/fog/slicehost/bin.rb @@ -9,21 +9,27 @@ module Slicehost def [](service) @@connections ||= Hash.new do |hash, key| hash[key] = case key + when :compute + Fog::Slicehost::Compute.new when :slices - Fog::Slicehost.new + location = caller.first + warning = "[yellow][WARN] Slicehost[:blocks] is deprecated, use Bluebox[:compute] instead[/]" + warning << " [light_black](" << location << ")[/] " + Formatador.display_line(warning) + Fog::Slicehost::Compute.new end end @@connections[service] end def services - [:slices] + [:compute] end - for collection in Fog::Slicehost.collections + for collection in Fog::Slicehost::Compute.collections module_eval <<-EOS, __FILE__, __LINE__ def #{collection} - self[:slices].#{collection} + self[:compute].#{collection} end EOS end diff --git a/lib/fog/slicehost/compute.rb b/lib/fog/slicehost/compute.rb new file mode 100644 index 000000000..80e5e98bd --- /dev/null +++ b/lib/fog/slicehost/compute.rb @@ -0,0 +1,93 @@ +module Fog + module Slicehost + class Compute < Fog::Service + + requires :slicehost_password + + model_path 'fog/slicehost/models/compute' + model :flavor + collection :flavors + model :image + collection :images + model :server + collection :servers + + request_path 'fog/slicehost/requests/compute' + request :create_slice + request :delete_slice + request :get_backups + request :get_flavor + request :get_flavors + request :get_image + request :get_images + request :get_slice + request :get_slices + request :reboot_slice + + class Mock + include Collections + + def self.data + @data ||= Hash.new do |hash, key| + hash[key] = {} + end + end + + def self.reset_data(keys=data.keys) + for key in [*keys] + data.delete(key) + end + end + + def initialize(options={}) + @slicehost_password = options[:slicehost_password] + @data = self.class.data[@slicehost_password] + end + + end + + class Real + include Collections + + def initialize(options={}) + @slicehost_password = options[:slicehost_password] + @host = options[:host] || "api.slicehost.com" + @port = options[:port] || 443 + @scheme = options[:scheme] || 'https' + @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent]) + end + + def reload + @connection.reset + end + + def request(params) + params[:headers] ||= {} + params[:headers].merge!({ + 'Authorization' => "Basic #{Base64.encode64(@slicehost_password).delete("\r\n")}" + }) + case params[:method] + when 'DELETE', 'GET', 'HEAD' + params[:headers]['Accept'] = 'application/xml' + when 'POST', 'PUT' + params[:headers]['Content-Type'] = 'application/xml' + end + + begin + response = @connection.request(params.merge!({:host => @host})) + rescue Excon::Errors::Error => error + raise case error + when Excon::Errors::NotFound + Fog::Slicehost::NotFound.slurp(error) + else + error + end + end + + response + end + + end + end + end +end diff --git a/lib/fog/slicehost/models/compute/flavor.rb b/lib/fog/slicehost/models/compute/flavor.rb new file mode 100644 index 000000000..c73811435 --- /dev/null +++ b/lib/fog/slicehost/models/compute/flavor.rb @@ -0,0 +1,45 @@ +require 'fog/model' + +module Fog + module Slicehost + class Compute + + class Flavor < Fog::Model + + identity :id + + attribute :name + attribute :price + attribute :ram + + def bits + # 64 + raise StandardError.new("Figure me out!?!") + end + + def cores + # # 2 quad-cores >= 2Ghz = 8 cores + # 8 * case ram + # when 256 + # 1/64.0 + # when 512 + # 1/32.0 + # when 1024 + # 1/16.0 + # when 2048 + # 1/8.0 + # when 4096 + # 1/4.0 + # when 8192 + # 1/2.0 + # when 15872 + # 1 + # end + raise StandardError.new("Figure me out!?!") + end + + end + + end + end +end diff --git a/lib/fog/slicehost/models/compute/flavors.rb b/lib/fog/slicehost/models/compute/flavors.rb new file mode 100644 index 000000000..acd94bc76 --- /dev/null +++ b/lib/fog/slicehost/models/compute/flavors.rb @@ -0,0 +1,27 @@ +require 'fog/collection' +require 'fog/slicehost/models/flavor' + +module Fog + module Slicehost + class Compute + + class Flavors < Fog::Collection + + model Fog::Slicehost::Flavor + + def all + data = connection.get_flavors.body['flavors'] + load(data) + end + + def get(flavor_id) + connection.get_flavor(flavor_id) + rescue Excon::Errors::Forbidden + nil + end + + end + + end + end +end diff --git a/lib/fog/slicehost/models/compute/image.rb b/lib/fog/slicehost/models/compute/image.rb new file mode 100644 index 000000000..ec7111a03 --- /dev/null +++ b/lib/fog/slicehost/models/compute/image.rb @@ -0,0 +1,17 @@ +require 'fog/model' + +module Fog + module Slicehost + class Compute + + class Image < Fog::Model + + identity :id + + attribute :name + + end + + end + end +end diff --git a/lib/fog/slicehost/models/compute/images.rb b/lib/fog/slicehost/models/compute/images.rb new file mode 100644 index 000000000..0db534f74 --- /dev/null +++ b/lib/fog/slicehost/models/compute/images.rb @@ -0,0 +1,27 @@ +require 'fog/collection' +require 'fog/slicehost/models/image' + +module Fog + module Slicehost + class Compute + + class Images < Fog::Collection + + model Fog::Slicehost::Image + + def all + data = connection.get_images.body['images'] + load(data) + end + + def get(image_id) + connection.get_image(image_id) + rescue Excon::Errors::Forbidden + nil + end + + end + + end + end +end diff --git a/lib/fog/slicehost/models/compute/server.rb b/lib/fog/slicehost/models/compute/server.rb new file mode 100644 index 000000000..b30e6d9fa --- /dev/null +++ b/lib/fog/slicehost/models/compute/server.rb @@ -0,0 +1,64 @@ +require 'fog/model' + +module Fog + module Slicehost + class Compute + + class Server < Fog::Model + + identity :id + + attribute :addresses + attribute :backup_id, :aliases => 'backup-id' + attribute :bandwidth_in, :aliases => 'bw-in' + attribute :bandwidth_out, :aliases => 'bw-out' + attribute :flavor_id, :aliases => 'flavor-id' + attribute :image_id, :aliases => 'image-id' + attribute :name + attribute :password, :aliases => 'root-password' + attribute :progress + attribute :status + + def initialize(attributes={}) + @flavor_id ||= 1 + super + end + + def destroy + requires :id + connection.delete_slice(@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 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 + data = connection.create_slice(@flavor_id, @image_id, @name) + merge_attributes(data.body) + true + end + + end + + end + end +end diff --git a/lib/fog/slicehost/models/compute/servers.rb b/lib/fog/slicehost/models/compute/servers.rb new file mode 100644 index 000000000..9f50c4b07 --- /dev/null +++ b/lib/fog/slicehost/models/compute/servers.rb @@ -0,0 +1,31 @@ +require 'fog/collection' +require 'fog/slicehost/models/server' + +module Fog + module Slicehost + class Compute + + class Servers < Fog::Collection + + model Fog::Slicehost::Server + + def all + data = connection.get_slices.body['slices'] + load(data) + end + + def get(server_id) + if server_id && server = connection.get_slice(server_id).body + new(server) + elsif !server_id + nil + end + rescue Excon::Errors::Forbidden + nil + end + + end + + end + end +end diff --git a/lib/fog/slicehost/models/flavor.rb b/lib/fog/slicehost/models/flavor.rb deleted file mode 100644 index 6185cab4f..000000000 --- a/lib/fog/slicehost/models/flavor.rb +++ /dev/null @@ -1,43 +0,0 @@ -require 'fog/model' - -module Fog - class Slicehost - - class Flavor < Fog::Model - - identity :id - - attribute :name - attribute :price - attribute :ram - - def bits - # 64 - raise StandardError.new("Figure me out!?!") - end - - def cores - # # 2 quad-cores >= 2Ghz = 8 cores - # 8 * case ram - # when 256 - # 1/64.0 - # when 512 - # 1/32.0 - # when 1024 - # 1/16.0 - # when 2048 - # 1/8.0 - # when 4096 - # 1/4.0 - # when 8192 - # 1/2.0 - # when 15872 - # 1 - # end - raise StandardError.new("Figure me out!?!") - end - - end - - end -end diff --git a/lib/fog/slicehost/models/flavors.rb b/lib/fog/slicehost/models/flavors.rb deleted file mode 100644 index d7d804286..000000000 --- a/lib/fog/slicehost/models/flavors.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'fog/collection' -require 'fog/slicehost/models/flavor' - -module Fog - class Slicehost - - class Flavors < Fog::Collection - - model Fog::Slicehost::Flavor - - def all - data = connection.get_flavors.body['flavors'] - load(data) - end - - def get(flavor_id) - connection.get_flavor(flavor_id) - rescue Excon::Errors::Forbidden - nil - end - - end - - end -end diff --git a/lib/fog/slicehost/models/image.rb b/lib/fog/slicehost/models/image.rb deleted file mode 100644 index 717303f81..000000000 --- a/lib/fog/slicehost/models/image.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'fog/model' - -module Fog - class Slicehost - - class Image < Fog::Model - - identity :id - - attribute :name - - end - - end -end diff --git a/lib/fog/slicehost/models/images.rb b/lib/fog/slicehost/models/images.rb deleted file mode 100644 index ef9a3d460..000000000 --- a/lib/fog/slicehost/models/images.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'fog/collection' -require 'fog/slicehost/models/image' - -module Fog - class Slicehost - - class Images < Fog::Collection - - model Fog::Slicehost::Image - - def all - data = connection.get_images.body['images'] - load(data) - end - - def get(image_id) - connection.get_image(image_id) - rescue Excon::Errors::Forbidden - nil - end - - end - - end -end diff --git a/lib/fog/slicehost/models/server.rb b/lib/fog/slicehost/models/server.rb deleted file mode 100644 index d0b773acf..000000000 --- a/lib/fog/slicehost/models/server.rb +++ /dev/null @@ -1,62 +0,0 @@ -require 'fog/model' - -module Fog - class Slicehost - - class Server < Fog::Model - - identity :id - - attribute :addresses - attribute :backup_id, :aliases => 'backup-id' - attribute :bandwidth_in, :aliases => 'bw-in' - attribute :bandwidth_out, :aliases => 'bw-out' - attribute :flavor_id, :aliases => 'flavor-id' - attribute :image_id, :aliases => 'image-id' - attribute :name - attribute :password, :aliases => 'root-password' - attribute :progress - attribute :status - - def initialize(attributes={}) - @flavor_id ||= 1 - super - end - - def destroy - requires :id - connection.delete_slice(@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 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 - data = connection.create_slice(@flavor_id, @image_id, @name) - merge_attributes(data.body) - true - end - - end - - end -end diff --git a/lib/fog/slicehost/models/servers.rb b/lib/fog/slicehost/models/servers.rb deleted file mode 100644 index eb3006634..000000000 --- a/lib/fog/slicehost/models/servers.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'fog/collection' -require 'fog/slicehost/models/server' - -module Fog - class Slicehost - - class Servers < Fog::Collection - - model Fog::Slicehost::Server - - def all - data = connection.get_slices.body['slices'] - load(data) - end - - def get(server_id) - if server_id && server = connection.get_slice(server_id).body - new(server) - elsif !server_id - nil - end - rescue Excon::Errors::Forbidden - nil - end - - end - - end -end diff --git a/lib/fog/slicehost/parsers/compute/create_slice.rb b/lib/fog/slicehost/parsers/compute/create_slice.rb new file mode 100644 index 000000000..99ed7170d --- /dev/null +++ b/lib/fog/slicehost/parsers/compute/create_slice.rb @@ -0,0 +1,31 @@ +module Fog + module Parsers + module Slicehost + module Compute + + class CreateSlice < Fog::Parsers::Base + + def reset + @response = {} + end + + def end_element(name) + case name + when 'address' + @response['addresses'] ||= [] + @response['addresses'] << @value + when 'backup-id', 'flavor-id', 'id', 'image-id', 'progress' + @response[name] = @value.to_i + when 'bw-in', 'bw-out' + @response[name] = @value.to_f + when 'name', 'root-password', 'status' + @response[name] = @value + end + end + + end + + end + end + end +end diff --git a/lib/fog/slicehost/parsers/compute/get_backups.rb b/lib/fog/slicehost/parsers/compute/get_backups.rb new file mode 100644 index 000000000..16a3af007 --- /dev/null +++ b/lib/fog/slicehost/parsers/compute/get_backups.rb @@ -0,0 +1,32 @@ +module Fog + module Parsers + module Slicehost + module Compute + + class GetBackups < Fog::Parsers::Base + + def reset + @backup = {} + @response = { 'backups' => [] } + end + + def end_element(name) + case name + when 'backup' + @response['backups'] << @backup + @backup = {} + when 'date' + @backup[name] = Time.parse(@value) + when 'id', 'slice-id' + @backup[name] = @value.to_i + when 'name' + @backup[name] = @value + end + end + + end + + end + end + end +end diff --git a/lib/fog/slicehost/parsers/compute/get_flavor.rb b/lib/fog/slicehost/parsers/compute/get_flavor.rb new file mode 100644 index 000000000..0d973d281 --- /dev/null +++ b/lib/fog/slicehost/parsers/compute/get_flavor.rb @@ -0,0 +1,26 @@ +module Fog + module Parsers + module Slicehost + module Compute + + class GetFlavor < Fog::Parsers::Base + + def reset + @response = {} + end + + def end_element(name) + case name + when 'id', 'price', 'ram' + @response[name] = @value.to_i + when 'name' + @response[name] = @value + end + end + + end + + end + end + end +end diff --git a/lib/fog/slicehost/parsers/compute/get_flavors.rb b/lib/fog/slicehost/parsers/compute/get_flavors.rb new file mode 100644 index 000000000..255d78bc4 --- /dev/null +++ b/lib/fog/slicehost/parsers/compute/get_flavors.rb @@ -0,0 +1,30 @@ +module Fog + module Parsers + module Slicehost + module Compute + + class GetFlavors < Fog::Parsers::Base + + def reset + @flavor = {} + @response = { 'flavors' => [] } + end + + def end_element(name) + case name + when 'flavor' + @response['flavors'] << @flavor + @flavor = {} + when 'id', 'price', 'ram' + @flavor[name] = @value.to_i + when 'name' + @flavor[name] = @value + end + end + + end + + end + end + end +end diff --git a/lib/fog/slicehost/parsers/compute/get_image.rb b/lib/fog/slicehost/parsers/compute/get_image.rb new file mode 100644 index 000000000..6f6218566 --- /dev/null +++ b/lib/fog/slicehost/parsers/compute/get_image.rb @@ -0,0 +1,26 @@ +module Fog + module Parsers + module Slicehost + module Compute + + class GetImage < Fog::Parsers::Base + + def reset + @response = {} + end + + def end_element(name) + case name + when 'id' + @response[name] = @value.to_i + when 'name' + @response[name] = @value + end + end + + end + + end + end + end +end diff --git a/lib/fog/slicehost/parsers/compute/get_images.rb b/lib/fog/slicehost/parsers/compute/get_images.rb new file mode 100644 index 000000000..b9997fec8 --- /dev/null +++ b/lib/fog/slicehost/parsers/compute/get_images.rb @@ -0,0 +1,30 @@ +module Fog + module Parsers + module Slicehost + module Compute + + class GetImages < Fog::Parsers::Base + + def reset + @image = {} + @response = { 'images' => [] } + end + + def end_element(name) + case name + when 'id' + @image[name] = @value.to_i + when 'image' + @response['images'] << @image + @image = {} + when 'name' + @image[name] = @value + end + end + + end + + end + end + end +end diff --git a/lib/fog/slicehost/parsers/compute/get_slice.rb b/lib/fog/slicehost/parsers/compute/get_slice.rb new file mode 100644 index 000000000..46e1cdd4c --- /dev/null +++ b/lib/fog/slicehost/parsers/compute/get_slice.rb @@ -0,0 +1,31 @@ +module Fog + module Parsers + module Slicehost + module Compute + + class GetSlice < Fog::Parsers::Base + + def reset + @response = {} + end + + def end_element(name) + case name + when 'address' + @response['addresses'] ||= [] + @response['addresses'] << @value + when 'backup-id', 'flavor-id', 'id', 'image-id', 'progress' + @response[name] = @value.to_i + when 'bw-in', 'bw-out' + @response[name] = @value.to_f + when 'name', 'status' + @response[name] = @value + end + end + + end + + end + end + end +end diff --git a/lib/fog/slicehost/parsers/compute/get_slices.rb b/lib/fog/slicehost/parsers/compute/get_slices.rb new file mode 100644 index 000000000..4dfa91993 --- /dev/null +++ b/lib/fog/slicehost/parsers/compute/get_slices.rb @@ -0,0 +1,35 @@ +module Fog + module Parsers + module Slicehost + module Compute + + class GetSlices < Fog::Parsers::Base + + def reset + @slice = {} + @response = { 'slices' => [] } + end + + def end_element(name) + case name + when 'address' + @slice['addresses'] ||= [] + @slice['addresses'] << @value + when 'backup-id', 'flavor-id', 'id', 'image-id', 'progress' + @slice[name] = @value.to_i + when 'bw-in', 'bw-out' + @slice[name] = @value.to_f + when 'name', 'status' + @slice[name] = @value + when 'slice' + @response['slices'] << @slice + @slice = {} + end + end + + end + + end + end + end +end diff --git a/lib/fog/slicehost/parsers/create_slice.rb b/lib/fog/slicehost/parsers/create_slice.rb deleted file mode 100644 index 88df466b3..000000000 --- a/lib/fog/slicehost/parsers/create_slice.rb +++ /dev/null @@ -1,29 +0,0 @@ -module Fog - module Parsers - module Slicehost - - class CreateSlice < Fog::Parsers::Base - - def reset - @response = {} - end - - def end_element(name) - case name - when 'address' - @response['addresses'] ||= [] - @response['addresses'] << @value - when 'backup-id', 'flavor-id', 'id', 'image-id', 'progress' - @response[name] = @value.to_i - when 'bw-in', 'bw-out' - @response[name] = @value.to_f - when 'name', 'root-password', 'status' - @response[name] = @value - end - end - - end - - end - end -end diff --git a/lib/fog/slicehost/parsers/get_backups.rb b/lib/fog/slicehost/parsers/get_backups.rb deleted file mode 100644 index b8a207788..000000000 --- a/lib/fog/slicehost/parsers/get_backups.rb +++ /dev/null @@ -1,30 +0,0 @@ -module Fog - module Parsers - module Slicehost - - class GetBackups < Fog::Parsers::Base - - def reset - @backup = {} - @response = { 'backups' => [] } - end - - def end_element(name) - case name - when 'backup' - @response['backups'] << @backup - @backup = {} - when 'date' - @backup[name] = Time.parse(@value) - when 'id', 'slice-id' - @backup[name] = @value.to_i - when 'name' - @backup[name] = @value - end - end - - end - - end - end -end diff --git a/lib/fog/slicehost/parsers/get_flavor.rb b/lib/fog/slicehost/parsers/get_flavor.rb deleted file mode 100644 index 7b9c6db7d..000000000 --- a/lib/fog/slicehost/parsers/get_flavor.rb +++ /dev/null @@ -1,24 +0,0 @@ -module Fog - module Parsers - module Slicehost - - class GetFlavor < Fog::Parsers::Base - - def reset - @response = {} - end - - def end_element(name) - case name - when 'id', 'price', 'ram' - @response[name] = @value.to_i - when 'name' - @response[name] = @value - end - end - - end - - end - end -end diff --git a/lib/fog/slicehost/parsers/get_flavors.rb b/lib/fog/slicehost/parsers/get_flavors.rb deleted file mode 100644 index d1dcb8747..000000000 --- a/lib/fog/slicehost/parsers/get_flavors.rb +++ /dev/null @@ -1,28 +0,0 @@ -module Fog - module Parsers - module Slicehost - - class GetFlavors < Fog::Parsers::Base - - def reset - @flavor = {} - @response = { 'flavors' => [] } - end - - def end_element(name) - case name - when 'flavor' - @response['flavors'] << @flavor - @flavor = {} - when 'id', 'price', 'ram' - @flavor[name] = @value.to_i - when 'name' - @flavor[name] = @value - end - end - - end - - end - end -end diff --git a/lib/fog/slicehost/parsers/get_image.rb b/lib/fog/slicehost/parsers/get_image.rb deleted file mode 100644 index 0bb8b263e..000000000 --- a/lib/fog/slicehost/parsers/get_image.rb +++ /dev/null @@ -1,24 +0,0 @@ -module Fog - module Parsers - module Slicehost - - class GetImage < Fog::Parsers::Base - - def reset - @response = {} - end - - def end_element(name) - case name - when 'id' - @response[name] = @value.to_i - when 'name' - @response[name] = @value - end - end - - end - - end - end -end diff --git a/lib/fog/slicehost/parsers/get_images.rb b/lib/fog/slicehost/parsers/get_images.rb deleted file mode 100644 index 9f15451a1..000000000 --- a/lib/fog/slicehost/parsers/get_images.rb +++ /dev/null @@ -1,28 +0,0 @@ -module Fog - module Parsers - module Slicehost - - class GetImages < Fog::Parsers::Base - - def reset - @image = {} - @response = { 'images' => [] } - end - - def end_element(name) - case name - when 'id' - @image[name] = @value.to_i - when 'image' - @response['images'] << @image - @image = {} - when 'name' - @image[name] = @value - end - end - - end - - end - end -end diff --git a/lib/fog/slicehost/parsers/get_slice.rb b/lib/fog/slicehost/parsers/get_slice.rb deleted file mode 100644 index 2cb5ad172..000000000 --- a/lib/fog/slicehost/parsers/get_slice.rb +++ /dev/null @@ -1,29 +0,0 @@ -module Fog - module Parsers - module Slicehost - - class GetSlice < Fog::Parsers::Base - - def reset - @response = {} - end - - def end_element(name) - case name - when 'address' - @response['addresses'] ||= [] - @response['addresses'] << @value - when 'backup-id', 'flavor-id', 'id', 'image-id', 'progress' - @response[name] = @value.to_i - when 'bw-in', 'bw-out' - @response[name] = @value.to_f - when 'name', 'status' - @response[name] = @value - end - end - - end - - end - end -end diff --git a/lib/fog/slicehost/parsers/get_slices.rb b/lib/fog/slicehost/parsers/get_slices.rb deleted file mode 100644 index e753e38b7..000000000 --- a/lib/fog/slicehost/parsers/get_slices.rb +++ /dev/null @@ -1,33 +0,0 @@ -module Fog - module Parsers - module Slicehost - - class GetSlices < Fog::Parsers::Base - - def reset - @slice = {} - @response = { 'slices' => [] } - end - - def end_element(name) - case name - when 'address' - @slice['addresses'] ||= [] - @slice['addresses'] << @value - when 'backup-id', 'flavor-id', 'id', 'image-id', 'progress' - @slice[name] = @value.to_i - when 'bw-in', 'bw-out' - @slice[name] = @value.to_f - when 'name', 'status' - @slice[name] = @value - when 'slice' - @response['slices'] << @slice - @slice = {} - end - end - - end - - end - end -end diff --git a/lib/fog/slicehost/requests/compute/create_slice.rb b/lib/fog/slicehost/requests/compute/create_slice.rb new file mode 100644 index 000000000..eb009bef6 --- /dev/null +++ b/lib/fog/slicehost/requests/compute/create_slice.rb @@ -0,0 +1,49 @@ +module Fog + module Slicehost + class Compute + class Real + + require 'fog/slicehost/parsers/compute/create_slice' + + # Get list of slices + # ==== Parameters + # * flavor_id<~Integer> - Id of flavor to create slice with + # * image_id<~Integer> - Id of image to create slice with + # * name<~String> - Name of slice + # + # ==== Returns + # * response<~Excon::Response>: + # * body<~Array>: + # * 'addresses'<~Array> - Ip addresses for the slice + # * 'backup-id'<~Integer> - Id of backup slice was booted from + # * 'bw-in'<~Integer> - Incoming bandwidth total for current billing cycle, in Gigabytes + # * 'bw-out'<~Integer> - Outgoing bandwidth total for current billing cycle, in Gigabytes + # * 'flavor-id'<~Integer> - Id of flavor slice was booted from + # * 'id'<~Integer> - Id of the slice + # * 'image-id'<~Integer> - Id of image slice was booted from + # * 'name'<~String> - Name of the slice + # * 'progress'<~Integer> - Progress of current action, in percentage + # * 'root-password'<~String> - Root password of slice + # * 'status'<~String> - Current status of the slice + def create_slice(flavor_id, image_id, name) + request( + :body => %Q{#{flavor_id}#{image_id}#{name}}, + :expects => 201, + :method => 'POST', + :parser => Fog::Parsers::Slicehost::Compute::CreateSlice.new, + :path => 'slices.xml' + ) + end + + end + + class Mock + + def create_slice(flavor_id, image_id, name) + Fog::Mock.not_implemented + end + + end + end + end +end diff --git a/lib/fog/slicehost/requests/compute/delete_slice.rb b/lib/fog/slicehost/requests/compute/delete_slice.rb new file mode 100644 index 000000000..548ee3602 --- /dev/null +++ b/lib/fog/slicehost/requests/compute/delete_slice.rb @@ -0,0 +1,45 @@ +module Fog + module Slicehost + class Compute + class Real + + # Get list of slices + # ==== Parameters + # * flavor_id<~Integer> - Id of flavor to create slice with + # * image_id<~Integer> - Id of image to create slice with + # * name<~String> - Name of slice + # + # ==== Returns + # * response<~Excon::Response>: + # * body<~Array>: + # * 'addresses'<~Array> - Ip addresses for the slice + # * 'backup-id'<~Integer> - Id of backup slice was booted from + # * 'bw-in'<~Integer> - Incoming bandwidth total for current billing cycle, in Gigabytes + # * 'bw-out'<~Integer> - Outgoing bandwidth total for current billing cycle, in Gigabytes + # * 'flavor-id'<~Integer> - Id of flavor slice was booted from + # * 'id'<~Integer> - Id of the slice + # * 'image-id'<~Integer> - Id of image slice was booted from + # * 'name'<~String> - Name of the slice + # * 'progress'<~Integer> - Progress of current action, in percentage + # * 'root-password'<~String> - Root password of slice + # * 'status'<~String> - Current status of the slice + def delete_slice(slice_id) + request( + :expects => 200, + :method => 'DELETE', + :path => "slices/#{slice_id}.xml" + ) + end + + end + + class Mock + + def delete_slice(slice_id) + Fog::Mock.not_implemented + end + + end + end + end +end diff --git a/lib/fog/slicehost/requests/compute/get_backups.rb b/lib/fog/slicehost/requests/compute/get_backups.rb new file mode 100644 index 000000000..518c26e35 --- /dev/null +++ b/lib/fog/slicehost/requests/compute/get_backups.rb @@ -0,0 +1,37 @@ +module Fog + module Slicehost + class Compute + class Real + + require 'fog/slicehost/parsers/compute/get_backups' + + # Get list of backups + # + # ==== Returns + # * response<~Excon::Response>: + # * body<~Array>: + # * 'date'<~Time> - Timestamp of backup creation + # * 'id'<~Integer> - Id of the backup + # * 'name'<~String> - Name of the backup + # * 'slice-id'<~Integer> - Id of slice the backup was made from + def get_backups + request( + :expects => 200, + :method => 'GET', + :parser => Fog::Parsers::Slicehost::Compute::GetBackups.new, + :path => 'backups.xml' + ) + end + + end + + class Mock + + def get_backups + Fog::Mock.not_implemented + end + + end + end + end +end diff --git a/lib/fog/slicehost/requests/compute/get_flavor.rb b/lib/fog/slicehost/requests/compute/get_flavor.rb new file mode 100644 index 000000000..ffedb5b4a --- /dev/null +++ b/lib/fog/slicehost/requests/compute/get_flavor.rb @@ -0,0 +1,40 @@ +module Fog + module Slicehost + class Compute + class Real + + require 'fog/slicehost/parsers/compute/get_flavor' + + # Get details of a flavor + # + # ==== Parameters + # * flavor_id<~Integer> - Id of flavor to lookup + # + # ==== Returns + # * response<~Excon::Response>: + # * body<~Array>: + # * 'id'<~Integer> - Id of the flavor + # * 'name'<~String> - Name of the flavor + # * 'price'<~Integer> - Price in cents + # * 'ram'<~Integer> - Amount of ram for the flavor + def get_flavor(flavor_id) + request( + :expects => 200, + :method => 'GET', + :parser => Fog::Parsers::Slicehost::Compute::GetFlavor.new, + :path => "flavors/#{flavor_id}.xml" + ) + end + + end + + class Mock + + def get_flavor(flavor_id) + Fog::Mock.not_implemented + end + + end + end + end +end diff --git a/lib/fog/slicehost/requests/compute/get_flavors.rb b/lib/fog/slicehost/requests/compute/get_flavors.rb new file mode 100644 index 000000000..5e8122ed9 --- /dev/null +++ b/lib/fog/slicehost/requests/compute/get_flavors.rb @@ -0,0 +1,37 @@ +module Fog + module Slicehost + class Compute + class Real + + require 'fog/slicehost/parsers/compute/get_flavors' + + # Get list of flavors + # + # ==== Returns + # * response<~Excon::Response>: + # * body<~Array>: + # * 'id'<~Integer> - Id of the flavor + # * 'name'<~String> - Name of the flavor + # * 'price'<~Integer> - Price in cents + # * 'ram'<~Integer> - Amount of ram for the flavor + def get_flavors + request( + :expects => 200, + :method => 'GET', + :parser => Fog::Parsers::Slicehost::Compute::GetFlavors.new, + :path => 'flavors.xml' + ) + end + + end + + class Mock + + def get_flavors + Fog::Mock.not_implemented + end + + end + end + end +end diff --git a/lib/fog/slicehost/requests/compute/get_image.rb b/lib/fog/slicehost/requests/compute/get_image.rb new file mode 100644 index 000000000..366c71f0a --- /dev/null +++ b/lib/fog/slicehost/requests/compute/get_image.rb @@ -0,0 +1,38 @@ +module Fog + module Slicehost + class Compute + class Real + + require 'fog/slicehost/parsers/compute/get_image' + + # Get details of an image + # + # ==== Parameters + # * image_id<~Integer> - Id of image to lookup + # + # ==== Returns + # * response<~Excon::Response>: + # * body<~Array>: + # * 'id'<~Integer> - Id of the image + # * 'name'<~String> - Name of the image + def get_image(image_id) + request( + :expects => 200, + :method => 'GET', + :parser => Fog::Parsers::Slicehost::Compute::GetImage.new, + :path => "images/#{image_id}.xml" + ) + end + + end + + class Mock + + def get_image(image_id) + Fog::Mock.not_implemented + end + + end + end + end +end diff --git a/lib/fog/slicehost/requests/compute/get_images.rb b/lib/fog/slicehost/requests/compute/get_images.rb new file mode 100644 index 000000000..8b7208444 --- /dev/null +++ b/lib/fog/slicehost/requests/compute/get_images.rb @@ -0,0 +1,35 @@ +module Fog + module Slicehost + class Compute + class Real + + require 'fog/slicehost/parsers/compute/get_images' + + # Get list of images + # + # ==== Returns + # * response<~Excon::Response>: + # * body<~Array>: + # * 'id'<~Integer> - Id of the image + # * 'name'<~String> - Name of the image + def get_images + request( + :expects => 200, + :method => 'GET', + :parser => Fog::Parsers::Slicehost::Compute::GetImages.new, + :path => 'images.xml' + ) + end + + end + + class Mock + + def get_images + Fog::Mock.not_implemented + end + + end + end + end +end diff --git a/lib/fog/slicehost/requests/compute/get_slice.rb b/lib/fog/slicehost/requests/compute/get_slice.rb new file mode 100644 index 000000000..7200595bc --- /dev/null +++ b/lib/fog/slicehost/requests/compute/get_slice.rb @@ -0,0 +1,46 @@ +module Fog + module Slicehost + class Compute + class Real + + require 'fog/slicehost/parsers/compute/get_slice' + + # Get details of a slice + # + # ==== Parameters + # * slice_id<~Integer> - Id of slice to lookup + # + # ==== Returns + # * response<~Excon::Response>: + # * body<~Hash>: + # * 'addresses'<~Array> - Ip addresses for the slice + # * 'backup-id'<~Integer> - Id of backup slice was booted from + # * 'bw-in'<~Float> - Incoming bandwidth total for current billing cycle, in Gigabytes + # * 'bw-out'<~Float> - Outgoing bandwidth total for current billing cycle, in Gigabytes + # * 'flavor_id'<~Integer> - Id of flavor slice was booted from + # * 'id'<~Integer> - Id of the slice + # * 'image-id'<~Integer> - Id of image slice was booted from + # * 'name'<~String> - Name of the slice + # * 'progress'<~Integer> - Progress of current action, in percentage + # * 'status'<~String> - Current status of the slice + def get_slice(slice_id) + request( + :expects => 200, + :method => 'GET', + :parser => Fog::Parsers::Slicehost::Compute::GetSlice.new, + :path => "/slices/#{slice_id}.xml" + ) + end + + end + + class Mock + + def get_slice(id) + Fog::Mock.not_implemented + end + + end + end + end +end diff --git a/lib/fog/slicehost/requests/compute/get_slices.rb b/lib/fog/slicehost/requests/compute/get_slices.rb new file mode 100644 index 000000000..1ca619946 --- /dev/null +++ b/lib/fog/slicehost/requests/compute/get_slices.rb @@ -0,0 +1,43 @@ +module Fog + module Slicehost + class Compute + class Real + + require 'fog/slicehost/parsers/compute/get_slices' + + # Get list of slices + # + # ==== Returns + # * response<~Excon::Response>: + # * body<~Array>: + # * 'addresses'<~Array> - Ip addresses for the slice + # * 'backup-id'<~Integer> - Id of backup slice was booted from + # * 'bw-in'<~Float> - Incoming bandwidth total for current billing cycle, in Gigabytes + # * 'bw-out'<~Float> - Outgoing bandwidth total for current billing cycle, in Gigabytes + # * 'flavor_id'<~Integer> - Id of flavor slice was booted from + # * 'id'<~Integer> - Id of the slice + # * 'image-id'<~Integer> - Id of image slice was booted from + # * 'name'<~String> - Name of the slice + # * 'progress'<~Integer> - Progress of current action, in percentage + # * 'status'<~String> - Current status of the slice + def get_slices + request( + :expects => 200, + :method => 'GET', + :parser => Fog::Parsers::Slicehost::Compute::GetSlices.new, + :path => 'slices.xml' + ) + end + + end + + class Mock + + def get_slices + Fog::Mock.not_implemented + end + + end + end + end +end diff --git a/lib/fog/slicehost/requests/compute/reboot_slice.rb b/lib/fog/slicehost/requests/compute/reboot_slice.rb new file mode 100644 index 000000000..15ef64f38 --- /dev/null +++ b/lib/fog/slicehost/requests/compute/reboot_slice.rb @@ -0,0 +1,44 @@ +module Fog + module Slicehost + class Compute + class Real + + # Reboot slice + # ==== Parameters + # * slice_id<~Integer> - Id of server to reboot + # * type<~String> - Type of reboot, must be in ['HARD', 'SOFT'] + # + # ==== Returns + # * response<~Excon::Response>: + # * body<~Hash>: + # * 'addresses'<~Array> - Ip addresses for the slice + # * 'backup-id'<~Integer> - Id of backup slice was booted from + # * 'bw-in'<~Float> - Incoming bandwidth total for current billing cycle, in Gigabytes + # * 'bw-out'<~Float> - Outgoing bandwidth total for current billing cycle, in Gigabytes + # * 'flavor_id'<~Integer> - Id of flavor slice was booted from + # * 'id'<~Integer> - Id of the slice + # * 'image-id'<~Integer> - Id of image slice was booted from + # * 'name'<~String> - Name of the slice + # * 'progress'<~Integer> - Progress of current action, in percentage + # * 'status'<~String> - Current status of the slice + def reboot_slice(slice_id, type = 'SOFT') + request( + :expects => 200, + :method => 'PUT', + :parser => Fog::Parsers::Slicehost::Compute::GetSlice.new, + :path => "/slices/#{slice_id}/#{'hard_' if type == 'HARD'}reboot.xml" + ) + end + + end + + class Mock + + def get_slice(id) + Fog::Mock.not_implemented + end + + end + end + end +end diff --git a/lib/fog/slicehost/requests/create_slice.rb b/lib/fog/slicehost/requests/create_slice.rb deleted file mode 100644 index 7070e6936..000000000 --- a/lib/fog/slicehost/requests/create_slice.rb +++ /dev/null @@ -1,47 +0,0 @@ -module Fog - class Slicehost - class Real - - require 'fog/slicehost/parsers/create_slice' - - # Get list of slices - # ==== Parameters - # * flavor_id<~Integer> - Id of flavor to create slice with - # * image_id<~Integer> - Id of image to create slice with - # * name<~String> - Name of slice - # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Array>: - # * 'addresses'<~Array> - Ip addresses for the slice - # * 'backup-id'<~Integer> - Id of backup slice was booted from - # * 'bw-in'<~Integer> - Incoming bandwidth total for current billing cycle, in Gigabytes - # * 'bw-out'<~Integer> - Outgoing bandwidth total for current billing cycle, in Gigabytes - # * 'flavor-id'<~Integer> - Id of flavor slice was booted from - # * 'id'<~Integer> - Id of the slice - # * 'image-id'<~Integer> - Id of image slice was booted from - # * 'name'<~String> - Name of the slice - # * 'progress'<~Integer> - Progress of current action, in percentage - # * 'root-password'<~String> - Root password of slice - # * 'status'<~String> - Current status of the slice - def create_slice(flavor_id, image_id, name) - request( - :body => %Q{#{flavor_id}#{image_id}#{name}}, - :expects => 201, - :method => 'POST', - :parser => Fog::Parsers::Slicehost::CreateSlice.new, - :path => 'slices.xml' - ) - end - - end - - class Mock - - def create_slice(flavor_id, image_id, name) - Fog::Mock.not_implemented - end - - end - end -end diff --git a/lib/fog/slicehost/requests/delete_slice.rb b/lib/fog/slicehost/requests/delete_slice.rb deleted file mode 100644 index 57c26eaf8..000000000 --- a/lib/fog/slicehost/requests/delete_slice.rb +++ /dev/null @@ -1,43 +0,0 @@ -module Fog - class Slicehost - class Real - - # Get list of slices - # ==== Parameters - # * flavor_id<~Integer> - Id of flavor to create slice with - # * image_id<~Integer> - Id of image to create slice with - # * name<~String> - Name of slice - # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Array>: - # * 'addresses'<~Array> - Ip addresses for the slice - # * 'backup-id'<~Integer> - Id of backup slice was booted from - # * 'bw-in'<~Integer> - Incoming bandwidth total for current billing cycle, in Gigabytes - # * 'bw-out'<~Integer> - Outgoing bandwidth total for current billing cycle, in Gigabytes - # * 'flavor-id'<~Integer> - Id of flavor slice was booted from - # * 'id'<~Integer> - Id of the slice - # * 'image-id'<~Integer> - Id of image slice was booted from - # * 'name'<~String> - Name of the slice - # * 'progress'<~Integer> - Progress of current action, in percentage - # * 'root-password'<~String> - Root password of slice - # * 'status'<~String> - Current status of the slice - def delete_slice(slice_id) - request( - :expects => 200, - :method => 'DELETE', - :path => "slices/#{slice_id}.xml" - ) - end - - end - - class Mock - - def delete_slice(slice_id) - Fog::Mock.not_implemented - end - - end - end -end diff --git a/lib/fog/slicehost/requests/get_backups.rb b/lib/fog/slicehost/requests/get_backups.rb deleted file mode 100644 index f43fe33c0..000000000 --- a/lib/fog/slicehost/requests/get_backups.rb +++ /dev/null @@ -1,35 +0,0 @@ -module Fog - class Slicehost - class Real - - require 'fog/slicehost/parsers/get_backups' - - # Get list of backups - # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Array>: - # * 'date'<~Time> - Timestamp of backup creation - # * 'id'<~Integer> - Id of the backup - # * 'name'<~String> - Name of the backup - # * 'slice-id'<~Integer> - Id of slice the backup was made from - def get_backups - request( - :expects => 200, - :method => 'GET', - :parser => Fog::Parsers::Slicehost::GetBackups.new, - :path => 'backups.xml' - ) - end - - end - - class Mock - - def get_backups - Fog::Mock.not_implemented - end - - end - end -end diff --git a/lib/fog/slicehost/requests/get_flavor.rb b/lib/fog/slicehost/requests/get_flavor.rb deleted file mode 100644 index 34d5d95e0..000000000 --- a/lib/fog/slicehost/requests/get_flavor.rb +++ /dev/null @@ -1,38 +0,0 @@ -module Fog - class Slicehost - class Real - - require 'fog/slicehost/parsers/get_flavor' - - # Get details of a flavor - # - # ==== Parameters - # * flavor_id<~Integer> - Id of flavor to lookup - # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Array>: - # * 'id'<~Integer> - Id of the flavor - # * 'name'<~String> - Name of the flavor - # * 'price'<~Integer> - Price in cents - # * 'ram'<~Integer> - Amount of ram for the flavor - def get_flavor(flavor_id) - request( - :expects => 200, - :method => 'GET', - :parser => Fog::Parsers::Slicehost::GetFlavor.new, - :path => "flavors/#{flavor_id}.xml" - ) - end - - end - - class Mock - - def get_flavor(flavor_id) - Fog::Mock.not_implemented - end - - end - end -end diff --git a/lib/fog/slicehost/requests/get_flavors.rb b/lib/fog/slicehost/requests/get_flavors.rb deleted file mode 100644 index fd367910a..000000000 --- a/lib/fog/slicehost/requests/get_flavors.rb +++ /dev/null @@ -1,35 +0,0 @@ -module Fog - class Slicehost - class Real - - require 'fog/slicehost/parsers/get_flavors' - - # Get list of flavors - # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Array>: - # * 'id'<~Integer> - Id of the flavor - # * 'name'<~String> - Name of the flavor - # * 'price'<~Integer> - Price in cents - # * 'ram'<~Integer> - Amount of ram for the flavor - def get_flavors - request( - :expects => 200, - :method => 'GET', - :parser => Fog::Parsers::Slicehost::GetFlavors.new, - :path => 'flavors.xml' - ) - end - - end - - class Mock - - def get_flavors - Fog::Mock.not_implemented - end - - end - end -end diff --git a/lib/fog/slicehost/requests/get_image.rb b/lib/fog/slicehost/requests/get_image.rb deleted file mode 100644 index aacff163d..000000000 --- a/lib/fog/slicehost/requests/get_image.rb +++ /dev/null @@ -1,36 +0,0 @@ -module Fog - class Slicehost - class Real - - require 'fog/slicehost/parsers/get_image' - - # Get details of an image - # - # ==== Parameters - # * image_id<~Integer> - Id of image to lookup - # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Array>: - # * 'id'<~Integer> - Id of the image - # * 'name'<~String> - Name of the image - def get_image(image_id) - request( - :expects => 200, - :method => 'GET', - :parser => Fog::Parsers::Slicehost::GetImage.new, - :path => "images/#{image_id}.xml" - ) - end - - end - - class Mock - - def get_image(image_id) - Fog::Mock.not_implemented - end - - end - end -end diff --git a/lib/fog/slicehost/requests/get_images.rb b/lib/fog/slicehost/requests/get_images.rb deleted file mode 100644 index f6da578f8..000000000 --- a/lib/fog/slicehost/requests/get_images.rb +++ /dev/null @@ -1,33 +0,0 @@ -module Fog - class Slicehost - class Real - - require 'fog/slicehost/parsers/get_images' - - # Get list of images - # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Array>: - # * 'id'<~Integer> - Id of the image - # * 'name'<~String> - Name of the image - def get_images - request( - :expects => 200, - :method => 'GET', - :parser => Fog::Parsers::Slicehost::GetImages.new, - :path => 'images.xml' - ) - end - - end - - class Mock - - def get_images - Fog::Mock.not_implemented - end - - end - end -end diff --git a/lib/fog/slicehost/requests/get_slice.rb b/lib/fog/slicehost/requests/get_slice.rb deleted file mode 100644 index d82ebc86e..000000000 --- a/lib/fog/slicehost/requests/get_slice.rb +++ /dev/null @@ -1,44 +0,0 @@ -module Fog - class Slicehost - class Real - - require 'fog/slicehost/parsers/get_slice' - - # Get details of a slice - # - # ==== Parameters - # * slice_id<~Integer> - Id of slice to lookup - # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Hash>: - # * 'addresses'<~Array> - Ip addresses for the slice - # * 'backup-id'<~Integer> - Id of backup slice was booted from - # * 'bw-in'<~Float> - Incoming bandwidth total for current billing cycle, in Gigabytes - # * 'bw-out'<~Float> - Outgoing bandwidth total for current billing cycle, in Gigabytes - # * 'flavor_id'<~Integer> - Id of flavor slice was booted from - # * 'id'<~Integer> - Id of the slice - # * 'image-id'<~Integer> - Id of image slice was booted from - # * 'name'<~String> - Name of the slice - # * 'progress'<~Integer> - Progress of current action, in percentage - # * 'status'<~String> - Current status of the slice - def get_slice(slice_id) - request( - :expects => 200, - :method => 'GET', - :parser => Fog::Parsers::Slicehost::GetSlice.new, - :path => "/slices/#{slice_id}.xml" - ) - end - - end - - class Mock - - def get_slice(id) - Fog::Mock.not_implemented - end - - end - end -end diff --git a/lib/fog/slicehost/requests/get_slices.rb b/lib/fog/slicehost/requests/get_slices.rb deleted file mode 100644 index 1cdcf68be..000000000 --- a/lib/fog/slicehost/requests/get_slices.rb +++ /dev/null @@ -1,41 +0,0 @@ -module Fog - class Slicehost - class Real - - require 'fog/slicehost/parsers/get_slices' - - # Get list of slices - # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Array>: - # * 'addresses'<~Array> - Ip addresses for the slice - # * 'backup-id'<~Integer> - Id of backup slice was booted from - # * 'bw-in'<~Float> - Incoming bandwidth total for current billing cycle, in Gigabytes - # * 'bw-out'<~Float> - Outgoing bandwidth total for current billing cycle, in Gigabytes - # * 'flavor_id'<~Integer> - Id of flavor slice was booted from - # * 'id'<~Integer> - Id of the slice - # * 'image-id'<~Integer> - Id of image slice was booted from - # * 'name'<~String> - Name of the slice - # * 'progress'<~Integer> - Progress of current action, in percentage - # * 'status'<~String> - Current status of the slice - def get_slices - request( - :expects => 200, - :method => 'GET', - :parser => Fog::Parsers::Slicehost::GetSlices.new, - :path => 'slices.xml' - ) - end - - end - - class Mock - - def get_slices - Fog::Mock.not_implemented - end - - end - end -end diff --git a/lib/fog/slicehost/requests/reboot_slice.rb b/lib/fog/slicehost/requests/reboot_slice.rb deleted file mode 100644 index edfee6ad9..000000000 --- a/lib/fog/slicehost/requests/reboot_slice.rb +++ /dev/null @@ -1,42 +0,0 @@ -module Fog - class Slicehost - class Real - - # Reboot slice - # ==== Parameters - # * slice_id<~Integer> - Id of server to reboot - # * type<~String> - Type of reboot, must be in ['HARD', 'SOFT'] - # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Hash>: - # * 'addresses'<~Array> - Ip addresses for the slice - # * 'backup-id'<~Integer> - Id of backup slice was booted from - # * 'bw-in'<~Float> - Incoming bandwidth total for current billing cycle, in Gigabytes - # * 'bw-out'<~Float> - Outgoing bandwidth total for current billing cycle, in Gigabytes - # * 'flavor_id'<~Integer> - Id of flavor slice was booted from - # * 'id'<~Integer> - Id of the slice - # * 'image-id'<~Integer> - Id of image slice was booted from - # * 'name'<~String> - Name of the slice - # * 'progress'<~Integer> - Progress of current action, in percentage - # * 'status'<~String> - Current status of the slice - def reboot_slice(slice_id, type = 'SOFT') - request( - :expects => 200, - :method => 'PUT', - :parser => Fog::Parsers::Slicehost::GetSlice.new, - :path => "/slices/#{slice_id}/#{'hard_' if type == 'HARD'}reboot.xml" - ) - end - - end - - class Mock - - def get_slice(id) - Fog::Mock.not_implemented - end - - end - end -end