Merge "Replace url with endpoint in credentials provider"
This commit is contained in:
commit
329ab549a2
|
@ -208,7 +208,10 @@ class Puppet::Provider::Keystone < Puppet::Provider::Openstack
|
|||
|
||||
def self.get_service_url
|
||||
service_url = nil
|
||||
if ENV['OS_URL']
|
||||
if ENV['OS_ENDPOINT']
|
||||
service_url = ENV['OS_ENDPOINT'].dup
|
||||
# Compatibility with pre-4.0.0 openstackclient
|
||||
elsif ENV['OS_URL']
|
||||
service_url = ENV['OS_URL'].dup
|
||||
elsif public_endpoint
|
||||
service_url = public_endpoint
|
||||
|
@ -238,10 +241,16 @@ class Puppet::Provider::Keystone < Puppet::Provider::Openstack
|
|||
|
||||
def self.request_by_service_token(service, action, error, properties=nil, options={})
|
||||
properties ||= []
|
||||
@credentials.token = admin_token
|
||||
@credentials.url = service_url
|
||||
@credentials.token = admin_token
|
||||
@credentials.endpoint = service_url
|
||||
raise error unless @credentials.service_token_set?
|
||||
Puppet::Provider::Openstack.request(service, action, properties, @credentials, options)
|
||||
begin
|
||||
Puppet::Provider::Openstack.request(service, action, properties, @credentials, options)
|
||||
rescue Puppet::ExecutionFailure, Puppet::Error::OpenstackUnauthorizedError
|
||||
# openstackclient < 4.0.0 does not support --os-endpoint and requires --os-url
|
||||
@credentials.url = service_url
|
||||
Puppet::Provider::Openstack.request(service, action, properties, @credentials, options)
|
||||
end
|
||||
end
|
||||
|
||||
def self.service_url
|
||||
|
|
|
@ -260,13 +260,13 @@ id="the_user_id"
|
|||
end
|
||||
|
||||
describe '#get_service_url when retrieving the security token' do
|
||||
it 'should return nothing when OS_URL is not defined in environment' do
|
||||
it 'should return nothing when OS_ENDPOINT is not defined in environment' do
|
||||
ENV.clear
|
||||
expect(klass.get_service_url).to be_nil
|
||||
end
|
||||
|
||||
it 'should return the OS_URL from the environment' do
|
||||
ENV['OS_URL'] = 'http://127.0.0.1:5001/v3'
|
||||
it 'should return the OS_ENDPOINT from the environment' do
|
||||
ENV['OS_ENDPOINT'] = 'http://127.0.0.1:5001/v3'
|
||||
expect(klass.get_service_url).to eq('http://127.0.0.1:5001/v3')
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue