Fix authtoken parameters to load service user credential

This change fixes the old authtoken parameters used to load credential
of the mistral service user, because these are no longer configured by
puppet-mistral.

Closes-Bug: #1961601
Change-Id: Idb55a4a64edd35b8fb9608fc36e2a91502f5de14
This commit is contained in:
Takashi Kajinami
2022-02-22 00:01:27 +09:00
parent 91171b8a89
commit 1f858293f3
3 changed files with 57 additions and 5 deletions

View File

@@ -17,9 +17,9 @@ class Puppet::Provider::Mistral < Puppet::Provider::MistralWorkflowRequester
def self.mistral_request(service, action, error, properties=nil)
properties ||= []
@credentials.username = mistral_credentials['admin_username']
@credentials.password = mistral_credentials['admin_password']
@credentials.project_name = mistral_credentials['admin_project_name']
@credentials.username = mistral_credentials['username']
@credentials.password = mistral_credentials['password']
@credentials.project_name = mistral_credentials['project_name']
@credentials.auth_url = auth_endpoint
if mistral_credentials['region_name']
@credentials.region_name = mistral_credentials['region_name']
@@ -57,8 +57,7 @@ class Puppet::Provider::Mistral < Puppet::Provider::MistralWorkflowRequester
end
def self.get_mistral_credentials
auth_keys = ['auth_url', 'admin_tenant_name', 'admin_user',
'admin_password']
auth_keys = ['auth_url', 'project_name', 'username', 'password']
conf = mistral_conf
if conf and conf['keystone_authtoken'] and
auth_keys.all?{|k| !conf['keystone_authtoken'][k].nil?}

View File

@@ -0,0 +1,5 @@
---
fixes:
- |
Now the base ``Puppet::Provider::Mistral`` class loads service user
credential using the proper keystoneauth parameters.

View File

@@ -0,0 +1,48 @@
require 'puppet'
require 'spec_helper'
require 'puppet/provider/mistral'
require 'tempfile'
klass = Puppet::Provider::Mistral
describe Puppet::Provider::Mistral do
after :each do
klass.reset
end
describe 'when retrieving the auth credentials' do
it 'should fail if no auth params are passed and the mistral config file does not have the expected contents' do
mock = {}
Puppet::Util::IniConfig::File.expects(:new).returns(mock)
mock.expects(:read).with('/etc/mistral/mistral.conf')
expect do
klass.mistral_credentials
end.to raise_error(Puppet::Error, /Mistral types will not work/)
end
it 'should read conf file with all sections' do
creds_hash = {
'auth_url' => 'https://192.168.56.210:5000/v3/',
'project_name' => 'admin_tenant',
'username' => 'admin',
'password' => 'password',
'project_domain_name' => 'Default',
'user_domain_name' => 'Default',
}
mock = {
'keystone_authtoken' => {
'auth_url' => 'https://192.168.56.210:5000/v3/',
'project_name' => 'admin_tenant',
'username' => 'admin',
'password' => 'password',
}
}
Puppet::Util::IniConfig::File.expects(:new).returns(mock)
mock.expects(:read).with('/etc/mistral/mistral.conf')
expect(klass.mistral_credentials).to eq(creds_hash)
end
end
end