Stop reading keystone_authtoken options

Using credentials in keystone_authtoken options for trove_* resources
was deprecated some cycles ago[1].

[1] f99ea85cd3

Change-Id: I561fc082f6754a0d65983a9b9024099ba8416b82
This commit is contained in:
Takashi Kajinami 2024-05-02 17:19:55 +09:00
parent e46bb54f4b
commit e48e2dcb9c
2 changed files with 0 additions and 180 deletions

View File

@ -5,7 +5,6 @@ File.expand_path('../../../../openstacklib/lib', File.dirname(__FILE__)).tap { |
require 'puppet/util/inifile'
require 'puppet/provider/openstack'
require 'puppet/provider/openstack/auth'
require 'puppet/provider/openstack/credentials'
class Puppet::Provider::Trove < Puppet::Provider::Openstack
@ -14,100 +13,6 @@ class Puppet::Provider::Trove < Puppet::Provider::Openstack
initvars # so commands will work
commands :trove_manage => 'trove-manage'
def self.request(service, action, properties=nil)
begin
super
rescue Puppet::Error::OpenstackAuthInputError => error
trove_request(service, action, error, properties)
end
end
def self.trove_request(service, action, error, properties=nil)
warning('Usage of keystone_authtoken parameters is deprecated.')
properties ||= []
@credentials.username = trove_credentials['username']
@credentials.password = trove_credentials['password']
@credentials.project_name = trove_credentials['project_name']
@credentials.auth_url = auth_endpoint
@credentials.user_domain_name = trove_credentials['user_domain_name']
@credentials.project_domain_name = trove_credentials['project_domain_name']
if trove_credentials['region_name']
@credentials.region_name = trove_credentials['region_name']
end
raise error unless @credentials.set?
Puppet::Provider::Openstack.request(service, action, properties, @credentials)
end
def self.conf_filename
'/etc/trove/trove.conf'
end
def self.trove_conf
return @trove_conf if @trove_conf
@trove_conf = Puppet::Util::IniConfig::File.new
@trove_conf.read(conf_filename)
@trove_conf
end
def self.trove_credentials
@trove_credentials ||= get_trove_credentials
end
def trove_credentials
self.class.trove_credentials
end
def self.get_trove_credentials
#needed keys for authentication
auth_keys = ['auth_url', 'project_name', 'username', 'password']
conf = trove_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
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 " +
"required sections. Trove types will not work if trove is not " +
"correctly configured.")
end
end
def self.conf_filename
'/etc/trove/trove.conf'
end
def self.get_auth_endpoint
q = trove_credentials
"#{q['auth_url']}"
end
def self.auth_endpoint
@auth_endpoint ||= get_auth_endpoint
end
def self.reset
@auth_endpoint = nil
@trove_conf = nil
@trove_credentials = nil
end
def trove_manage(*args)
execute([command(:trove_manage)] + args)
end

View File

@ -1,85 +0,0 @@
require 'puppet'
require 'spec_helper'
require 'puppet/provider/trove_datastore/trove'
provider_class = Puppet::Type.type(:trove_datastore).provider(:trove)
describe provider_class do
let(:set_env) do
ENV['OS_USERNAME'] = 'test'
ENV['OS_PASSWORD'] = 'abc123'
ENV['OS_PROJECT_NAME'] = 'test'
ENV['OS_AUTH_URL'] = 'http://127.0.0.1:5000'
end
let :datastore_name do
'foo'
end
let :datastore_attrs do
{
:name => datastore_name,
:ensure => 'present',
}
end
let :resource do
Puppet::Type::Trove_datastore.new(datastore_attrs)
end
let :provider do
described_class.new(resource)
end
before :each do
set_env
end
describe "self.instances" do
it 'lists datastores' do
expect(provider_class).to receive(:openstack)
.with('datastore', 'list', '--quiet', '--format', 'csv', [])
.and_return('"ID","Name"
"1275b24c-73af-4c51-98ec-c9938a94a153","store1"
"18088802-efe2-42f8-ac85-ecfddd37d24e","store2"
')
instances = provider_class.instances
expect(instances.length).to eq(2)
expect(instances[0].id).to eq('1275b24c-73af-4c51-98ec-c9938a94a153')
expect(instances[0].name).to eq('store1')
expect(instances[1].id).to eq('18088802-efe2-42f8-ac85-ecfddd37d24e')
expect(instances[1].name).to eq('store2')
end
end
describe '#create' do
context 'without version' do
it 'creates datastore' do
expect(provider).to receive(:trove_manage)
.with(['datastore_update', datastore_name, "''"])
.and_return(0)
provider.create
end
end
context 'with version' do
before do
datastore_attrs.merge!(
:version => '0.1',
)
end
it 'creates datastore' do
expect(provider).to receive(:trove_manage)
.with(['datastore_update', datastore_name, "''"])
.and_return(0)
expect(provider).to receive(:trove_manage)
.with(['datastore_update', datastore_name, "0.1"])
.and_return(0)
provider.create
end
end
end
end