1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Added server power cycle actions + basic tests.

TODO: More complex scenarios, edges cases,
plus feedback tests for state following each
power cycle action.
This commit is contained in:
Sean Handley 2012-07-15 12:30:45 +02:00
parent 2f4ac6433e
commit b670d5e719
5 changed files with 69 additions and 2 deletions

View file

@ -0,0 +1,13 @@
module Fog
module Compute
class Serverlove
class Real
def reset_server(server_id)
request(:method => "post", :path => "/servers/#{server_id}/reset", :expects => 204)
end
end
end
end
end

View file

@ -0,0 +1,13 @@
module Fog
module Compute
class Serverlove
class Real
def shutdown_server(server_id)
request(:method => "post", :path => "/servers/#{server_id}/shutdown", :expects => 204)
end
end
end
end
end

View file

@ -0,0 +1,13 @@
module Fog
module Compute
class Serverlove
class Real
def start_server(server_id)
request(:method => "post", :path => "/servers/#{server_id}/start", :expects => 204)
end
end
end
end
end

View file

@ -0,0 +1,13 @@
module Fog
module Compute
class Serverlove
class Real
def stop_server(server_id)
request(:method => "post", :path => "/servers/#{server_id}/stop", :expects => 204)
end
end
end
end
end

View file

@ -13,7 +13,7 @@ Shindo.tests('Fog::Compute[:serverlove] | server requests', ['serverlove']) do
tests('success') do tests('success') do
attributes = { 'name' => 'Test', 'cpu' => '1000' } attributes = { 'name' => 'Test', 'cpu' => '1000', 'persistent' => 'true' }
tests("#create_server").formats(@server_format) do tests("#create_server").formats(@server_format) do
@server = Fog::Compute[:serverlove].create_server(attributes).body @server = Fog::Compute[:serverlove].create_server(attributes).body
@ -29,6 +29,21 @@ Shindo.tests('Fog::Compute[:serverlove] | server requests', ['serverlove']) do
Fog::Compute[:serverlove].servers.get(@server['server']).name == "Diff" Fog::Compute[:serverlove].servers.get(@server['server']).name == "Diff"
end end
tests("#start_server").succeeds do
Fog::Compute[:serverlove].start_server(@server['server'])
end
tests("#reset_server").succeeds do
Fog::Compute[:serverlove].reset_server(@server['server'])
end
tests("#shutdown_server").succeeds do
Fog::Compute[:serverlove].shutdown_server(@server['server'])
end
tests("#stop_server").succeeds do
Fog::Compute[:serverlove].stop_server(@server['server'])
end
tests("#destroy_server").succeeds do tests("#destroy_server").succeeds do
Fog::Compute[:serverlove].destroy_server(@server['server']) Fog::Compute[:serverlove].destroy_server(@server['server'])