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

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

@ -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