Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to connect to identity_v3 endpoint even if it's not in the catalog #268

Merged
merged 1 commit into from
Feb 21, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion lib/fog/openstack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def self.authenticate_v2(options, connection_options = {})

# Keystone Style Auth
def self.authenticate_v3(options, connection_options = {})
uri = options[:openstack_auth_uri]
uri = options[:openstack_auth_uri]
project_name = options[:openstack_project_name]
service_type = options[:openstack_service_type]
service_name = options[:openstack_service_name]
Expand Down Expand Up @@ -302,6 +302,26 @@ def self.authenticate_v3(options, connection_options = {})
service = get_service_v3(body, service_type, service_name, openstack_region, options)
end

# If no identity endpoint is found, try the auth uri (slicing /auth/tokens)
# It covers the case where identityv3 endpoint is not present in the catalog but we have to use it
unless service
if service_type.include? "identity"
identity_uri = uri.to_s.sub('/auth/tokens', '')
response = Fog::Core::Connection.new(identity_uri, false, connection_options).request({:method => 'GET'})
if response.status == 200
service = {
"endpoints" => [{
"url" => identity_uri,
"region" => openstack_region,
"interface" => endpoint_type
}],
"type" => service_type,
"name" => service_name
}
end
end
end

unless service
available_services = body['token']['catalog'].map { |service|
service['type']
Expand Down