replace Fog::Errors with Excon::Errors, add 409 conflicts for non-built rackspace server delete

This commit is contained in:
Wesley Beary 2009-11-08 12:16:52 -08:00
parent f00f77638e
commit fa1481e9f2
48 changed files with 56 additions and 52 deletions

View File

@ -166,7 +166,6 @@ module Fog
response = @connection.request({
:body => body,
:expects => 200,
:error_parser => Fog::Errors::Parser.new,
:headers => { 'Content-Type' => 'application/x-www-form-urlencoded' },
:host => @host,
:method => 'POST',

View File

@ -42,7 +42,7 @@ module Fog
if public_ip
all(public_ip).first
end
rescue Fog::Errors::BadRequest
rescue Excon::Errors::BadRequest
nil
end

View File

@ -38,7 +38,7 @@ module Fog
if instance_id
all(instance_id).first
end
rescue Fog::Errors::BadRequest
rescue Excon::Errors::BadRequest
nil
end

View File

@ -36,7 +36,7 @@ module Fog
if key_name
all(key_name).first
end
rescue Fog::Errors::BadRequest
rescue Excon::Errors::BadRequest
nil
end

View File

@ -36,7 +36,7 @@ module Fog
if group_name
all(group_name).first
end
rescue Fog::Errors::BadRequest
rescue Excon::Errors::BadRequest
nil
end

View File

@ -42,7 +42,7 @@ module Fog
if snapshot_id
all(snapshot_id).first
end
rescue Fog::Errors::BadRequest
rescue Excon::Errors::BadRequest
nil
end

View File

@ -42,7 +42,7 @@ module Fog
if volume_id
all(volume_id).first
end
rescue Fog::Errors::BadRequest
rescue Excon::Errors::BadRequest
nil
end

View File

@ -12,7 +12,7 @@ module Fog
def destroy
connection.delete_bucket(@name)
true
rescue Fog::Errors::NotFound
rescue Excon::Errors::NotFound
false
end

View File

@ -51,7 +51,7 @@ module Fog
}.merge!(object))
end
bucket
rescue Fog::Errors::NotFound
rescue Excon::Errors::NotFound
nil
end

View File

@ -46,7 +46,7 @@ module Fog
:connection => connection
}.merge!(object_data))
object
rescue Fog::Errors::NotFound
rescue Excon::Errors::NotFound
nil
end
@ -70,7 +70,7 @@ module Fog
:connection => connection
}.merge!(object_data))
object
rescue Fog::Errors::NotFound
rescue Excon::Errors::NotFound
nil
end

View File

@ -47,7 +47,7 @@ else
}
else
response.status = 400
raise(Fog::Errors.status_error(200, 400, response))
raise(Excon::Errors.status_error(200, 400, response))
end
response
end

View File

@ -60,7 +60,7 @@ else
}.merge!(data)
else
response.status = 400
raise(Fog::Errors.status_error(200, 400, response))
raise(Excon::Errors.status_error(200, 400, response))
end
else
response.status = 400

View File

@ -48,7 +48,7 @@ else
}.merge!(data)
else
response.status = 400
raise(Fog::Errors.status_error(200, 400, response))
raise(Excon::Errors.status_error(200, 400, response))
end
response
end

View File

@ -49,7 +49,7 @@ else
}
else
response.status = 400
raise(Fog::Errors.status_error(200, 400, response))
raise(Excon::Errors.status_error(200, 400, response))
end
response
end

View File

@ -53,7 +53,7 @@ else
}.merge!(data)
else
response.status = 400
raise(Fog::Errors.status_error(200, 400, response))
raise(Excon::Errors.status_error(200, 400, response))
end
response
end

View File

@ -41,7 +41,7 @@ else
}
else
response.status = 400
raise(Fog::Errors.status_error(200, 400, response))
raise(Excon::Errors.status_error(200, 400, response))
end
response
end

View File

@ -41,7 +41,7 @@ else
}
else
response.status = 400
raise(Fog::Errors.status_error(200, 400, response))
raise(Excon::Errors.status_error(200, 400, response))
end
response
end

View File

@ -43,7 +43,7 @@ else
}
else
response.status = 400
raise(Fog::Errors.status_error(200, 400, response))
raise(Excon::Errors.status_error(200, 400, response))
end
response
end

View File

@ -49,7 +49,7 @@ else
}
else
response.status = 400
raise(Fog::Errors.status_error(200, 400, response))
raise(Excon::Errors.status_error(200, 400, response))
end
response
end

View File

@ -104,7 +104,7 @@ else
}
else
response.status = 400
raise(Fog::Errors.status_error(200, 400, response))
raise(Excon::Errors.status_error(200, 400, response))
end
response
end

View File

@ -51,7 +51,7 @@ else
}
else
response.status = 400
raise(Fog::Errors.status_error(200, 400, response))
raise(Excon::Errors.status_error(200, 400, response))
end
response
end

View File

@ -59,7 +59,7 @@ else
}
else
response.status = 400
raise(Fog::Errors.status_error(200, 400, response))
raise(Excon::Errors.status_error(200, 400, response))
end
response
end

View File

@ -66,7 +66,7 @@ else
}
else
response.status = 400
raise(Fog::Errors.status_error(200, 400, response))
raise(Excon::Errors.status_error(200, 400, response))
end
response
end

View File

@ -73,7 +73,7 @@ else
}
else
response.status = 400
raise(Fog::Errors.status_error(200, 400, response))
raise(Excon::Errors.status_error(200, 400, response))
end
response
end

View File

@ -50,7 +50,7 @@ else
}.merge!(data)
else
response.status = 400
raise(Fog::Errors.status_error(200, 400, response))
raise(Excon::Errors.status_error(200, 400, response))
end
response
end

View File

@ -43,7 +43,7 @@ else
}
else
response.status = 400
raise(Fog::Errors.status_error(200, 400, response))
raise(Excon::Errors.status_error(200, 400, response))
end
response
end

View File

@ -45,7 +45,7 @@ else
}
else
response.status = 400
raise(Fog::Errors.status_error(200, 400, response))
raise(Excon::Errors.status_error(200, 400, response))
end
response
end

View File

@ -45,7 +45,7 @@ else
}
else
response.status = 400
raise(Fog::Errors.status_error(200, 400, response))
raise(Excon::Errors.status_error(200, 400, response))
end
response
end

View File

@ -38,7 +38,7 @@ else
}
else
response.status = 400
raise(Fog::Errors.status_error(200, 400, response))
raise(Excon::Errors.status_error(200, 400, response))
end
response
end

View File

@ -72,7 +72,7 @@ else
end
else
response.status = 400
raise(Fog::Errors.status_error(200, 400, response))
raise(Excon::Errors.status_error(200, 400, response))
end
response
end

View File

@ -66,7 +66,7 @@ else
}
else
response.status = 404
raise(Fog::Errors.status_error(200, 404, response))
raise(Excon::Errors.status_error(200, 404, response))
end
response

View File

@ -35,10 +35,10 @@ else
response = Fog::Response.new
if Fog::AWS::S3.data[:buckets][bucket_name].nil?
response.status = 404
raise(Fog::Errors.status_error(204, 404, response))
raise(Excon::Errors.status_error(204, 404, response))
elsif Fog::AWS::S3.data[:buckets][bucket_name] && !Fog::AWS::S3.data[:buckets][bucket_name][:objects].empty?
response.status = 409
raise(Fog::Errors.status_error(204, 409, response))
raise(Excon::Errors.status_error(204, 409, response))
else
Fog::AWS::S3.data[:buckets].delete(bucket_name)
response.status = 204

View File

@ -40,7 +40,7 @@ else
bucket[:objects].delete(object_name)
else
response.status = 404
raise(Fog::Errors.status_error(204, 404, response))
raise(Excon::Errors.status_error(204, 404, response))
end
response
end

View File

@ -94,7 +94,7 @@ else
end
else
response.status = 404
raise(Fog::Errors.status_error(200, 404, response))
raise(Excon::Errors.status_error(200, 404, response))
end
response
end

View File

@ -41,7 +41,7 @@ else
response.body = {'LocationConstraint' => bucket['LocationConstraint'] }
else
response.status = 404
raise(Fog::Errors.status_error(200, 404, response))
raise(Excon::Errors.status_error(200, 404, response))
end
response
end

View File

@ -108,7 +108,7 @@ else
end
else
response.status = 404
raise(Fog::Errors.status_error(200, 404, response))
raise(Excon::Errors.status_error(200, 404, response))
end
response
end

View File

@ -41,7 +41,7 @@ else
response.body = { 'Payer' => bucket['Payer'] }
else
response.status = 404
raise(Fog::Errors.status_error(200, 404, response))
raise(Excon::Errors.status_error(200, 404, response))
end
response
end

View File

@ -64,7 +64,7 @@ else
bucket[:objects][object_name]['Content-Type'] = data[:headers]['Content-Type']
else
response.status = 404
raise(Fog::Errors.status_error(200, 404, response))
raise(Excon::Errors.status_error(200, 404, response))
end
response
end

View File

@ -43,7 +43,7 @@ else
bucket['Payer'] = payer
else
response.status = 404
raise(Fog::Errors.status_error(200, 404, response))
raise(Excon::Errors.status_error(200, 404, response))
end
response
end

View File

@ -59,7 +59,7 @@ else
}
else
response.status = 400
raise(Fog::Errors.status_error(200, 400, response))
raise(Excon::Errors.status_error(200, 400, response))
end
response
end

View File

@ -60,7 +60,7 @@ else
}
else
response.status = 400
raise(Fog::Errors.status_error(200, 400, response))
raise(Excon::Errors.status_error(200, 400, response))
end
response
end

View File

@ -68,7 +68,7 @@ else
}
else
response.status = 400
raise(Fog::Errors.status_error(200, 400, response))
raise(Excon::Errors.status_error(200, 400, response))
end
response
end

View File

@ -63,7 +63,7 @@ else
}
else
response.status = 400
raise(Fog::Errors.status_error(200, 400, response))
raise(Excon::Errors.status_error(200, 400, response))
end
response
end

View File

@ -99,7 +99,6 @@ module Fog
response = @connection.request({
:block => params[:block],
:body => params[:body],
:error_parser => Fog::Errors::Parser.new,
:expects => params[:expects],
:headers => params[:headers],
:host => params[:host],

View File

@ -45,4 +45,4 @@ module Fog
end
end
Fog::Rackspace.reload
Fog::Rackspace.reload

View File

@ -26,7 +26,7 @@ module Fog
def get(id)
connection.get_server_details(id)
rescue Fog::Errors::NotFound
rescue Excon::Errors::NotFound
nil
end

View File

@ -29,8 +29,14 @@ else
def delete_server(id)
response = Fog::Response.new
if Fog::Rackspace::Servers.data[:servers].delete(id)
response.status = 202
if server = Fog::Rackspace::Servers.data[:servers][id]
if server['STATUS'] == 'BUILD'
response.status = 409
raise(Excon::Errors.status_error(200, 400, response))
else
Fog::Rackspace::Servers.delete(id)
response.status = 202
end
else
response.status = 404
end

View File

@ -4,9 +4,9 @@ describe 'Rackspace::Servers.create_server' do
describe 'success' do
after(:each) do
eventually(128) do
# eventually(128) do
servers.delete_server(@server_id)
end
# end
end
it "should return proper attributes" do