Enable keystone v3 support for cinder_type

Previously, the cinder_type provider used Credentialsv2_0 when
creating a new type, so it did not support Keystone v3 environments.
Switching th Credentialsv3 to support both Keystone v3.

Change-Id: Iff8e21c922c2d90108053f70cbc053436e3461de
This commit is contained in:
Javier Pena 2016-05-19 16:19:50 +02:00
parent d4f5963461
commit c58a3d7cac
4 changed files with 25 additions and 5 deletions

View File

@ -32,6 +32,10 @@ class Puppet::Provider::Cinder < Puppet::Provider::Openstack
@credentials.password = cinder_credentials['admin_password']
@credentials.project_name = cinder_credentials['admin_tenant_name']
@credentials.auth_url = auth_endpoint
if @credentials.version == '3'
@credentials.user_domain_name = cinder_credentials['user_domain_name']
@credentials.project_domain_name = cinder_credentials['project_domain_name']
end
raise error unless @credentials.set?
Puppet::Provider::Openstack.request(service, action, properties, @credentials)
end
@ -52,6 +56,16 @@ class Puppet::Provider::Cinder < Puppet::Provider::Openstack
auth_keys.all?{|k| !conf['keystone_authtoken'][k].nil?}
creds = Hash[ auth_keys.map \
{ |k| [k, conf['keystone_authtoken'][k].strip] } ]
if conf['project_domain_name']
creds['project_domain_name'] = conf['project_domain_name']
else
creds['project_domain_name'] = 'Default'
end
if conf['user_domain_name']
creds['user_domain_name'] = conf['user_domain_name']
else
creds['user_domain_name'] = 'Default'
end
return creds
else
raise(Puppet::Error, "File: #{conf_filename} does not contain all " +

View File

@ -7,7 +7,7 @@ Puppet::Type.type(:cinder_type).provide(
desc 'Provider for cinder types.'
@credentials = Puppet::Provider::Openstack::CredentialsV2_0.new
@credentials = Puppet::Provider::Openstack::CredentialsV3.new
mk_resource_methods

View File

@ -0,0 +1,4 @@
---
features:
- Keystone v3 support is added to the cinder_type
provider.

View File

@ -24,10 +24,12 @@ describe Puppet::Provider::Cinder do
it 'should read conf file with all sections' do
creds_hash = {
'auth_uri' => 'https://192.168.56.210:35357/v2.0/',
'admin_tenant_name' => 'admin_tenant',
'admin_user' => 'admin',
'admin_password' => 'password',
'auth_uri' => 'https://192.168.56.210:35357/v2.0/',
'admin_tenant_name' => 'admin_tenant',
'admin_user' => 'admin',
'admin_password' => 'password',
'project_domain_name' => 'Default',
'user_domain_name' => 'Default',
}
mock = {
'keystone_authtoken' => {