Check if auth_admin_prefix is defined

Check if auth_admin_prefix is defined (passed as a parameter to api.pp)
before trying to access it in the settings data structure.

Change-Id: I61a3ae41dca2a5e5bd9e635b0a2ab9eb05b0326a
Fixes: bug #1190481
This commit is contained in:
Simon Sellar 2013-06-13 00:38:07 +00:00
parent dc98e9bb58
commit bf4fe406aa
1 changed files with 4 additions and 1 deletions

View File

@ -21,10 +21,13 @@ class Puppet::Provider::Glance < Puppet::Provider
g['auth_host'] = glance_file['keystone_authtoken']['auth_host'].strip
g['auth_port'] = glance_file['keystone_authtoken']['auth_port'].strip
g['auth_protocol'] = glance_file['keystone_authtoken']['auth_protocol'].strip
g['auth_admin_prefix'] = glance_file['keystone_authtoken'].fetch('auth_admin_prefix', '').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
# auth_admin_prefix not required to be set.
g['auth_admin_prefix'] = (glance_file['keystone_authtoken']['auth_admin_prefix'] || '').strip
return g
else
raise(Puppet::Error, 'File: /etc/glance/glance-api.conf does not contain all required sections.')