From 3010079b0a843cd3aa36a2c29bd3858e67013f74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20Gagne=CC=81?= Date: Thu, 5 Jan 2017 14:23:24 -0500 Subject: [PATCH] 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 --- lib/puppet/provider/keystone_user/openstack.rb | 2 +- spec/unit/provider/keystone_user/openstack_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/puppet/provider/keystone_user/openstack.rb b/lib/puppet/provider/keystone_user/openstack.rb index a1083ad4e..5b1a72aaf 100644 --- a/lib/puppet/provider/keystone_user/openstack.rb +++ b/lib/puppet/provider/keystone_user/openstack.rb @@ -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\/?$/ diff --git a/spec/unit/provider/keystone_user/openstack_spec.rb b/spec/unit/provider/keystone_user/openstack_spec.rb index bfc5544dc..5c40d2bec 100644 --- a/spec/unit/provider/keystone_user/openstack_spec.rb +++ b/spec/unit/provider/keystone_user/openstack_spec.rb @@ -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',