Wait for volumes to become available.

This commit is contained in:
Ash Wilson 2014-10-01 10:16:09 -04:00
parent 9a70adea0f
commit 29fb4d28de
2 changed files with 15 additions and 0 deletions

View File

@ -60,6 +60,19 @@ module Shindo
sleep 30 unless Fog.mocking?
end
def wait_for_volume_state(service, volume_id, state)
current_state = nil
until current_state == state
current_state = service.get_volume(volume_id).body['volume']['status']
if current_state == 'error'
Fog::Logger.warning caller
Fog::Logger.warning "Volume is in an error state!"
return
end
sleep 10 unless Fog.mocking?
end
end
def rackspace_test_image_id(service)
image_id = Fog.credentials[:rackspace_image_id]
# I chose to use the first Ubuntu because it will work with the smallest flavor and it doesn't require a license

View File

@ -56,6 +56,8 @@ Shindo.tests('Fog::Rackspace::BlockStorage | volume_tests', ['rackspace']) do
ids.each do |id|
tests("#delete_volume(#{id})").succeeds do
wait_for_volume_state(service, id, 'available')
service.delete_volume(id)
end
end