# File lib/fog/bare_metal_cloud/compute.rb, line 52 def initialize(options={}) require 'fog/core/parser' @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.newservers.com" @persistent = options[:persistent] || false @port = options[:port] || 443 @scheme = options[:scheme] || 'https' @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options) end
Boot a new server
planId<~String> - The id of the plan to boot the server with
options<~Hash>: optional extra arguments
imageId<~String> - Optional image to boot server from
name<~String> - Name to boot new server with
response<~Excon::Response>:
body<~Hash>:
'server'<~Hash>:
'id'<~String> - Id of the image
# File lib/fog/bare_metal_cloud/requests/compute/add_server.rb, line 20 def add_server(plan_id, options = {}) request( :expects => 200, :method => 'GET', :parser => Fog::ToHashDocument.new, :path => 'api/addServer', :query => {'planId' => plan_id}.merge!(options) ) end
Boot a new server by configuration
config<~String> - The Hardware configuration string
options<~Hash>: optional extra arguments
imageName<~String> - Optional imageName to be installed
name<~String> - Optional server Name
response<~Excon::Response>:
body<~Hash>:
'server'<~Hash>:
'id'<~String> - Id of the image
# File lib/fog/bare_metal_cloud/requests/compute/add_server_by_configuration.rb, line 20 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
Shutdown a running server
serverId<~String> - The id of the server to shutdown
response<~Excon::Response>:
body<~Hash>:
'server'<~Hash>:
'id'<~String> - Id of the image
# File lib/fog/bare_metal_cloud/requests/compute/cancel_server.rb, line 17 def cancel_server(server_id) request( :expects => 200, :method => 'GET', :parser => Fog::ToHashDocument.new, :path => 'api/cancelServer', :query => {'serverId' => server_id} ) end
List servers
serverId<~String> - Id of the server
response<~Excon::Response>:
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
# File lib/fog/bare_metal_cloud/requests/compute/get_server.rb, line 28 def get_server(server_id) request( :expects => 200, :method => 'GET', :parser => Fog::ToHashDocument.new, :path => 'api/getServer', :query => {'serverId' => server_id} ) end
List Configurations
response<~Excon::Response>:
body<~Hash>:
available-server<~Array>:
'configuration'<~String> - Hardware Configuration string
'quantity'<~String>: - quantity of servers to a certain configuration
# File lib/fog/bare_metal_cloud/requests/compute/list_configurations.rb, line 15 def list_configurations request( :expects => 200, :method => 'GET', :parser => Fog::ToHashDocument.new, :path => 'api/listConfigurations' ) end
List images
response<~Excon::Response>:
body<~Hash>:
'image'<~Array>
'Size'<~String> - Size of the image
'Name'<~String> - Name of the image
# File lib/fog/bare_metal_cloud/requests/compute/list_images.rb, line 15 def list_images request( :expects => 200, :method => 'GET', :parser => Fog::ToHashDocument.new, :path => 'api/listImages' ) end
List available plans
response<~Excon::Response>:
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
# File lib/fog/bare_metal_cloud/requests/compute/list_plans.rb, line 18 def list_plans request( :expects => 200, :method => 'GET', :parser => Fog::ToHashDocument.new, :path => 'api/listPlans' ) end
List servers
response<~Excon::Response>:
body<~Hash>:
server<~Array>:
'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
# File lib/fog/bare_metal_cloud/requests/compute/list_servers.rb, line 24 def list_servers request( :expects => 200, :method => 'GET', :parser => Fog::ToHashDocument.new, :path => 'api/listServers' ) end
Reboot a running server
serverId<~String> - The id of the server to reboot
# File lib/fog/bare_metal_cloud/requests/compute/reboot_server.rb, line 11 def reboot_server(server_id) request( :expects => 200, :method => 'GET', :parser => Fog::ToHashDocument.new, :path => 'api/rebootServer', :query => {'serverId' => server_id} ) end
# File lib/fog/bare_metal_cloud/compute.rb, line 65 def reload @connection.reset end
# File lib/fog/bare_metal_cloud/compute.rb, line 69 def request(params) params[:query] ||= {} params[:query].merge!({ :password => @bare_metal_cloud_password, :username => @bare_metal_cloud_username }) params[:headers] ||= {} 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::HTTPStatusError => error raise case error when Excon::Errors::NotFound Fog::Compute::BareMetalCloud::NotFound.slurp(error) else error end end response end
Generated with the Darkfish Rdoc Generator 2.