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:
@@ -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?}
|
||||
|
5
releasenotes/notes/bug-1961601-1df5a15bead1daf3.yaml
Normal file
5
releasenotes/notes/bug-1961601-1df5a15bead1daf3.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Now the base ``Puppet::Provider::Mistral`` class loads service user
|
||||
credential using the proper keystoneauth parameters.
|
48
spec/unit/provider/mistral_spec.rb
Normal file
48
spec/unit/provider/mistral_spec.rb
Normal 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
|
Reference in New Issue
Block a user