Class: Fog::Compute::Glesys::Real
- Inherits:
-
Object
- Object
- Fog::Compute::Glesys::Real
- Defined in:
- lib/fog/glesys/compute.rb,
lib/fog/glesys/requests/compute/stop.rb,
lib/fog/glesys/requests/compute/start.rb,
lib/fog/glesys/requests/compute/create.rb,
lib/fog/glesys/requests/compute/ip_add.rb,
lib/fog/glesys/requests/compute/reboot.rb,
lib/fog/glesys/requests/compute/destroy.rb,
lib/fog/glesys/requests/compute/ip_take.rb,
lib/fog/glesys/requests/compute/ip_remove.rb,
lib/fog/glesys/requests/compute/ip_details.rb,
lib/fog/glesys/requests/compute/ip_release.rb,
lib/fog/glesys/requests/compute/ip_list_own.rb,
lib/fog/glesys/requests/compute/ip_list_free.rb,
lib/fog/glesys/requests/compute/list_servers.rb,
lib/fog/glesys/requests/compute/server_status.rb,
lib/fog/glesys/requests/compute/template_list.rb,
lib/fog/glesys/requests/compute/server_details.rb
Instance Method Summary collapse
- #create(options = {}) ⇒ Object
- #destroy(options) ⇒ Object
-
#initialize(options) ⇒ Real
constructor
A new instance of Real.
- #ip_add(params) ⇒ Object
- #ip_details(params) ⇒ Object
- #ip_list_free(options = {}) ⇒ Object
- #ip_list_own(options = {}) ⇒ Object
- #ip_release(params) ⇒ Object
- #ip_remove(params) ⇒ Object
- #ip_take(params) ⇒ Object
- #list_servers(serverid = nil, options = {}) ⇒ Object
- #reboot(param) ⇒ Object
- #request(method_name, options = {}) ⇒ Object
- #server_details(serverid, options = {}) ⇒ Object
- #server_status(serverid) ⇒ Object
- #start(param) ⇒ Object
- #stop(param) ⇒ Object
- #template_list ⇒ Object
Constructor Details
#initialize(options) ⇒ Real
Returns a new instance of Real.
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/fog/glesys/compute.rb', line 69 def initialize() require 'base64' @api_url = [:glesys_api_url] || API_URL @glesys_username = [:glesys_username] @glesys_api_key = [:glesys_api_key] @connection_options = [:connection_options] || {} @persistent = [:persistent] || false @connection = Fog::XML::Connection.new(@api_url, @persistent, @connection_options) end |
Instance Method Details
#create(options = {}) ⇒ Object
5 6 7 |
# File 'lib/fog/glesys/requests/compute/create.rb', line 5 def create( = {}) request('server/create/',) end |
#destroy(options) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/glesys/requests/compute/destroy.rb', line 5 def destroy() if [:keepip].nil? [:keepip] = 0 end request("/server/destroy", ) end |
#ip_add(params) ⇒ Object
5 6 7 |
# File 'lib/fog/glesys/requests/compute/ip_add.rb', line 5 def ip_add(params) request("/ip/add", params) end |
#ip_details(params) ⇒ Object
5 6 7 |
# File 'lib/fog/glesys/requests/compute/ip_details.rb', line 5 def ip_details(params) request("/ip/details", params) end |
#ip_list_free(options = {}) ⇒ Object
5 6 7 |
# File 'lib/fog/glesys/requests/compute/ip_list_free.rb', line 5 def ip_list_free( = {}) request("/ip/listfree", ) end |
#ip_list_own(options = {}) ⇒ Object
5 6 7 |
# File 'lib/fog/glesys/requests/compute/ip_list_own.rb', line 5 def ip_list_own( = {}) request("/ip/listown", ) end |
#ip_release(params) ⇒ Object
5 6 7 |
# File 'lib/fog/glesys/requests/compute/ip_release.rb', line 5 def ip_release(params) request("/ip/release", params) end |
#ip_remove(params) ⇒ Object
5 6 7 |
# File 'lib/fog/glesys/requests/compute/ip_remove.rb', line 5 def ip_remove(params) request("/ip/remove", params) end |
#ip_take(params) ⇒ Object
5 6 7 |
# File 'lib/fog/glesys/requests/compute/ip_take.rb', line 5 def ip_take(params) request("/ip/take", params) end |
#list_servers(serverid = nil, options = {}) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/glesys/requests/compute/list_servers.rb', line 5 def list_servers(serverid = nil, = {}) unless serverid.nil? [:serverid] = serverid end request("/server/list", ) end |
#reboot(param) ⇒ Object
5 6 7 |
# File 'lib/fog/glesys/requests/compute/reboot.rb', line 5 def reboot(param) request("/server/reboot", param) end |
#request(method_name, options = {}) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/fog/glesys/compute.rb', line 80 def request(method_name, = {}) .merge!( {:format => 'json'}) begin parser = .delete(:parser) data = @connection.request( :expects => 200, :method => "POST", :body => urlencode(), :parser => parser, :path => method_name, :headers => { 'Authorization' => "Basic #{encoded_api_auth}", 'Content-Type' => 'application/x-www-form-urlencoded' } ) data.body = Fog::JSON.decode(data.body) response_code = data.body['response']['status']['code'] unless response_code.to_i == 200 raise Fog::Compute::Glesys::Error, "#{data.body['response']['status']['text']}" end data rescue Excon::Errors::HTTPStatusError => error raise case error when Excon::Errors::NotFound Fog::Compute::Glesys::NotFound.slurp(error) else error end end end |
#server_details(serverid, options = {}) ⇒ Object
5 6 7 |
# File 'lib/fog/glesys/requests/compute/server_details.rb', line 5 def server_details(serverid, = {}) request("/server/details", { :serverid => serverid }.merge!() ) end |
#server_status(serverid) ⇒ Object
5 6 7 |
# File 'lib/fog/glesys/requests/compute/server_status.rb', line 5 def server_status(serverid) request("/server/status", { :serverid => serverid } ) end |
#start(param) ⇒ Object
5 6 7 |
# File 'lib/fog/glesys/requests/compute/start.rb', line 5 def start(param) request("/server/start", param) end |
#stop(param) ⇒ Object
5 6 7 |
# File 'lib/fog/glesys/requests/compute/stop.rb', line 5 def stop(param) request("/server/stop", param) end |
#template_list ⇒ Object
5 6 7 |
# File 'lib/fog/glesys/requests/compute/template_list.rb', line 5 def template_list request("/server/templates") end |