Class: Fog::Compute::GoGrid::Real
- Inherits:
-
Object
- Object
- Fog::Compute::GoGrid::Real
- Defined in:
- lib/rackspace-fog/go_grid/compute.rb,
lib/rackspace-fog/go_grid/requests/compute/grid_ip_list.rb,
lib/rackspace-fog/go_grid/requests/compute/grid_image_get.rb,
lib/rackspace-fog/go_grid/requests/compute/grid_image_list.rb,
lib/rackspace-fog/go_grid/requests/compute/grid_server_add.rb,
lib/rackspace-fog/go_grid/requests/compute/grid_server_get.rb,
lib/rackspace-fog/go_grid/requests/compute/grid_server_list.rb,
lib/rackspace-fog/go_grid/requests/compute/grid_server_power.rb,
lib/rackspace-fog/go_grid/requests/compute/common_lookup_list.rb,
lib/rackspace-fog/go_grid/requests/compute/grid_server_delete.rb,
lib/rackspace-fog/go_grid/requests/compute/support_password_get.rb,
lib/rackspace-fog/go_grid/requests/compute/support_password_list.rb,
lib/rackspace-fog/go_grid/requests/compute/grid_loadbalancer_list.rb
Instance Method Summary collapse
-
#common_lookup_list(lookup, options = {}) ⇒ Object
List options and lookups.
-
#grid_image_get(options = {}) ⇒ Object
List images.
-
#grid_image_list(options = {}) ⇒ Object
List images.
-
#grid_ip_list(options = {}) ⇒ Object
List ips.
-
#grid_loadbalancer_list(options = {}) ⇒ Object
List load balancers.
-
#grid_server_add(image, ip, name, server_ram, options = {}) ⇒ Object
Create a new server.
-
#grid_server_delete(server) ⇒ Object
Delete a server.
-
#grid_server_get(servers) ⇒ Object
Get one or more servers by name.
-
#grid_server_list(options = {}) ⇒ Object
List servers.
-
#grid_server_power(server, power) ⇒ Object
Start, Stop or Restart a server.
-
#initialize(options = {}) ⇒ Real
constructor
A new instance of Real.
- #reload ⇒ Object
- #request(params) ⇒ Object
-
#support_password_get(id, options = {}) ⇒ Object
Get one or more passwords by id.
-
#support_password_list(options = {}) ⇒ Object
List passwords.
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/rackspace-fog/go_grid/compute.rb', line 62 def initialize(={}) require 'digest/md5' @go_grid_api_key = [:go_grid_api_key] @go_grid_shared_secret = [:go_grid_shared_secret] @connection_options = [:connection_options] || {} @host = [:host] || "api.gogrid.com" @path = [:path] || "/api" @persistent = [:persistent] || false @port = [:port] || 443 @scheme = [:scheme] || 'https' @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options) end |
Instance Method Details
#common_lookup_list(lookup, options = {}) ⇒ Object
List options and lookups
Parameters
-
‘lookup’<~String> - the lookup to be listed
-
options<~Hash>:
-
‘sort’<~String> - column to sort result by in [‘description’, ‘id’, ‘name’]
-
‘asc’<~String> - order to sort in [‘true’,‘false’]
-
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
18 19 20 21 22 23 |
# File 'lib/rackspace-fog/go_grid/requests/compute/common_lookup_list.rb', line 18 def common_lookup_list(lookup, ={}) request( :path => 'common/lookup/list', :query => {'lookup' => lookup}.merge!() ) end |
#grid_image_get(options = {}) ⇒ Object
List images
Parameters
-
options<~Hash>:
-
‘id’<~String> - ID of the image
-
‘name’<~String> - Name of the image
-
‘image’<~String> - ID(s) or Name(s) of the images to retrive. Can be speicifed multiple times
-
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
18 19 20 21 22 23 |
# File 'lib/rackspace-fog/go_grid/requests/compute/grid_image_get.rb', line 18 def grid_image_get(={}) request( :path => 'grid/image/get', :query => ) end |
#grid_image_list(options = {}) ⇒ Object
List images
Parameters
-
options<~Hash>:
-
‘datacenter’<~String> - datacenter to limit results to
-
‘isPublic’<~String> - If true only returns public images, in [‘false’, ‘true’]
-
‘num_items’<~Integer> - Number of items to return
-
‘page’<~Integer> - Page index for paginated results
-
‘state’<~String> - state to limit results to, in [‘Saving’, ‘Available’]
-
‘type’<~String> - image type to limit results to
-
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
21 22 23 24 25 26 |
# File 'lib/rackspace-fog/go_grid/requests/compute/grid_image_list.rb', line 21 def grid_image_list(={}) request( :path => 'grid/image/list', :query => ) end |
#grid_ip_list(options = {}) ⇒ Object
List ips
Parameters
-
options<~Hash>:
-
‘datacenter’<~String> - datacenter to limit results to
-
‘ip.state’<~String> - state to limit results to in ip.state
-
‘ip.type’<~String> - type to limit results to in ip.type
-
‘num_items’<~Integer> - Number of items to return
-
‘page’<~Integer> - Page index for paginated results
-
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
20 21 22 23 24 25 |
# File 'lib/rackspace-fog/go_grid/requests/compute/grid_ip_list.rb', line 20 def grid_ip_list(={}) request( :path => 'grid/ip/list', :query => ) end |
#grid_loadbalancer_list(options = {}) ⇒ Object
List load balancers
Parameters
-
options<~Hash>:
-
‘datacenter’<~String> - datacenter to limit results to
-
‘num_items’<~Integer> - Number of items to return
-
‘page’<~Integer> - Page index for paginated results
-
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
18 19 20 21 22 23 |
# File 'lib/rackspace-fog/go_grid/requests/compute/grid_loadbalancer_list.rb', line 18 def grid_loadbalancer_list(={}) request( :path => 'grid/loadbalancer/list', :query => ) end |
#grid_server_add(image, ip, name, server_ram, options = {}) ⇒ Object
Create a new server
Parameters
-
‘name’<~String> - name of the server, 20 or fewer characters
-
‘image’<~String> - image to use, in grid_image_list
-
‘ip’<~String> - initial public ip for this server
-
‘options’<~Hash>:
-
‘server.ram’<~String> - flavor to use, in common_lookup_list(‘server.ram’)
-
‘description’<~String> - description of this server
-
‘isSandbox’<~String> - treat this server as image sandbox? in [‘true’, ‘false’]
-
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rackspace-fog/go_grid/requests/compute/grid_server_add.rb', line 21 def grid_server_add(image, ip, name, server_ram, ={}) request( :path => 'grid/server/add', :query => { 'image' => image, 'ip' => ip, 'name' => name, 'server.ram' => server_ram }.merge!() ) end |
#grid_server_delete(server) ⇒ Object
Delete a server
Parameters
-
‘server’<~String> - id or name of server to delete
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
15 16 17 18 19 20 |
# File 'lib/rackspace-fog/go_grid/requests/compute/grid_server_delete.rb', line 15 def grid_server_delete(server) request( :path => 'grid/server/delete', :query => {'server' => server} ) end |
#grid_server_get(servers) ⇒ Object
Get one or more servers by name
Parameters
-
‘server’<~String> - id or name of server(s) to lookup
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
15 16 17 18 19 20 |
# File 'lib/rackspace-fog/go_grid/requests/compute/grid_server_get.rb', line 15 def grid_server_get(servers) request( :path => 'grid/server/get', :query => {'server' => [*servers]} ) end |
#grid_server_list(options = {}) ⇒ Object
List servers
Parameters
-
options<~Hash>:
-
‘datacenter’<~String> - datacenter to limit results to
-
‘isSandbox’<~String> - If true only returns Image Sandbox servers, in [‘false’, ‘true’]
-
‘num_items’<~Integer> - Number of items to return
-
‘page’<~Integer> - Page index for paginated results
-
‘server.type’<~String> - server type to limit results to
-
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
20 21 22 23 24 25 |
# File 'lib/rackspace-fog/go_grid/requests/compute/grid_server_list.rb', line 20 def grid_server_list(={}) request( :path => 'grid/server/list', :query => ) end |
#grid_server_power(server, power) ⇒ Object
Start, Stop or Restart a server
Parameters
-
‘server’<~String> - id or name of server to power
-
‘power’<~String> - power operation, in [‘restart’, ‘start’, ‘stop’]
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
16 17 18 19 20 21 |
# File 'lib/rackspace-fog/go_grid/requests/compute/grid_server_power.rb', line 16 def grid_server_power(server, power) request( :path => 'grid/server/power', :query => {'server' => server, 'power' => power} ) end |
#reload ⇒ Object
75 76 77 |
# File 'lib/rackspace-fog/go_grid/compute.rb', line 75 def reload @connection.reset end |
#request(params) ⇒ Object
79 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 |
# File 'lib/rackspace-fog/go_grid/compute.rb', line 79 def request(params) params = { :expects => 200, :method => 'GET' }.merge!(params) params[:query] ||= {} params[:query].merge!({ 'api_key' => @go_grid_api_key, 'format' => 'json', 'sig' => Digest::MD5.hexdigest("#{@go_grid_api_key}#{@go_grid_shared_secret}#{Time.now.to_i}"), 'v' => '1.5' }) begin response = @connection.request( params.merge!(:path => "#{@path}/#{params[:path]}") ) rescue Excon::Errors::HTTPStatusError => error raise case error when Excon::Errors::NotFound Fog::Compute::GoGrid::NotFound.slurp(error) else error end end unless response.body.empty? response.body = Fog::JSON.decode(response.body) end response end |
#support_password_get(id, options = {}) ⇒ Object
Get one or more passwords by id
Parameters
-
options<~Hash>:
-
‘id’<~String> - id of the password to retrieve
-
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
16 17 18 19 20 21 22 23 |
# File 'lib/rackspace-fog/go_grid/requests/compute/support_password_get.rb', line 16 def support_password_get(id, ={}) request( :path => 'support/password/get', :query => { 'id' => id }.merge!() ) end |
#support_password_list(options = {}) ⇒ Object
List passwords
Parameters
-
options<~Hash>:
-
‘datacenter’<~String> - datacenter to limit results to
-
‘isSandbox’<~String> - If true only returns Image Sandbox servers, in [‘false’, ‘true’]
-
‘num_items’<~Integer> - Number of items to return
-
‘page’<~Integer> - Page index for paginated results
-
‘server.type’<~String> - server type to limit results to
-
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
TODO: docs
20 21 22 23 24 25 |
# File 'lib/rackspace-fog/go_grid/requests/compute/support_password_list.rb', line 20 def support_password_list(={}) request( :path => 'support/password/list', :query => ) end |