Class: Fog::Compute::StormOnDemand::Real
- Inherits:
-
Object
- Object
- Fog::Compute::StormOnDemand::Real
- Defined in:
- lib/fog/storm_on_demand/compute.rb,
lib/fog/storm_on_demand/requests/compute/get_stats.rb,
lib/fog/storm_on_demand/requests/compute/get_server.rb,
lib/fog/storm_on_demand/requests/compute/list_images.rb,
lib/fog/storm_on_demand/requests/compute/clone_server.rb,
lib/fog/storm_on_demand/requests/compute/list_configs.rb,
lib/fog/storm_on_demand/requests/compute/list_servers.rb,
lib/fog/storm_on_demand/requests/compute/create_server.rb,
lib/fog/storm_on_demand/requests/compute/delete_server.rb,
lib/fog/storm_on_demand/requests/compute/reboot_server.rb,
lib/fog/storm_on_demand/requests/compute/resize_server.rb,
lib/fog/storm_on_demand/requests/compute/list_balancers.rb,
lib/fog/storm_on_demand/requests/compute/list_templates.rb,
lib/fog/storm_on_demand/requests/compute/list_private_ips.rb,
lib/fog/storm_on_demand/requests/compute/add_balancer_node.rb,
lib/fog/storm_on_demand/requests/compute/remove_balancer_node.rb
Instance Method Summary collapse
- #add_balancer_node(options = {}) ⇒ Object
- #clone_server(options = {}) ⇒ Object
- #create_server(options = {}) ⇒ Object
- #delete_server(options = {}) ⇒ Object
- #get_server(options = {}) ⇒ Object
- #get_stats(options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Real
constructor
A new instance of Real.
- #list_balancers(options = {}) ⇒ Object
- #list_configs(options = {}) ⇒ Object
- #list_images(options = {}) ⇒ Object
- #list_private_ips(options = {}) ⇒ Object
- #list_servers(options = {}) ⇒ Object
- #list_templates(options = {}) ⇒ Object
- #reboot_server(options = {}) ⇒ Object
- #reload ⇒ Object
- #remove_balancer_node(options = {}) ⇒ Object
- #request(params) ⇒ Object
- #resize_server(options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/fog/storm_on_demand/compute.rb', line 87 def initialize(={}) uri = URI.parse([:storm_on_demand_auth_url] ||= API_URL) @connection_options = [:connection_options] || {} @host = uri.host @path = uri.path @persistent = [:persistent] || false @port = uri.port @scheme = uri.scheme @storm_on_demand_username = [:storm_on_demand_username] @storm_on_demand_password = [:storm_on_demand_password] @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options) end |
Instance Method Details
#add_balancer_node(options = {}) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/fog/storm_on_demand/requests/compute/add_balancer_node.rb', line 6 def add_balancer_node( = {}) request( :path => "/network/loadbalancer/addnode", :body => Fog::JSON.encode({:params => }) ) end |
#clone_server(options = {}) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/fog/storm_on_demand/requests/compute/clone_server.rb', line 6 def clone_server( = {}) request( :path => "/storm/server/clone", :body => Fog::JSON.encode({:params => }) ) end |
#create_server(options = {}) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/fog/storm_on_demand/requests/compute/create_server.rb', line 6 def create_server( = {}) request( :path => "/storm/server/create", :body => Fog::JSON.encode({:params => }) ) end |
#delete_server(options = {}) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/fog/storm_on_demand/requests/compute/delete_server.rb', line 6 def delete_server( = {}) request( :path => "/storm/server/destroy", :body => Fog::JSON.encode({:params => }) ) end |
#get_server(options = {}) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/fog/storm_on_demand/requests/compute/get_server.rb', line 6 def get_server( = {}) request( :path => "/storm/server/details", :body => Fog::JSON.encode({:params => }) ) end |
#get_stats(options = {}) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/fog/storm_on_demand/requests/compute/get_stats.rb', line 6 def get_stats( = {}) request( :path => "/monitoring/load/stats", :body => Fog::JSON.encode({:params => }) ) end |
#list_balancers(options = {}) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/fog/storm_on_demand/requests/compute/list_balancers.rb', line 6 def list_balancers( = {}) request( :path => "/network/loadbalancer/list", :body => Fog::JSON.encode() ) end |
#list_configs(options = {}) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/fog/storm_on_demand/requests/compute/list_configs.rb', line 6 def list_configs( = {}) request( :path => "/storm/config/list", :body => Fog::JSON.encode() ) end |
#list_images(options = {}) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/fog/storm_on_demand/requests/compute/list_images.rb', line 6 def list_images( = {}) request( :path => "/server/image/list", :body => Fog::JSON.encode() ) end |
#list_private_ips(options = {}) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/fog/storm_on_demand/requests/compute/list_private_ips.rb', line 6 def list_private_ips( = {}) request( :path => "/network/private/get", :body => Fog::JSON.encode() ) end |
#list_servers(options = {}) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/fog/storm_on_demand/requests/compute/list_servers.rb', line 6 def list_servers( = {}) request( :path => "/storm/server/list", :body => Fog::JSON.encode() ) end |
#list_templates(options = {}) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/fog/storm_on_demand/requests/compute/list_templates.rb', line 6 def list_templates( = {}) request( :path => "/server/template/list", :body => Fog::JSON.encode() ) end |
#reboot_server(options = {}) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/fog/storm_on_demand/requests/compute/reboot_server.rb', line 6 def reboot_server( = {}) request( :path => "/storm/server/reboot", :body => Fog::JSON.encode({:params => }) ) end |
#reload ⇒ Object
100 101 102 |
# File 'lib/fog/storm_on_demand/compute.rb', line 100 def reload @connection.reset end |
#remove_balancer_node(options = {}) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/fog/storm_on_demand/requests/compute/remove_balancer_node.rb', line 6 def remove_balancer_node( = {}) request( :path => "/network/loadbalancer/removenode", :body => Fog::JSON.encode({:params => }) ) end |
#request(params) ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/fog/storm_on_demand/compute.rb', line 104 def request(params) begin response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', 'Authorization' => 'Basic ' << Base64.encode64("#{@storm_on_demand_username}:#{@storm_on_demand_password}").chomp }.merge!(params[:headers] || {}), :host => @host, :path => "#{@path}/#{params[:path]}", :expects => 200, :method => :post })) rescue Excon::Errors::HTTPStatusError => error raise case error when Excon::Errors::NotFound Fog::StormOnDemand::Compute::NotFound.slurp(error) else error end end unless response.body.empty? response.body = Fog::JSON.decode(response.body) end if response.body.has_key?('full_error') raise(Fog::Compute::StormOnDemand::Error, response.body.inspect) end response end |