From 49150c30d251ce260650ef6b9d12640ee78ef581 Mon Sep 17 00:00:00 2001 From: Diego Desani Date: Fri, 24 Aug 2012 00:17:43 -0400 Subject: [PATCH] - Updated "@host" variable to "noc.newservers.com" which is the current host for API calls - Added two calls: add_server_by_configuration.rb and list_configurations.rb -- These calls should be used instead of add_server and list_plans, although we still support them. - General comments were updated. --- lib/fog/bare_metal_cloud/compute.rb | 4 ++- .../compute/add_server_by_configuration.rb | 33 +++++++++++++++++++ .../requests/compute/get_server.rb | 29 +++++++++------- .../requests/compute/list_configurations.rb | 27 +++++++++++++++ .../requests/compute/list_images.rb | 8 ++--- .../requests/compute/list_plans.rb | 14 ++++---- .../requests/compute/list_servers.rb | 4 +-- 7 files changed, 93 insertions(+), 26 deletions(-) create mode 100644 lib/fog/bare_metal_cloud/requests/compute/add_server_by_configuration.rb create mode 100644 lib/fog/bare_metal_cloud/requests/compute/list_configurations.rb diff --git a/lib/fog/bare_metal_cloud/compute.rb b/lib/fog/bare_metal_cloud/compute.rb index c7d0e95a0..667b30721 100644 --- a/lib/fog/bare_metal_cloud/compute.rb +++ b/lib/fog/bare_metal_cloud/compute.rb @@ -12,11 +12,13 @@ module Fog request_path 'fog/bare_metal_cloud/requests/compute' request :add_server + request :add_server_by_configuration request :cancel_server request :get_server request :list_images request :list_plans request :list_servers + request :list_configurations request :reboot_server class Mock @@ -53,7 +55,7 @@ module Fog @bare_metal_cloud_password = options[:bare_metal_cloud_password] @bare_metal_cloud_username = options[:bare_metal_cloud_username] @connection_options = options[:connection_options] || {} - @host = options[:host] || "noc.baremetalcloud.com" + @host = options[:host] || "noc.newservers.com" @persistent = options[:persistent] || false @port = options[:port] || 443 @scheme = options[:scheme] || 'https' diff --git a/lib/fog/bare_metal_cloud/requests/compute/add_server_by_configuration.rb b/lib/fog/bare_metal_cloud/requests/compute/add_server_by_configuration.rb new file mode 100644 index 000000000..7722b35d1 --- /dev/null +++ b/lib/fog/bare_metal_cloud/requests/compute/add_server_by_configuration.rb @@ -0,0 +1,33 @@ +module Fog + module Compute + class BareMetalCloud + class Real + + # Boot a new server by configuration + # + # ==== Parameters + # * config<~String> - The Hardware configuration string + # * options<~Hash>: optional extra arguments + # * imageName<~String> - Optional imageName to be installed + # * name<~String> - Optional server Name + # + # ==== Returns + # * response<~Excon::Response>: + # * body<~Hash>: + # * 'server'<~Hash>: + # * 'id'<~String> - Id of the image + # + def add_server_by_configuration(config, options = {}) + request( + :expects => 200, + :method => 'GET', + :parser => Fog::ToHashDocument.new, + :path => 'api/addServerByConfiguration', + :query => {'configuration' => config}.merge!(options) + ) + end + + end + end + end +end diff --git a/lib/fog/bare_metal_cloud/requests/compute/get_server.rb b/lib/fog/bare_metal_cloud/requests/compute/get_server.rb index 18ffa6bc5..73f898091 100644 --- a/lib/fog/bare_metal_cloud/requests/compute/get_server.rb +++ b/lib/fog/bare_metal_cloud/requests/compute/get_server.rb @@ -5,20 +5,25 @@ module Fog # List servers # + # ==== Parameters + # * serverId<~String> - Id of the server + # # ==== Returns # * response<~Excon::Response>: - # * server<~Hash>: - # * 'id'<~String> - Id of the server - # * 'ip'<~Hash>: - # * 'address'<~String> - Address of the ip - # * 'name'<~String> - Name of the ip - # * 'login'<~Hash>: - # * 'name'<~String> - Name of the login - # * 'password'<~String> - Password of the login - # * 'username'<~String> - Username of the login - # * 'name'<~String> - Name of the server - # * 'notes'<~String> - Notes about the server - # * 'state'<~String> - State of the server + # * body<~Has>: + # * server<~Hash>: + # * 'id'<~String> - Id of the server + # * 'mac-address'<~String> - mac-address of the server + # * 'ip'<~Hash>: + # * 'address'<~String> - Address of the ip + # * 'name'<~String> - Name of the ip + # * 'login'<~Hash>: + # * 'name'<~String> - Name of the login + # * 'password'<~String> - Password of the login + # * 'username'<~String> - Username of the login + # * 'name'<~String> - Name of the server + # * 'notes'<~String> - Notes about the server + # * 'state'<~String> - State of the server # def get_server(server_id) request( diff --git a/lib/fog/bare_metal_cloud/requests/compute/list_configurations.rb b/lib/fog/bare_metal_cloud/requests/compute/list_configurations.rb new file mode 100644 index 000000000..62bb5f843 --- /dev/null +++ b/lib/fog/bare_metal_cloud/requests/compute/list_configurations.rb @@ -0,0 +1,27 @@ +module Fog + module Compute + class BareMetalCloud + class Real + + # List Configurations + # + # ==== Returns + # * response<~Excon::Response>: + # * body<~Hash>: + # * available-server<~Array>: + # * 'configuration'<~String> - Hardware Configuration string + # * 'quantity'<~String>: - quantity of servers to a certain configuration + # + def list_configurations + request( + :expects => 200, + :method => 'GET', + :parser => Fog::ToHashDocument.new, + :path => 'api/listConfigurations' + ) + end + + end + end + end +end diff --git a/lib/fog/bare_metal_cloud/requests/compute/list_images.rb b/lib/fog/bare_metal_cloud/requests/compute/list_images.rb index 499d694c1..521ab3483 100644 --- a/lib/fog/bare_metal_cloud/requests/compute/list_images.rb +++ b/lib/fog/bare_metal_cloud/requests/compute/list_images.rb @@ -7,10 +7,10 @@ module Fog # # ==== Returns # * response<~Excon::Response>: - # * body<~Array>: - # * 'id'<~String> - Id of the image - # * 'name'<~String> - Name of the image - # * 'size'<~String> - Size of the image + # * body<~Hash>: + # * 'image'<~Array> + # * 'Size'<~String> - Size of the image + # * 'Name'<~String> - Name of the image # def list_images request( diff --git a/lib/fog/bare_metal_cloud/requests/compute/list_plans.rb b/lib/fog/bare_metal_cloud/requests/compute/list_plans.rb index 9ca555f6a..a4aca8802 100644 --- a/lib/fog/bare_metal_cloud/requests/compute/list_plans.rb +++ b/lib/fog/bare_metal_cloud/requests/compute/list_plans.rb @@ -7,13 +7,13 @@ module Fog # # ==== Returns # * response<~Excon::Response>: - # * body<~Array>: - # * 'description'<~String> - Description of the plan - # * 'id'<~String> - Id of the plan - # * 'name'<~String> - Name of the plan - # * 'rate'<~String> - Cost per hour of the plan - # * 'os'<~String> - Operating system of the plan - # * 'config'<~String> - Configuration of the plan + # * body<~Hash>: + # * 'plan'<~Array> + # * 'id'<~String> - Id of the plan + # * 'name'<~String> - Name of the plan + # * 'rate'<~String> - Cost per hour of the plan + # * 'os'<~String> - Operating system of the plan + # * 'config'<~String> - Configuration of the plan # def list_plans request( diff --git a/lib/fog/bare_metal_cloud/requests/compute/list_servers.rb b/lib/fog/bare_metal_cloud/requests/compute/list_servers.rb index 0d3e9e509..5a0195016 100644 --- a/lib/fog/bare_metal_cloud/requests/compute/list_servers.rb +++ b/lib/fog/bare_metal_cloud/requests/compute/list_servers.rb @@ -7,8 +7,8 @@ module Fog # # ==== Returns # * response<~Excon::Response>: - # * body<~Array>: - # * server<~Hash>: + # * body<~Hash>: + # * server<~Array>: # * 'id'<~String> - Id of the server # * 'ip'<~Hash>: # * 'address'<~String> - Address of the ip