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

[digitalocean|compute] Implemented Server.reboot

- Added reboot_server request
- Added required tests
This commit is contained in:
Sergio Rubio 2013-02-06 21:23:33 +01:00
parent 7183f1e55c
commit 06467aeec7
5 changed files with 54 additions and 14 deletions

View file

@ -28,6 +28,7 @@ module Fog
request :get_server_details
request :create_server
request :destroy_server
request :reboot_server
# request :digitalocean_resize

View file

@ -20,7 +20,7 @@ module Fog
#
# The preferred method of rebooting a server.
def reboot
raise NotImplementedError
service.reboot_server id
end
# Reboot the server (hard reboot).

View file

@ -0,0 +1,25 @@
module Fog
module Compute
class DigitalOcean
class Real
def reboot_server( id )
request(
:expects => [200],
:method => 'GET',
:path => "droplets/#{id}/reboot"
)
end
end
class Mock
def reboot_server( id )
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -1,18 +1,8 @@
Shindo.tests("Fog::Compute[:digitalocean] | server model", ['digitalocean', 'compute']) do
service = Fog::Compute[:digitalocean]
server = service.servers.create :name => 'fog-test',
:image_id => service.images.first.id,
:region_id => service.regions.first.id,
:flavor_id => service.flavors.first.id
server = fog_test_server
tests('The server model should') do
# Wait for the server to come up
begin
server.wait_for(120) { server.reload rescue nil; server.ready? }
rescue Fog::Errors::TimeoutError
# Server bootstrap took more than 120 secs!
end
tests('have the action') do
test('reload') { server.respond_to? 'reload' }
@ -40,9 +30,13 @@ Shindo.tests("Fog::Compute[:digitalocean] | server model", ['digitalocean', 'com
end
end
end
end
test('reboot the server') do
server.reboot
server.wait_for { server.status == 'off' }
server.status == 'off'
end
server.destroy
end
end

View file

@ -0,0 +1,20 @@
Shindo.tests('Fog::Compute[:digitalocean] | reboot_server request', ['digitalocean', 'compute']) do
server = fog_test_server
tests('success') do
tests('#reboot_server') do
test('returns 200') do
service.reboot_server(server.id).status == 200
end
test('state is off') do
server.wait_for { server.status == 'off' }
server.status == 'off'
end
end
end
end