swift: Switch to domain_name

glance_store has correctly supported usage of domain_name options since
bug 1480330 was fixed[1] in 4.1.0(Zed release).

Domain names are preferred to domain ids because these are predictable.
Add new parameters to manage domain_name options so that we can replace
the existing domain_id parameters.

[1] 6738d0b156fc1caae0604eb7bd8f05a6ed1c2d68

Change-Id: Id4d6e0f23d6571acee717152c863a25f7be62f8f
Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
This commit is contained in:
Takashi Kajinami
2025-07-01 22:14:45 +09:00
parent 8ef014a044
commit da11a7e02b
5 changed files with 165 additions and 105 deletions

View File

@@ -30,13 +30,13 @@
# (Optional) The address where the Swift authentication service is listening.
# Defaults to 'http://127.0.0.1:5000/v3/'
#
# [*swift_store_auth_project_domain_id*]
# (Optional) ID of the domain to which the project belongs.
# Defaults to 'default'
# [*swift_store_auth_project_domain_name*]
# (Optional) Name of the domain to which the project belongs.
# Defaults to 'Default'
#
# [*swift_store_auth_user_domain_id*]
# (Optional) ID of the domain to which the user belongs.
# Defaults to 'default'
# [*swift_store_auth_user_domain_name*]
# (Optional) Name of the domain to which the user belongs.
# Defaults to 'Default'
#
# [*swift_store_container*]
# (Optional) Name of single container to store images/name prefix for
@@ -109,13 +109,21 @@
# (Optional) The authentication version to be used.
# Defaults to undef
#
# [*swift_store_auth_project_domain_id*]
# (Optional) ID of the domain to which the project belongs.
# Defaults to undef
#
# [*swift_store_auth_user_domain_id*]
# (Optional) ID of the domain to which the user belongs.
# Defaults to undef
#
define glance::backend::multistore::swift(
$swift_store_user,
$swift_store_key,
$swift_store_auth_address = 'http://127.0.0.1:5000/v3/',
$swift_store_container = $facts['os_service_default'],
$swift_store_auth_project_domain_id = 'default',
$swift_store_auth_user_domain_id = 'default',
$swift_store_auth_project_domain_name = 'Default',
$swift_store_auth_user_domain_name = 'Default',
$swift_store_large_object_size = $facts['os_service_default'],
$swift_store_large_object_chunk_size = $facts['os_service_default'],
$swift_store_create_container_on_put = $facts['os_service_default'],
@@ -131,6 +139,8 @@ define glance::backend::multistore::swift(
# DEPRECATED PARAMETERS
$swift_store_config_file = undef,
$swift_store_auth_version = undef,
$swift_store_auth_project_domain_id = undef,
$swift_store_auth_user_domain_id = undef,
) {
include glance::deps
@@ -146,8 +156,14 @@ define glance::backend::multistore::swift(
$swift_store_config_file_real = '/etc/glance/glance-swift.conf'
}
if $swift_store_auth_version != undef {
warning('The swift_store_auth_version parameter is deprecated')
[
'swift_store_auth_version',
'swift_store_auth_project_domain_id',
'swift_store_auth_user_domain_id'
].each |String $dep_opt| {
if getvar($dep_opt) != undef {
warning("The ${dep_opt} parameter is deprecated")
}
}
glance_api_config {
@@ -187,7 +203,9 @@ define glance::backend::multistore::swift(
"${default_swift_reference}/key": value => $swift_store_key, secret => true;
"${default_swift_reference}/auth_address": value => $swift_store_auth_address;
"${default_swift_reference}/auth_version": value => pick($swift_store_auth_version, $facts['os_service_default']);
"${default_swift_reference}/user_domain_id": value => $swift_store_auth_user_domain_id;
"${default_swift_reference}/project_domain_id": value => $swift_store_auth_project_domain_id;
"${default_swift_reference}/user_domain_name": value => $swift_store_auth_user_domain_name;
"${default_swift_reference}/project_domain_name": value => $swift_store_auth_project_domain_name;
"${default_swift_reference}/user_domain_id": value => pick($swift_store_auth_user_domain_id, $facts['os_service_default']);
"${default_swift_reference}/project_domain_id": value => pick($swift_store_auth_project_domain_id, $facts['os_service_default']);
}
}

View File

@@ -15,13 +15,13 @@
# (Optional) The address where the Swift authentication service is listening.
# Defaults to 'http://127.0.0.1:5000/v3/'
#
# [*swift_store_auth_project_domain_id*]
# (Optional) ID of the domain to which the project belongs.
# Defaults to 'default'
# [*swift_store_auth_project_domain_name*]
# (Optional) Name of the domain to which the project belongs.
# Defaults to 'Default'
#
# [*swift_store_auth_user_domain_id*]
# (Optional) ID of the domain to which the user belongs.
# Defaults to 'default'
# [*swift_store_auth_user_domain_name*]
# (Optional) Name of the domain to which the user belongs.
# Defaults to 'Default'
#
# [*swift_store_container*]
# (Optional) Name of single container to store images/name prefix for
@@ -66,13 +66,21 @@
# (Optional) The authentication version to be used.
# Defaults to undef
#
# [*swift_store_auth_project_domain_id*]
# (Optional) ID of the domain to which the project belongs.
# Defaults to 'default'
#
# [*swift_store_auth_user_domain_id*]
# (Optional) ID of the domain to which the user belongs.
# Defaults to 'default'
#
class glance::backend::swift(
$swift_store_user,
$swift_store_key,
$swift_store_auth_address = 'http://127.0.0.1:5000/v3/',
$swift_store_container = $facts['os_service_default'],
$swift_store_auth_project_domain_id = 'default',
$swift_store_auth_user_domain_id = 'default',
$swift_store_auth_project_domain_name = 'Default',
$swift_store_auth_user_domain_name = 'Default',
$swift_store_large_object_size = $facts['os_service_default'],
$swift_store_large_object_chunk_size = $facts['os_service_default'],
$swift_store_create_container_on_put = $facts['os_service_default'],
@@ -81,7 +89,9 @@ class glance::backend::swift(
$default_swift_reference = 'ref1',
Boolean $multi_store = false,
# DEPRECATED PARAMETERS
$swift_store_auth_version = undef
$swift_store_auth_version = undef,
$swift_store_auth_project_domain_id = undef,
$swift_store_auth_user_domain_id = undef,
) {
include glance::deps
@@ -95,6 +105,8 @@ class glance::backend::swift(
swift_store_auth_address => $swift_store_auth_address,
swift_store_container => $swift_store_container,
swift_store_auth_version => $swift_store_auth_version,
swift_store_auth_project_domain_name => $swift_store_auth_project_domain_name,
swift_store_auth_user_domain_name => $swift_store_auth_user_domain_name,
swift_store_auth_project_domain_id => $swift_store_auth_project_domain_id,
swift_store_auth_user_domain_id => $swift_store_auth_user_domain_id,
swift_store_large_object_size => $swift_store_large_object_size,

View File

@@ -0,0 +1,18 @@
---
features:
- |
The ``glance::backend::swift`` class and
the ``glance::backend::multistore::swift`` defined resource type now
support the following two new parameters.
- ``swift_store_auth_project_domain_name``
- ``swift_store_auth_user_domain_name``
deprecations:
- |
The following parameters of the ``glance::backend::swift`` class and
the ``glance::backend::multistore::swift`` defined resource type have
been deprecated, in favor of the new project_name parameters.
- ``swift_store_auth_project_domain_id``
- ``swift_store_auth_user_domain_id``

View File

@@ -45,8 +45,10 @@ describe 'glance::backend::swift' do
is_expected.to contain_glance_swift_config('ref1/user').with_value('user')
is_expected.to contain_glance_swift_config('ref1/auth_version').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_swift_config('ref1/auth_address').with_value('http://127.0.0.1:5000/v3/')
is_expected.to contain_glance_swift_config('ref1/user_domain_id').with_value('default')
is_expected.to contain_glance_swift_config('ref1/project_domain_id').with_value('default')
is_expected.to contain_glance_swift_config('ref1/user_domain_name').with_value('Default')
is_expected.to contain_glance_swift_config('ref1/project_domain_name').with_value('Default')
is_expected.to contain_glance_swift_config('ref1/user_domain_id').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_swift_config('ref1/project_domain_id').with_value('<SERVICE DEFAULT>')
end
end
@@ -56,8 +58,10 @@ describe 'glance::backend::swift' do
:swift_store_user => 'user2',
:swift_store_key => 'key2',
:swift_store_auth_version => '3',
:swift_store_auth_project_domain_id => 'proj_domain',
:swift_store_auth_user_domain_id => 'user_domain',
:swift_store_auth_project_domain_name => 'proj_domain',
:swift_store_auth_user_domain_name => 'user_domain',
:swift_store_auth_project_domain_id => 'proj_domain_id',
:swift_store_auth_user_domain_id => 'user_domain_id',
:swift_store_large_object_size => '100',
:swift_store_large_object_chunk_size => '50',
:swift_store_auth_address => '127.0.0.2:8080/v1.0/',
@@ -92,8 +96,10 @@ describe 'glance::backend::swift' do
is_expected.to contain_glance_swift_config('swift_creds/user').with_value('user2')
is_expected.to contain_glance_swift_config('swift_creds/auth_version').with_value('3')
is_expected.to contain_glance_swift_config('swift_creds/auth_address').with_value('127.0.0.2:8080/v1.0/')
is_expected.to contain_glance_swift_config('swift_creds/user_domain_id').with_value('user_domain')
is_expected.to contain_glance_swift_config('swift_creds/project_domain_id').with_value('proj_domain')
is_expected.to contain_glance_swift_config('swift_creds/user_domain_name').with_value('user_domain')
is_expected.to contain_glance_swift_config('swift_creds/project_domain_name').with_value('proj_domain')
is_expected.to contain_glance_swift_config('swift_creds/user_domain_id').with_value('user_domain_id')
is_expected.to contain_glance_swift_config('swift_creds/project_domain_id').with_value('proj_domain_id')
end
end
end

View File

@@ -75,8 +75,10 @@ describe 'glance::backend::multistore::swift' do
is_expected.to contain_glance_swift_config('ref1/user').with_value('user')
is_expected.to contain_glance_swift_config('ref1/auth_version').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_swift_config('ref1/auth_address').with_value('http://127.0.0.1:5000/v3/')
is_expected.to contain_glance_swift_config('ref1/user_domain_id').with_value('default')
is_expected.to contain_glance_swift_config('ref1/project_domain_id').with_value('default')
is_expected.to contain_glance_swift_config('ref1/user_domain_name').with_value('Default')
is_expected.to contain_glance_swift_config('ref1/project_domain_name').with_value('Default')
is_expected.to contain_glance_swift_config('ref1/user_domain_id').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_swift_config('ref1/project_domain_id').with_value('<SERVICE DEFAULT>')
end
end
@@ -88,8 +90,10 @@ describe 'glance::backend::multistore::swift' do
:swift_store_user => 'user2',
:swift_store_key => 'key2',
:swift_store_auth_version => '3',
:swift_store_auth_project_domain_id => 'proj_domain',
:swift_store_auth_user_domain_id => 'user_domain',
:swift_store_auth_project_domain_name => 'proj_domain',
:swift_store_auth_user_domain_name => 'user_domain',
:swift_store_auth_project_domain_id => 'proj_domain_id',
:swift_store_auth_user_domain_id => 'user_domain_id',
:swift_store_large_object_size => '100',
:swift_store_large_object_chunk_size => '50',
:swift_store_auth_address => '127.0.0.2:8080/v1.0/',
@@ -143,8 +147,10 @@ describe 'glance::backend::multistore::swift' do
is_expected.to contain_glance_swift_config('swift_creds/user').with_value('user2')
is_expected.to contain_glance_swift_config('swift_creds/auth_version').with_value('3')
is_expected.to contain_glance_swift_config('swift_creds/auth_address').with_value('127.0.0.2:8080/v1.0/')
is_expected.to contain_glance_swift_config('swift_creds/user_domain_id').with_value('user_domain')
is_expected.to contain_glance_swift_config('swift_creds/project_domain_id').with_value('proj_domain')
is_expected.to contain_glance_swift_config('swift_creds/user_domain_name').with_value('user_domain')
is_expected.to contain_glance_swift_config('swift_creds/project_domain_name').with_value('proj_domain')
is_expected.to contain_glance_swift_config('swift_creds/user_domain_id').with_value('user_domain_id')
is_expected.to contain_glance_swift_config('swift_creds/project_domain_id').with_value('proj_domain_id')
end
end
end