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:
parent
7183f1e55c
commit
06467aeec7
5 changed files with 54 additions and 14 deletions
|
@ -28,6 +28,7 @@ module Fog
|
||||||
request :get_server_details
|
request :get_server_details
|
||||||
request :create_server
|
request :create_server
|
||||||
request :destroy_server
|
request :destroy_server
|
||||||
|
request :reboot_server
|
||||||
|
|
||||||
# request :digitalocean_resize
|
# request :digitalocean_resize
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ module Fog
|
||||||
#
|
#
|
||||||
# The preferred method of rebooting a server.
|
# The preferred method of rebooting a server.
|
||||||
def reboot
|
def reboot
|
||||||
raise NotImplementedError
|
service.reboot_server id
|
||||||
end
|
end
|
||||||
|
|
||||||
# Reboot the server (hard reboot).
|
# Reboot the server (hard reboot).
|
||||||
|
|
25
lib/fog/digitalocean/requests/compute/reboot_server.rb
Normal file
25
lib/fog/digitalocean/requests/compute/reboot_server.rb
Normal 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
|
|
@ -1,18 +1,8 @@
|
||||||
Shindo.tests("Fog::Compute[:digitalocean] | server model", ['digitalocean', 'compute']) do
|
Shindo.tests("Fog::Compute[:digitalocean] | server model", ['digitalocean', 'compute']) do
|
||||||
|
|
||||||
service = Fog::Compute[:digitalocean]
|
server = fog_test_server
|
||||||
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
|
|
||||||
|
|
||||||
tests('The server model should') do
|
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
|
tests('have the action') do
|
||||||
test('reload') { server.respond_to? 'reload' }
|
test('reload') { server.respond_to? 'reload' }
|
||||||
|
@ -40,9 +30,13 @@ Shindo.tests("Fog::Compute[:digitalocean] | server model", ['digitalocean', 'com
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
test('reboot the server') do
|
||||||
|
server.reboot
|
||||||
|
server.wait_for { server.status == 'off' }
|
||||||
|
server.status == 'off'
|
||||||
end
|
end
|
||||||
|
|
||||||
server.destroy
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
20
tests/digitalocean/requests/compute/reboot_server_tests.rb
Normal file
20
tests/digitalocean/requests/compute/reboot_server_tests.rb
Normal 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
|
Loading…
Reference in a new issue