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

[rackspace|dns] error state callbacks now return an error

This commit is contained in:
Brian Hartsock 2011-11-24 11:29:12 -05:00
parent 9a737babc5
commit 179bae1990
3 changed files with 25 additions and 1 deletions

View file

@ -5,6 +5,15 @@ module Fog
module DNS
class Rackspace < Fog::Service
class CallbackError < Fog::Errors::Error
attr_reader :response, :message, :details
def initialize(response)
@response = response
@message = response.body['error']['message']
@details = response.body['error']['details']
end
end
US_ENDPOINT = 'https://dns.api.rackspacecloud.com/v1.0'
UK_ENDPOINT = 'https://lon.dns.api.rackspacecloud.com/v1.0'

View file

@ -11,8 +11,10 @@ module Fog
response = nil
Fog.wait_for(timeout, interval) do
response = connection.callback job_id
if response.body['status'] != 'RUNNING'
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

View file

@ -0,0 +1,13 @@
Shindo.tests('Fog::Rackspace::DNS | zone', ['rackspace']) do
provider = Fog::DNS[:rackspace]
domain_name = uniq_id + '.com'
zone = provider.zones.create({:domain => domain_name, :email => 'hostmaster@' + domain_name})
tests('adding same domain twice throws error').raises(Fog::DNS::Rackspace::CallbackError) do
provider.zones.create({:domain => domain_name, :email => 'hostmaster@' + domain_name})
end
zone.destroy
end