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:
parent
f00f77638e
commit
fa1481e9f2
48 changed files with 56 additions and 52 deletions
|
@ -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',
|
||||
|
|
|
@ -42,7 +42,7 @@ module Fog
|
|||
if public_ip
|
||||
all(public_ip).first
|
||||
end
|
||||
rescue Fog::Errors::BadRequest
|
||||
rescue Excon::Errors::BadRequest
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ module Fog
|
|||
if instance_id
|
||||
all(instance_id).first
|
||||
end
|
||||
rescue Fog::Errors::BadRequest
|
||||
rescue Excon::Errors::BadRequest
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ module Fog
|
|||
if key_name
|
||||
all(key_name).first
|
||||
end
|
||||
rescue Fog::Errors::BadRequest
|
||||
rescue Excon::Errors::BadRequest
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ module Fog
|
|||
if group_name
|
||||
all(group_name).first
|
||||
end
|
||||
rescue Fog::Errors::BadRequest
|
||||
rescue Excon::Errors::BadRequest
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ module Fog
|
|||
if snapshot_id
|
||||
all(snapshot_id).first
|
||||
end
|
||||
rescue Fog::Errors::BadRequest
|
||||
rescue Excon::Errors::BadRequest
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ module Fog
|
|||
if volume_id
|
||||
all(volume_id).first
|
||||
end
|
||||
rescue Fog::Errors::BadRequest
|
||||
rescue Excon::Errors::BadRequest
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ module Fog
|
|||
def destroy
|
||||
connection.delete_bucket(@name)
|
||||
true
|
||||
rescue Fog::Errors::NotFound
|
||||
rescue Excon::Errors::NotFound
|
||||
false
|
||||
end
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ module Fog
|
|||
}.merge!(object))
|
||||
end
|
||||
bucket
|
||||
rescue Fog::Errors::NotFound
|
||||
rescue Excon::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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],
|
||||
|
|
|
@ -45,4 +45,4 @@ module Fog
|
|||
|
||||
end
|
||||
end
|
||||
Fog::Rackspace.reload
|
||||
Fog::Rackspace.reload
|
||||
|
|
|
@ -26,7 +26,7 @@ module Fog
|
|||
|
||||
def get(id)
|
||||
connection.get_server_details(id)
|
||||
rescue Fog::Errors::NotFound
|
||||
rescue Excon::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue