Replace url with endpoint in credentials provider
python-openstackclient has removed the --os-url option in [1]. This commit is part of the upcoming 4.0.0 release. The openstack provider relies on that for Keystone initial configuration, so we need to fix this or puppet-keystone will be broken. [2] is a more solid long-term solution, but this can work as a stop-gap. [1] - https://review.opendev.org/677795 [2] - https://review.opendev.org/630714 Depends-On: https://review.opendev.org/682108 Depends-On: https://review.opendev.org/682415 Change-Id: Id0bc07f352d0b545e60aabd4523536dfc7fc59a8
This commit is contained in:
@@ -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
|
||||
@@ -239,9 +242,15 @@ 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.endpoint = service_url
|
||||
raise error unless @credentials.service_token_set?
|
||||
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
|
||||
|
||||
|
Reference in New Issue
Block a user