Refer keystone_authtoken instead of neutron to detect region

... because we generally use parameters under keystone_authtoken
to find credentials.

This patch also removes useless and incorrect handling about keystone
version, so that domain parameters are correctly set.

Change-Id: I86b1a426e80f9bbaee62e10235a6491624b7d684
This commit is contained in:
Takashi Kajinami 2020-04-14 20:17:43 +09:00
parent a2d9afc0d2
commit d156a19ba6

View File

@ -29,10 +29,8 @@ class Puppet::Provider::Neutron < Puppet::Provider::Openstack
@credentials.password = neutron_credentials['password']
@credentials.project_name = neutron_credentials['project_name']
@credentials.auth_url = auth_endpoint
if @credentials.version == '3'
@credentials.user_domain_name = neutron_credentials['user_domain_name']
@credentials.project_domain_name = neutron_credentials['project_domain_name']
end
@credentials.user_domain_name = neutron_credentials['user_domain_name']
@credentials.project_domain_name = neutron_credentials['project_domain_name']
if neutron_credentials['region_name']
@credentials.region_name = neutron_credentials['region_name']
end
@ -81,19 +79,23 @@ class Puppet::Provider::Neutron < 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['neutron'] and conf['neutron']['region_name']
creds['region_name'] = conf['neutron']['region_name'].strip
if !conf['keystone_authtoken']['region_name'].nil?
creds['region_name'] = conf['keystone_authtoken']['region_name'].strip
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'
end
if !conf['keystone_authtoken']['user_domain_name'].nil?
creds['user_domain_name'] = conf['keystone_authtoken']['user_domain_name'].strip
else
creds['user_domain_name'] = 'Default'
end
return creds
else
raise(Puppet::Error, "File: #{conf_filename} does not contain all " +