mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
30 lines
756 B
Ruby
30 lines
756 B
Ruby
module Fog
|
|
module DNS
|
|
class Rackspace
|
|
|
|
module Callback
|
|
|
|
protected
|
|
|
|
def wait_for_job(job_id, timeout=Fog.timeout, interval=1)
|
|
retries = 5
|
|
response = nil
|
|
Fog.wait_for(timeout, interval) do
|
|
response = connection.callback job_id
|
|
if response.body['status'] == 'COMPLETED'
|
|
true
|
|
elsif response.body['status'] == 'ERROR'
|
|
raise Fog::DNS::Rackspace::CallbackError.new(response)
|
|
elsif retries == 0
|
|
raise Fog::Errors::Error.new("Wait on job #{job_id} took too long")
|
|
else
|
|
retries -= 1
|
|
false
|
|
end
|
|
end
|
|
response
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|