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,28 +109,38 @@
# (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_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'],
$swift_store_endpoint_type = 'internalURL',
$swift_store_service_type = $facts['os_service_default'],
$swift_store_region = $facts['os_service_default'],
$default_swift_reference = 'ref1',
$swift_buffer_on_upload = $facts['os_service_default'],
$swift_upload_buffer_dir = $facts['os_service_default'],
$swift_store_retry_get_count = $facts['os_service_default'],
$store_description = $facts['os_service_default'],
$weight = $facts['os_service_default'],
$swift_store_auth_address = 'http://127.0.0.1:5000/v3/',
$swift_store_container = $facts['os_service_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'],
$swift_store_endpoint_type = 'internalURL',
$swift_store_service_type = $facts['os_service_default'],
$swift_store_region = $facts['os_service_default'],
$default_swift_reference = 'ref1',
$swift_buffer_on_upload = $facts['os_service_default'],
$swift_upload_buffer_dir = $facts['os_service_default'],
$swift_store_retry_get_count = $facts['os_service_default'],
$store_description = $facts['os_service_default'],
$weight = $facts['os_service_default'],
# DEPRECATED PARAMETERS
$swift_store_config_file = undef,
$swift_store_auth_version = undef,
$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 {
@@ -183,11 +199,13 @@ define glance::backend::multistore::swift(
}
glance_swift_config {
"${default_swift_reference}/user": value => $swift_store_user;
"${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": value => $swift_store_user;
"${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_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,22 +66,32 @@
# (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_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'],
$swift_store_endpoint_type = 'internalURL',
$swift_store_region = $facts['os_service_default'],
$default_swift_reference = 'ref1',
Boolean $multi_store = false,
$swift_store_auth_address = 'http://127.0.0.1:5000/v3/',
$swift_store_container = $facts['os_service_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'],
$swift_store_endpoint_type = 'internalURL',
$swift_store_region = $facts['os_service_default'],
$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
@@ -90,20 +100,22 @@ class glance::backend::swift(
warning('glance::backend::swift is deprecated. Use glance::backend::multistore::swift instead.')
glance::backend::multistore::swift { 'glance_store':
swift_store_user => $swift_store_user,
swift_store_key => $swift_store_key,
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_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,
swift_store_large_object_chunk_size => $swift_store_large_object_chunk_size,
swift_store_create_container_on_put => $swift_store_create_container_on_put,
swift_store_endpoint_type => $swift_store_endpoint_type,
swift_store_region => $swift_store_region,
default_swift_reference => $default_swift_reference,
store_description => undef,
swift_store_user => $swift_store_user,
swift_store_key => $swift_store_key,
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,
swift_store_large_object_chunk_size => $swift_store_large_object_chunk_size,
swift_store_create_container_on_put => $swift_store_create_container_on_put,
swift_store_endpoint_type => $swift_store_endpoint_type,
swift_store_region => $swift_store_region,
default_swift_reference => $default_swift_reference,
store_description => undef,
}
if !$multi_store {

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,27 +45,31 @@ 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
describe 'when overriding parameters' do
let :params 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_large_object_size => '100',
:swift_store_large_object_chunk_size => '50',
:swift_store_auth_address => '127.0.0.2:8080/v1.0/',
:swift_store_container => 'swift',
:swift_store_create_container_on_put => true,
:swift_store_endpoint_type => 'publicURL',
:swift_store_region => 'RegionTwo',
:default_swift_reference => 'swift_creds',
:swift_store_user => 'user2',
:swift_store_key => 'key2',
:swift_store_auth_version => '3',
: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/',
:swift_store_container => 'swift',
:swift_store_create_container_on_put => true,
:swift_store_endpoint_type => 'publicURL',
:swift_store_region => 'RegionTwo',
:default_swift_reference => 'swift_creds',
}
end
@@ -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,34 +75,38 @@ 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
describe 'when overriding parameters' do
let :params do
{
:store_description => 'My swift store',
:weight => 0,
: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_large_object_size => '100',
:swift_store_large_object_chunk_size => '50',
:swift_store_auth_address => '127.0.0.2:8080/v1.0/',
:swift_store_container => 'swift',
:swift_store_create_container_on_put => true,
:swift_store_endpoint_type => 'publicURL',
:swift_store_service_type => 'object-store',
:swift_store_region => 'RegionTwo',
:swift_store_config_file => '/etc/glance/glance-swift2.conf',
:default_swift_reference => 'swift_creds',
:swift_buffer_on_upload => true,
:swift_upload_buffer_dir => '/var/glance/swift',
:swift_store_retry_get_count => 3,
:store_description => 'My swift store',
:weight => 0,
:swift_store_user => 'user2',
:swift_store_key => 'key2',
:swift_store_auth_version => '3',
: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/',
:swift_store_container => 'swift',
:swift_store_create_container_on_put => true,
:swift_store_endpoint_type => 'publicURL',
:swift_store_service_type => 'object-store',
:swift_store_region => 'RegionTwo',
:swift_store_config_file => '/etc/glance/glance-swift2.conf',
:default_swift_reference => 'swift_creds',
:swift_buffer_on_upload => true,
:swift_upload_buffer_dir => '/var/glance/swift',
:swift_store_retry_get_count => 3,
}
end
@@ -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