From 9f44421ceb54f970986fd96d2e66faccba1909ec Mon Sep 17 00:00:00 2001 From: Javier Pena Date: Tue, 3 Mar 2015 16:42:09 +0100 Subject: [PATCH] Support identity_uri in provider After https://review.openstack.org/152321 was merged, it was no longer guaranteed that some now deprecated settings like auth_host and auth_protocol would be present in glance-api.conf. This breaks the Glance provider, which expects them to be present. This patch adds support for identity_uri in provider, while keeping backwards compatibility. Change-Id: Ie8a2e45a4afea4828e02af36e64d65e7d4b7557e --- lib/puppet/provider/glance.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/puppet/provider/glance.rb b/lib/puppet/provider/glance.rb index ec4e1c08..6f7bbee0 100644 --- a/lib/puppet/provider/glance.rb +++ b/lib/puppet/provider/glance.rb @@ -30,6 +30,21 @@ class Puppet::Provider::Glance < Puppet::Provider # auth_admin_prefix not required to be set. g['auth_admin_prefix'] = (glance_file['keystone_authtoken']['auth_admin_prefix'] || '').strip + return g + elsif glance_file and glance_file['keystone_authtoken'] and + glance_file['keystone_authtoken']['identity_uri'] and + glance_file['keystone_authtoken']['admin_tenant_name'] and + glance_file['keystone_authtoken']['admin_user'] and + glance_file['keystone_authtoken']['admin_password'] and + glance_file['DEFAULT']['os_region_name'] + + g = {} + g['identity_uri'] = glance_file['keystone_authtoken']['identity_uri'].strip + g['admin_tenant_name'] = glance_file['keystone_authtoken']['admin_tenant_name'].strip + g['admin_user'] = glance_file['keystone_authtoken']['admin_user'].strip + g['admin_password'] = glance_file['keystone_authtoken']['admin_password'].strip + g['os_region_name'] = glance_file['DEFAULT']['os_region_name'].strip + return g else raise(Puppet::Error, 'File: /etc/glance/glance-api.conf does not contain all required sections.') @@ -46,7 +61,11 @@ class Puppet::Provider::Glance < Puppet::Provider def self.get_auth_endpoint g = glance_credentials - "#{g['auth_protocol']}://#{g['auth_host']}:#{g['auth_port']}#{g['auth_admin_prefix']}/v2.0/" + if g.key?('identity_uri') + "#{g['identity_uri']}/" + else + "#{g['auth_protocol']}://#{g['auth_host']}:#{g['auth_port']}#{g['auth_admin_prefix']}/v2.0/" + end end def self.glance_file