Use domain_id when testing keystone_user password

Older python-openstackclient crashes with this error if no project or
domain are passed to the openstack token issue command:

  Set a scope, such as a project or domain, with --os-project-name or OS_PROJECT_NAME

The @property_hash[:domain] value is not properly populated at this time,
making the "openstack token issue" command being invoked without proper scope.

The @property_hash[:domain_id] value is however available. Using the domain_id
instead makes both older and recent python-openstackclient happy.

Closes-bug: #1654379
Change-Id: Ie23bdb7e9dd77e6ec4358c68d77671ef3c0678a6
This commit is contained in:
Mathieu Gagné 2017-01-05 14:23:24 -05:00
parent 42e4d02c8b
commit 3010079b0a
2 changed files with 3 additions and 3 deletions

View File

@ -128,7 +128,7 @@ Puppet::Type.type(:keystone_user).provide(
credentials.project_id = projects[0][:id]
else
# last chance - try a domain scoped token
credentials.domain_name = domain
credentials.domain_id = domain_id
end
credentials.identity_api_version = '2' if credentials.auth_url =~ /v2\.0\/?$/

View File

@ -189,13 +189,13 @@ ac43ec53d5a74a0b9f51523ae41a29f0
it 'checks the password with domain scoped token' do
provider.expects(:id).twice.returns('project1_id')
provider.expects(:domain).returns('domain1')
provider.expects(:domain_id).returns('domain1_id')
mock_creds = Puppet::Provider::Openstack::CredentialsV3.new
mock_creds.auth_url = 'http://127.0.0.1:5000'
mock_creds.password = 'foo'
mock_creds.username = 'foo'
mock_creds.user_id = 'project1_id'
mock_creds.domain_name = 'domain1'
mock_creds.domain_id = 'domain1_id'
Puppet::Provider::Openstack::CredentialsV3.expects(:new).returns(mock_creds)
described_class.expects(:openstack)
.with('project', 'list', '--quiet', '--format', 'csv',