WIP: Fix provider if system-scoped credential is used for authtoken
Change-Id: I5a26abc4723fe2312030b205b58022257def7a83
This commit is contained in:
parent
af93169d4d
commit
3a0ef00d32
|
@ -25,10 +25,16 @@ class Puppet::Provider::Nova < Puppet::Provider::Openstack
|
|||
properties ||= []
|
||||
@credentials.username = nova_credentials['username']
|
||||
@credentials.password = nova_credentials['password']
|
||||
@credentials.project_name = nova_credentials['project_name']
|
||||
|
||||
if !nova_credentials['project_name'].nii?
|
||||
@credentials.project_name = nova_credentials['project_name']
|
||||
@credentials.project_domain_name = nova_credentials['project_domain_name']
|
||||
else
|
||||
@credentials.system_scope = nova_credentials['system_scope']
|
||||
end
|
||||
|
||||
@credentials.auth_url = auth_endpoint
|
||||
@credentials.user_domain_name = nova_credentials['user_domain_name']
|
||||
@credentials.project_domain_name = nova_credentials['project_domain_name']
|
||||
if nova_credentials['region_name']
|
||||
@credentials.region_name = nova_credentials['region_name']
|
||||
end
|
||||
|
@ -80,20 +86,30 @@ class Puppet::Provider::Nova < Puppet::Provider::Openstack
|
|||
|
||||
def self.get_nova_credentials
|
||||
#needed keys for authentication
|
||||
auth_keys = ['auth_url', 'project_name', 'username', 'password']
|
||||
auth_keys = ['auth_url', 'username', 'password']
|
||||
conf = nova_conf
|
||||
if conf and conf['keystone_authtoken'] and
|
||||
auth_keys.all?{|k| !conf['keystone_authtoken'][k].nil?}
|
||||
creds = Hash[ auth_keys.map \
|
||||
{ |k| [k, conf['keystone_authtoken'][k].strip] } ]
|
||||
if !conf['keystone_authtoken']['region_name'].nil?
|
||||
creds['region_name'] = conf['keystone_authtoken']['region_name'].strip
|
||||
|
||||
scope_set = true
|
||||
|
||||
if !conf['keystone_authtoken']['project_name'].nil?
|
||||
creds['project_name'] = conf['keystone_authtoken']['project_name'].strip
|
||||
if !conf['keystone_authtoken']['project_domain_name'].nil?
|
||||
creds['project_domain_name'] = conf['keystone_authtoken']['project_domain_name'].strip
|
||||
else
|
||||
creds['project_domain_name'] = 'Default'
|
||||
end
|
||||
elsif !conf['keystone_authtoken']['system_scope'].nil?
|
||||
creds['system_scope'] = conf['keystone_authtoken']['system_scope'].strip
|
||||
else
|
||||
scope_set = false
|
||||
end
|
||||
|
||||
if !conf['keystone_authtoken']['project_domain_name'].nil?
|
||||
creds['project_domain_name'] = conf['keystone_authtoken']['project_domain_name'].strip
|
||||
else
|
||||
creds['project_domain_name'] = 'Default'
|
||||
if !conf['keystone_authtoken']['region_name'].nil?
|
||||
creds['region_name'] = conf['keystone_authtoken']['region_name'].strip
|
||||
end
|
||||
|
||||
if !conf['keystone_authtoken']['user_domain_name'].nil?
|
||||
|
@ -102,12 +118,13 @@ class Puppet::Provider::Nova < Puppet::Provider::Openstack
|
|||
creds['user_domain_name'] = 'Default'
|
||||
end
|
||||
|
||||
return creds
|
||||
else
|
||||
raise(Puppet::Error, "File: #{conf_filename} does not contain all " +
|
||||
"required sections. Nova types will not work if nova is not " +
|
||||
"correctly configured.")
|
||||
if scope_set
|
||||
return creds
|
||||
end
|
||||
end
|
||||
raise(Puppet::Error, "File: #{conf_filename} does not contain all " +
|
||||
"required sections. Nova types will not work if nova is not " +
|
||||
"correctly configured.")
|
||||
end
|
||||
|
||||
def self.get_auth_endpoint
|
||||
|
|
Loading…
Reference in New Issue