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
This commit is contained in:
parent
3cad74dac3
commit
06e65b5fee
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
Loading…
Reference in New Issue
Block a user