Class: Fog::NewServers::Compute::Real
- Inherits:
- 
      Object
      
        - Object
- Fog::NewServers::Compute::Real
 
- Defined in:
- lib/fog/compute/new_servers.rb,
 lib/fog/compute/requests/new_servers/add_server.rb,
 lib/fog/compute/requests/new_servers/get_server.rb,
 lib/fog/compute/requests/new_servers/list_plans.rb,
 lib/fog/compute/requests/new_servers/list_images.rb,
 lib/fog/compute/requests/new_servers/list_servers.rb,
 lib/fog/compute/requests/new_servers/cancel_server.rb,
 lib/fog/compute/requests/new_servers/reboot_server.rb
Instance Method Summary collapse
- 
  
    
      #add_server(plan_id, options = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Boot a new server. 
- 
  
    
      #cancel_server(server_id)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Shutdown a running server. 
- 
  
    
      #get_server(server_id)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    List servers. 
- 
  
    
      #initialize(options = {})  ⇒ Real 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Real. 
- 
  
    
      #list_images  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    List images. 
- 
  
    
      #list_plans  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    List available plans. 
- 
  
    
      #list_servers  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    List servers. 
- 
  
    
      #reboot_server(server_id)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Reboot a running server. 
- #reload ⇒ Object
- #request(params) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
| 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | # File 'lib/fog/compute/new_servers.rb', line 52 def initialize(={}) unless .delete(:provider) location = caller.first warning = "[yellow][WARN] Fog::NewServers::Compute.new is deprecated, use Fog::Compute.new(:provider => 'NewServers') instead[/]" warning << " [light_black](" << location << ")[/] " Formatador.display_line(warning) end @new_servers_password = [:new_servers_password] @new_servers_username = [:new_servers_username] @host = [:host] || "noc.newservers.com" @port = [:port] || 443 @scheme = [:scheme] || 'https' @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", [:persistent]) end | 
Instance Method Details
#add_server(plan_id, options = {}) ⇒ Object
Boot a new server
Parameters
- 
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 
 
- 
Returns
- 
response<~Excon::Response>: - 
body<~Hash>: - 
‘server’<~Hash>: - 
‘id’<~String> - Id of the image 
 
- 
 
- 
 
- 
| 20 21 22 23 24 25 26 27 28 | # File 'lib/fog/compute/requests/new_servers/add_server.rb', line 20 def add_server(plan_id, = {}) request( :expects => 200, :method => 'GET', :parser => Fog::ToHashDocument.new, :path => 'api/addServer', :query => {'planId' => plan_id}.merge!() ) end | 
#cancel_server(server_id) ⇒ Object
Shutdown a running server
Parameters
- 
serverId<~String> - The id of the server to shutdown 
Returns
- 
response<~Excon::Response>: - 
body<~Hash>: - 
‘server’<~Hash>: - 
‘id’<~String> - Id of the image 
 
- 
 
- 
 
- 
| 17 18 19 20 21 22 23 24 25 | # File 'lib/fog/compute/requests/new_servers/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 | 
#get_server(server_id) ⇒ Object
List servers
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 
 
- 
 
- 
| 23 24 25 26 27 28 29 30 31 | # File 'lib/fog/compute/requests/new_servers/get_server.rb', line 23 def get_server(server_id) request( :expects => 200, :method => 'GET', :parser => Fog::ToHashDocument.new, :path => 'api/getServer', :query => {'serverId' => server_id} ) end | 
#list_images ⇒ Object
List images
Returns
- 
response<~Excon::Response>: - 
body<~Array>: - 
‘id’<~String> - Id of the image 
- 
‘name’<~String> - Name of the image 
- 
‘size’<~String> - Size of the image 
 
- 
 
- 
| 15 16 17 18 19 20 21 22 | # File 'lib/fog/compute/requests/new_servers/list_images.rb', line 15 def list_images request( :expects => 200, :method => 'GET', :parser => Fog::ToHashDocument.new, :path => 'api/listImages' ) end | 
#list_plans ⇒ Object
List available plans
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 
 
- 
 
- 
| 18 19 20 21 22 23 24 25 | # File 'lib/fog/compute/requests/new_servers/list_plans.rb', line 18 def list_plans request( :expects => 200, :method => 'GET', :parser => Fog::ToHashDocument.new, :path => 'api/listPlans' ) end | 
#list_servers ⇒ Object
List servers
Returns
- 
response<~Excon::Response>: - 
body<~Array>: - 
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 
 
- 
 
- 
 
- 
| 24 25 26 27 28 29 30 31 | # File 'lib/fog/compute/requests/new_servers/list_servers.rb', line 24 def list_servers request( :expects => 200, :method => 'GET', :parser => Fog::ToHashDocument.new, :path => 'api/listServers' ) end | 
#reboot_server(server_id) ⇒ Object
Reboot a running server
Parameters
- 
serverId<~String> - The id of the server to reboot 
| 11 12 13 14 15 16 17 18 19 | # File 'lib/fog/compute/requests/new_servers/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 | 
#reload ⇒ Object
| 68 69 70 | # File 'lib/fog/compute/new_servers.rb', line 68 def reload @connection.reset end | 
#request(params) ⇒ Object
| 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | # File 'lib/fog/compute/new_servers.rb', line 72 def request(params) params[:query] ||= {} params[:query].merge!({ :password => @new_servers_password, :username => @new_servers_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::NewServers::Compute::NotFound.slurp(error) else error end end response end |