mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
OpenStack custom exception cleanup.
Fixes an exception class name error for the custom OpenStack ServiceUnavailable exception. Previously the wrong class name was being used. Also cleans up and simplifies some other exceptions in the OpenStack implementation. (We can simply use NotFound from Fog::Errors instead)
This commit is contained in:
parent
e099801d02
commit
c544610791
3 changed files with 6 additions and 8 deletions
|
@ -26,9 +26,6 @@ module Fog
|
|||
end
|
||||
end
|
||||
|
||||
class InternalServerError < ServiceError; end
|
||||
class Conflict < ServiceError; end
|
||||
class NotFound < ServiceError; end
|
||||
class ServiceUnavailable < ServiceError; end
|
||||
|
||||
class BadRequest < ServiceError
|
||||
|
@ -103,7 +100,7 @@ module Fog
|
|||
|
||||
body = Fog::JSON.decode(response.body)
|
||||
if body['tenants'].empty?
|
||||
raise Errors::NotFound.new('No Tenant Found')
|
||||
raise Fog::Errors::NotFound.new('No Tenant Found')
|
||||
else
|
||||
options[:openstack_tenant] = body['tenants'].first['name']
|
||||
end
|
||||
|
@ -127,12 +124,12 @@ module Fog
|
|||
|
||||
message = "Could not find service #{missing}. Have #{available}"
|
||||
|
||||
raise Errors::NotFound, message
|
||||
raise Fog::Errors::NotFound, message
|
||||
end
|
||||
|
||||
if service['endpoints'].count > 1
|
||||
regions = service["endpoints"].map{ |e| e['region'] }.uniq.join(',')
|
||||
raise Errors::NotFound.new("Multiple regions available choose one of these '#{regions}'")
|
||||
raise Fog::Errors::NotFound.new("Multiple regions available choose one of these '#{regions}'")
|
||||
end
|
||||
|
||||
identity_service = body['access']['serviceCatalog'].
|
||||
|
|
|
@ -372,6 +372,7 @@ module Fog
|
|||
}
|
||||
|
||||
if @openstack_auth_uri.path =~ /\/v2.0\//
|
||||
|
||||
credentials = Fog::OpenStack.authenticate_v2(options, @connection_options)
|
||||
else
|
||||
credentials = Fog::OpenStack.authenticate_v1(options, @connection_options)
|
||||
|
@ -393,7 +394,7 @@ module Fog
|
|||
|
||||
@path.sub!(/\/$/, '')
|
||||
unless @path.match(/1\.1|v2/)
|
||||
raise Fog::Compute::OpenStack::ServiceUnavailable.new(
|
||||
raise Fog::OpenStack::Errors::ServiceUnavailable.new(
|
||||
"OpenStack binding only supports version 2 (a.k.a. 1.1)")
|
||||
end
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ Shindo.tests('OpenStack | authenticate', ['openstack']) do
|
|||
Excon.stub({ :method => 'POST', :path => "/v2.0/tokens" },
|
||||
{ :status => 200, :body => Fog::JSON.encode(body) })
|
||||
|
||||
raises(Fog::OpenStack::Errors::NotFound,
|
||||
raises(Fog::Errors::NotFound,
|
||||
'Could not find service network. Have compute, image') do
|
||||
Fog::OpenStack.authenticate_v2(
|
||||
:openstack_auth_uri => URI('http://example/v2.0/tokens'),
|
||||
|
|
Loading…
Reference in a new issue