mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[GoGrid] cleanup, add/delete/get/power servers
This commit is contained in:
parent
29d95e5113
commit
e860502732
10 changed files with 145 additions and 10 deletions
|
@ -12,7 +12,11 @@ module Fog
|
|||
request 'grid_image_list'
|
||||
request 'grid_ip_list'
|
||||
request 'grid_loadbalancer_list'
|
||||
request 'grid_server_add'
|
||||
request 'grid_server_delete'
|
||||
request 'grid_server_get'
|
||||
request 'grid_server_list'
|
||||
request 'grid_server_power'
|
||||
|
||||
class Mock
|
||||
include Collections
|
||||
|
@ -55,6 +59,11 @@ module Fog
|
|||
end
|
||||
|
||||
def request(params)
|
||||
params = {
|
||||
:expects => 200,
|
||||
:method => 'GET'
|
||||
}.merge!(params)
|
||||
|
||||
params[:query] ||= {}
|
||||
params[:query].merge!({
|
||||
'api_key' => @go_grid_api_key,
|
||||
|
|
|
@ -16,8 +16,6 @@ module Fog
|
|||
# TODO: docs
|
||||
def common_lookup_list(lookup, options={})
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:path => 'common/lookup/list',
|
||||
:query => {'lookup' => lookup}.merge!(options)
|
||||
)
|
||||
|
|
|
@ -19,8 +19,6 @@ module Fog
|
|||
# TODO: docs
|
||||
def grid_image_list(options={})
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:path => 'grid/image/list',
|
||||
:query => options
|
||||
)
|
||||
|
|
|
@ -18,8 +18,6 @@ module Fog
|
|||
# TODO: docs
|
||||
def grid_ip_list(options={})
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:path => 'grid/ip/list',
|
||||
:query => options
|
||||
)
|
||||
|
|
|
@ -16,8 +16,6 @@ module Fog
|
|||
# TODO: docs
|
||||
def grid_loadbalancer_list(options={})
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:path => 'grid/loadbalancer/list',
|
||||
:query => options
|
||||
)
|
||||
|
|
42
lib/fog/go_grid/requests/grid_server_add.rb
Normal file
42
lib/fog/go_grid/requests/grid_server_add.rb
Normal file
|
@ -0,0 +1,42 @@
|
|||
module Fog
|
||||
module GoGrid
|
||||
class Real
|
||||
|
||||
# Create a new server
|
||||
#
|
||||
# ==== Parameters
|
||||
# * 'image'<~String> - image to use, in grid_image_list
|
||||
# * 'ip'<~String> - initial public ip for this server
|
||||
# * 'name'<~String> - name of the server, 20 or fewer characters
|
||||
# * 'server_ram'<~String> - flavor to use, in common_lookup_list('server.ram')
|
||||
# * 'options'<~Hash>:
|
||||
# * '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
|
||||
def grid_server_add(image, ip, name, server_ram, options={})
|
||||
request(
|
||||
:path => 'grid/server/add',
|
||||
:query => {
|
||||
'image' => image,
|
||||
'ip' => ip,
|
||||
'name' => name,
|
||||
'server.ram' => server_ram
|
||||
}.merge!(options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def grid_server_add(image, ip, name, server_ram, options={})
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
31
lib/fog/go_grid/requests/grid_server_delete.rb
Normal file
31
lib/fog/go_grid/requests/grid_server_delete.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
module Fog
|
||||
module GoGrid
|
||||
class Real
|
||||
|
||||
# Delete a server
|
||||
#
|
||||
# ==== Parameters
|
||||
# * 'server'<~String> - id or name of server to delete
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Array>:
|
||||
# TODO: docs
|
||||
def grid_server_delete(server)
|
||||
request(
|
||||
:path => 'grid/server/delete',
|
||||
:query => {'server' => server}
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def grid_server_delete(server)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
31
lib/fog/go_grid/requests/grid_server_get.rb
Normal file
31
lib/fog/go_grid/requests/grid_server_get.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
module Fog
|
||||
module GoGrid
|
||||
class Real
|
||||
|
||||
# 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
|
||||
def grid_server_get(servers)
|
||||
request(
|
||||
:path => 'grid/server/get',
|
||||
:query => {'server' => [*servers]}
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def grid_server_get(servers)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -18,8 +18,6 @@ module Fog
|
|||
# TODO: docs
|
||||
def grid_server_list(options={})
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:path => 'grid/server/list',
|
||||
:query => options
|
||||
)
|
||||
|
|
32
lib/fog/go_grid/requests/grid_server_power.rb
Normal file
32
lib/fog/go_grid/requests/grid_server_power.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
module Fog
|
||||
module GoGrid
|
||||
class Real
|
||||
|
||||
# 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
|
||||
def grid_server_delete(server, power)
|
||||
request(
|
||||
:path => 'grid/server/power',
|
||||
:query => {'server' => server}
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def grid_server_delete(server)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue