Merge "Handle new message format for openstackclient >= 7.0.0"
This commit is contained in:
commit
a9a4bdf0f3
@ -139,16 +139,20 @@ class Puppet::Provider::Keystone < Puppet::Provider::Openstack
|
||||
|
||||
def self.fetch_user(name, domain)
|
||||
domain ||= default_domain
|
||||
user = system_request('user', 'show',
|
||||
[name, '--domain', domain],
|
||||
{:no_retry_exception_msgs => /No user with a name or ID/})
|
||||
user = system_request(
|
||||
'user', 'show',
|
||||
[name, '--domain', domain],
|
||||
{
|
||||
# TODO(tkajinam): Remove the first item after 2024.2 release.
|
||||
:no_retry_exception_msgs => [/No user with a name or ID/, /No user found for/]
|
||||
})
|
||||
# The description key is only set if it exists
|
||||
if user and user.key?(:id) and !user.key?(:description)
|
||||
user[:description] = ''
|
||||
end
|
||||
user
|
||||
rescue Puppet::ExecutionFailure => e
|
||||
raise e unless e.message =~ /No user with a name or ID/
|
||||
raise e unless (e.message =~ /No user with a name or ID/ or e.message =~ /No user found for/)
|
||||
end
|
||||
|
||||
def self.get_auth_url
|
||||
|
@ -74,7 +74,7 @@ id="newid"
|
||||
set_env
|
||||
end
|
||||
|
||||
it 'should be false if the user does not exist' do
|
||||
it 'should be false if the user does not exist (osc<7)' do
|
||||
expect(klass).to receive(:request_timeout).and_return(0)
|
||||
expect(klass).to receive(:openstack)
|
||||
.with('user', 'show', '--format', 'shell', ['no_user', '--domain', 'Default'])
|
||||
@ -83,6 +83,15 @@ id="newid"
|
||||
expect(klass.fetch_user('no_user', 'Default')).to be_falsey
|
||||
end
|
||||
|
||||
it 'should be false if the user does not exist (osc>=7)' do
|
||||
expect(klass).to receive(:request_timeout).and_return(0)
|
||||
expect(klass).to receive(:openstack)
|
||||
.with('user', 'show', '--format', 'shell', ['no_user', '--domain', 'Default'])
|
||||
.exactly(1).times
|
||||
.and_raise(Puppet::ExecutionFailure, "Execution of '/usr/bin/openstack user show --format shell no_user' returned 1: No user found for no_user")
|
||||
expect(klass.fetch_user('no_user', 'Default')).to be_falsey
|
||||
end
|
||||
|
||||
it 'should return the user' do
|
||||
expect(klass).to receive(:openstack)
|
||||
.with('user', 'show', '--format', 'shell', ['The User', '--domain', 'Default'])
|
||||
|
Loading…
x
Reference in New Issue
Block a user