From 06e65b5fee75b6476427aa5377d22780592c4dd7 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Thu, 16 Nov 2023 23:34:55 +0900 Subject: [PATCH] Use core provider implementation to look up keystone resources ... so that the credentials in clouds.yaml file can be used if available instead of openrc. Also, the transformation from project name to project uuid is still needed so the transform_to method has been undeprecated. Change-Id: I0e0d42d92e8272f3f7faf809e07e599805bbedaa --- lib/puppet/provider/ironic.rb | 25 +++-------------- .../provider/ironic_config/openstackconfig.rb | 10 +++---- manifests/glance.pp | 27 +++++++------------ ...e-openstack-provider-b7bec0088acec9af.yaml | 16 +++++++++++ 4 files changed, 34 insertions(+), 44 deletions(-) create mode 100644 releasenotes/notes/use-openstack-provider-b7bec0088acec9af.yaml diff --git a/lib/puppet/provider/ironic.rb b/lib/puppet/provider/ironic.rb index 504e7037..e1700a8c 100644 --- a/lib/puppet/provider/ironic.rb +++ b/lib/puppet/provider/ironic.rb @@ -1,27 +1,10 @@ require 'puppet/provider/openstack' require 'puppet/provider/openstack/auth' -require 'puppet/provider/openstack/credentials' -class Puppet::Provider::Ironic < Puppet::Provider +class Puppet::Provider::Ironic < Puppet::Provider::Openstack + extend Puppet::Provider::Openstack::Auth -end - -class Puppet::Provider::Ironic::OpenstackRequest - include Puppet::Provider::Openstack::Auth - - def openstack_request(service, action, properties=nil, options={}) - credentials = Puppet::Provider::Openstack::CredentialsV3.new - openstack = Puppet::Provider::Openstack - - set_credentials(credentials, get_os_vars_from_env) - unless credentials.set? - credentials.unset - set_credentials(credentials, get_os_vars_from_rcfile(rc_filename)) - end - unless credentials.set? - raise(Puppet::Error::OpenstackAuthInputError, 'Insufficient credentials to authenticate') - end - - openstack.request(service, action, properties, credentials, options) + def self.system_request(service, actuon, properties=nil, options={}) + self.request(service, action, properties, options, 'system') end end diff --git a/lib/puppet/provider/ironic_config/openstackconfig.rb b/lib/puppet/provider/ironic_config/openstackconfig.rb index 40db9f29..048a7ca0 100644 --- a/lib/puppet/provider/ironic_config/openstackconfig.rb +++ b/lib/puppet/provider/ironic_config/openstackconfig.rb @@ -10,19 +10,17 @@ Puppet::Type.type(:ironic_config).provide( end def to_project_uuid(name) - warning('to_project_uuid is deprecated and will be removed in a future release.') properties = [name, '--column', 'id'] - openstack = Puppet::Provider::Ironic::OpenstackRequest.new - res = openstack.openstack_request('project', 'show', properties) + ironic_provider = Puppet::Provider::Ironic + res = ironic_provider.system_request('project', 'show', properties) return "AUTH_#{res[:id]}" end def from_project_uuid(uuid) - warning('from_project_uuid is deprecated and will be removed in a future release.') uuid = uuid.sub('AUTH_','') properties = [uuid, '--column', 'name'] - openstack = Puppet::Provider::Ironic::OpenstackRequest.new - res = openstack.openstack_request('project', 'show', properties) + ironic_provider = Puppet::Provider::Ironic + res = ironic_provider.system_request('project', 'show', properties) return res[:name] end end diff --git a/manifests/glance.pp b/manifests/glance.pp index 73293c84..9c2c1bee 100644 --- a/manifests/glance.pp +++ b/manifests/glance.pp @@ -68,6 +68,13 @@ # account. # Defaults to $facts['os_service_default'] # +# [*swift_account_project_name*] +# (optional) The project of account that Glance uses to communicate with Swift. +# Will be converted to UUID, and option glance/swift_account will be set in +# the "AUTH_uuid" format. +# Can not be set together with swift_account. +# Defaults to undef, which leaves the configuration intact +# # [*swift_container*] # (optional) Swift container where Glance images are stored. Used for # generating temporary URLs. @@ -91,15 +98,6 @@ # The endpoint URL for requests for this client # Defaults to $facts['os_service_default'] # -# DEPRECATED PARAMETERS -# -# [*swift_account_project_name*] -# (optional) The project of account that Glance uses to communicate with Swift. -# Will be converted to UUID, and option glance/swift_account will be set in -# the "AUTH_uuid" format. -# Can not be set together with swift_account. -# Defaults to undef, which leaves the configuration intact -# class ironic::glance ( $auth_type = 'password', $auth_url = $facts['os_service_default'], @@ -114,21 +112,16 @@ class ironic::glance ( $api_insecure = $facts['os_service_default'], $swift_account = $facts['os_service_default'], $swift_account_prefix = $facts['os_service_default'], + $swift_account_project_name = undef, $swift_container = $facts['os_service_default'], $swift_endpoint_url = $facts['os_service_default'], $swift_temp_url_key = $facts['os_service_default'], $swift_temp_url_duration = $facts['os_service_default'], $endpoint_override = $facts['os_service_default'], - # DEPRECATED PARAMETERS - $swift_account_project_name = undef, ) { include ironic::deps - if $swift_account_project_name != undef { - warning('The swift_account_project_name parameter is deprecated and will be removed in a future release.') - } - if ($swift_account_project_name and !is_service_default($swift_account)) { fail('swift_account_project_name and swift_account can not be specified in the same time.') } @@ -163,11 +156,11 @@ class ironic::glance ( if $swift_account_project_name { ironic_config { - 'glance/swift_account': value => $swift_account_project_name, transform_to => 'project_uuid'; + 'glance/swift_account': value => $swift_account_project_name, transform_to => 'project_uuid'; } } else { ironic_config { - 'glance/swift_account': value => $swift_account; + 'glance/swift_account': value => $swift_account; } } } diff --git a/releasenotes/notes/use-openstack-provider-b7bec0088acec9af.yaml b/releasenotes/notes/use-openstack-provider-b7bec0088acec9af.yaml new file mode 100644 index 00000000..e75d1a25 --- /dev/null +++ b/releasenotes/notes/use-openstack-provider-b7bec0088acec9af.yaml @@ -0,0 +1,16 @@ +--- +features: + - | + The ``to_project_uuid`` transformer now load credentials from the clouds + yaml file. In case the file is not available then it tries to load + credential in openrc file or environment variables like the previous + version. + +deprecations: + - | + Usage of ``ironic_config`` with ``transform_to => project_uuid`` has been + undeprecated. + + - | + The ``ironic::glance::swift_account_project_name`` parameter is no longer + deprecated.