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
This commit is contained in:
Javier Pena 2015-03-03 16:42:09 +01:00
parent 9a4568c361
commit 9f44421ceb
1 changed files with 20 additions and 1 deletions

View File

@ -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