replace validate_legacy with proper data types

the validate_legacy function is marked for deprecation in
v9.0.0 from puppetlabs-stdlib.

Note that this change removes the pattern validation about [DEFAULT]
pipeline. The existing pattern check is incomplete, because of
the following two reasons.
 - the pattern does not guarantee that the requested pipeline is
   really supported or not
 - the pattern accepts a+b+c but the existing pipelines in glance
   does not have any entries with this pattern

Change-Id: I156d9a3a30ba6c523a0b16a14bf8a1839b61fb78
This commit is contained in:
Takashi Kajinami 2023-06-19 16:30:19 +09:00
parent a1a98cf2a5
commit 945280277f
12 changed files with 36 additions and 85 deletions

View File

@ -274,10 +274,10 @@ class glance::api(
$workers = $facts['os_workers'],
$delayed_delete = $facts['os_service_default'],
$auth_strategy = 'keystone',
$paste_deploy_flavor = 'keystone',
String $paste_deploy_flavor = 'keystone',
$paste_deploy_config_file = $facts['os_service_default'],
$manage_service = true,
$enabled = true,
Boolean $manage_service = true,
Boolean $enabled = true,
$service_name = $::glance::params::api_service_name,
$show_image_direct_url = $facts['os_service_default'],
$location_strategy = $facts['os_service_default'],
@ -312,7 +312,7 @@ class glance::api(
$conversion_format = $facts['os_service_default'],
$enable_proxy_headers_parsing = $facts['os_service_default'],
$max_request_body_size = $facts['os_service_default'],
$sync_db = true,
Boolean $sync_db = true,
$limit_param_default = $facts['os_service_default'],
$api_limit_max = $facts['os_service_default'],
$lock_path = $::glance::params::lock_path,
@ -320,21 +320,17 @@ class glance::api(
# DEPRECATED PARAMETERS
$stores = undef,
$default_store = undef,
$multi_store = false,
Boolean $multi_store = false,
$show_multiple_locations = undef,
$filesystem_store_metadata_file = undef,
$filesystem_store_file_perm = undef,
$pipeline = undef,
Optional[String] $pipeline = undef,
) inherits glance {
include glance::deps
include glance::policy
include glance::api::db
validate_legacy(Boolean, 'validate_bool', $manage_service)
validate_legacy(Boolean, 'validate_bool', $enabled)
validate_legacy(Boolean, 'validate_bool', $sync_db)
validate_legacy(Boolean, 'validate_bool', $multi_store)
['filesystem_store_metadata_file', 'filesystem_store_file_perm'].each |String $fs_opt| {
if getvar($fs_opt) != undef {
@ -532,8 +528,6 @@ enabled_backends instead.')
# Set the flavor, it is allowed to be blank
if $paste_deploy_flavor_real != '' {
validate_legacy(Pattern[/^(\w+([+]\w+)*)*$/], 'validate_re', $paste_deploy_flavor_real, ['^(\w+([+]\w+)*)*$'])
glance_api_config {
'paste_deploy/flavor': value => $paste_deploy_flavor_real
}

View File

@ -82,15 +82,13 @@ class glance::backend::cinder(
$cinder_store_user_name = $facts['os_service_default'],
$cinder_store_password = $facts['os_service_default'],
$cinder_os_region_name = 'RegionOne',
$multi_store = false,
Boolean $multi_store = false,
) {
include glance::deps
warning('glance::backend::cinder is deprecated. Use glance::backend::multistore::cinder instead.')
validate_legacy(Boolean, 'validate_bool', $multi_store)
glance::backend::multistore::cinder { 'glance_store':
cinder_api_insecure => $cinder_api_insecure,
cinder_catalog_info => $cinder_catalog_info,

View File

@ -20,15 +20,13 @@
class glance::backend::file(
$filesystem_store_datadir = '/var/lib/glance/images/',
$filesystem_thin_provisioning = $facts['os_service_default'],
$multi_store = false,
Boolean $multi_store = false,
) {
include glance::deps
warning('glance::backend::file is deprecated. Use glance::backend::multistore::file instead.')
validate_legacy(Boolean, 'validate_bool', $multi_store)
glance::backend::multistore::file { 'glance_store':
filesystem_store_datadir => $filesystem_store_datadir,
filesystem_thin_provisioning => $filesystem_thin_provisioning,

View File

@ -57,22 +57,20 @@
# Defaults to $facts['os_service_default'].
#
define glance::backend::multistore::rbd(
$rbd_store_user = $facts['os_service_default'],
$rbd_store_ceph_conf = $facts['os_service_default'],
$rbd_store_pool = $facts['os_service_default'],
$rbd_store_chunk_size = $facts['os_service_default'],
$rbd_thin_provisioning = $facts['os_service_default'],
$manage_packages = true,
$package_ensure = 'present',
$rados_connect_timeout = $facts['os_service_default'],
$store_description = $facts['os_service_default'],
$rbd_store_user = $facts['os_service_default'],
$rbd_store_ceph_conf = $facts['os_service_default'],
$rbd_store_pool = $facts['os_service_default'],
$rbd_store_chunk_size = $facts['os_service_default'],
$rbd_thin_provisioning = $facts['os_service_default'],
Boolean $manage_packages = true,
$package_ensure = 'present',
$rados_connect_timeout = $facts['os_service_default'],
$store_description = $facts['os_service_default'],
) {
include glance::deps
include glance::params
validate_legacy(Boolean, 'validate_bool', $manage_packages)
glance_api_config {
"${name}/rbd_store_ceph_conf": value => $rbd_store_ceph_conf;
"${name}/rbd_store_user": value => $rbd_store_user;

View File

@ -82,15 +82,13 @@ define glance::backend::multistore::s3(
$s3_store_large_object_chunk_size = $facts['os_service_default'],
$s3_store_thread_pools = $facts['os_service_default'],
$store_description = $facts['os_service_default'],
$manage_packages = true,
Boolean $manage_packages = true,
$package_ensure = 'present',
) {
include glance::deps
include glance::params
validate_legacy(Boolean, 'validate_bool', $manage_packages)
if $manage_packages {
ensure_packages('python-boto3', {
'ensure' => $package_ensure,

View File

@ -41,15 +41,15 @@
# Defaults to false
#
class glance::backend::rbd(
$rbd_store_user = $facts['os_service_default'],
$rbd_store_ceph_conf = $facts['os_service_default'],
$rbd_store_pool = $facts['os_service_default'],
$rbd_store_chunk_size = $facts['os_service_default'],
$rbd_thin_provisioning = $facts['os_service_default'],
$manage_packages = true,
$package_ensure = 'present',
$rados_connect_timeout = $facts['os_service_default'],
$multi_store = false,
$rbd_store_user = $facts['os_service_default'],
$rbd_store_ceph_conf = $facts['os_service_default'],
$rbd_store_pool = $facts['os_service_default'],
$rbd_store_chunk_size = $facts['os_service_default'],
$rbd_thin_provisioning = $facts['os_service_default'],
Boolean $manage_packages = true,
$package_ensure = 'present',
$rados_connect_timeout = $facts['os_service_default'],
Boolean $multi_store = false,
) {
include glance::deps
@ -57,8 +57,6 @@ class glance::backend::rbd(
warning('glance::backend::rbd is deprecated. Use glance::backend::multistore::rbd instead.')
validate_legacy(Boolean, 'validate_bool', $multi_store)
glance::backend::multistore::rbd { 'glance_store':
rbd_store_ceph_conf => $rbd_store_ceph_conf,
rbd_store_user => $rbd_store_user,

View File

@ -70,7 +70,7 @@ class glance::backend::swift(
$swift_store_endpoint_type = 'internalURL',
$swift_store_region = $facts['os_service_default'],
$default_swift_reference = 'ref1',
$multi_store = false,
Boolean $multi_store = false,
) {
include glance::deps
@ -78,8 +78,6 @@ class glance::backend::swift(
warning('glance::backend::swift is deprecated. Use glance::backend::multistore::swift instead.')
validate_legacy(Boolean, 'validate_bool', $multi_store)
glance::backend::multistore::swift { 'glance_store':
swift_store_user => $swift_store_user,
swift_store_key => $swift_store_key,

View File

@ -88,15 +88,13 @@ class glance::backend::vsphere(
$vcenter_insecure = 'True',
$vcenter_task_poll_interval = $facts['os_service_default'],
$vcenter_api_retry_count = $facts['os_service_default'],
$multi_store = false,
Boolean $multi_store = false,
) {
include glance::deps
warning('glance::backend::vsphere is deprecated. Use glance::backend::multistore::vsphere instead.')
validate_legacy(Boolean, 'validate_bool', $multi_store)
glance::backend::multistore::vsphere { 'glance_store':
vmware_server_host => $vcenter_host,
vmware_server_username => $vcenter_user,

View File

@ -36,21 +36,15 @@
# or Puppet catalog compilation will fail with duplicate resources.
#
class glance::config (
$api_config = {},
$api_paste_ini_config = {},
$cache_config = {},
$image_import_config = {},
$rootwrap_config = {},
Hash $api_config = {},
Hash $api_paste_ini_config = {},
Hash $cache_config = {},
Hash $image_import_config = {},
Hash $rootwrap_config = {},
) {
include glance::deps
validate_legacy(Hash, 'validate_hash', $api_config)
validate_legacy(Hash, 'validate_hash', $api_paste_ini_config)
validate_legacy(Hash, 'validate_hash', $cache_config)
validate_legacy(Hash, 'validate_hash', $image_import_config)
validate_legacy(Hash, 'validate_hash', $rootwrap_config)
create_resources('glance_api_config', $api_config)
create_resources('glance_api_paste_ini', $api_paste_ini_config)
create_resources('glance_cache_config', $cache_config)

View File

@ -31,7 +31,7 @@
# Defaults to 'utf8_general_ci'
#
class glance::db::mysql(
$password,
String[1] $password,
$dbname = 'glance',
$user = 'glance',
$host = '127.0.0.1',
@ -42,8 +42,6 @@ class glance::db::mysql(
include glance::deps
validate_legacy(String, 'validate_string', $password)
::openstacklib::db::mysql { 'glance':
user => $user,
password => $password,

View File

@ -48,7 +48,7 @@
class glance::policy (
$enforce_scope = $facts['os_service_default'],
$enforce_new_defaults = $facts['os_service_default'],
$policies = {},
Hash $policies = {},
$policy_path = '/etc/glance/policy.yaml',
$policy_default_rule = $facts['os_service_default'],
$policy_dirs = $facts['os_service_default'],
@ -58,8 +58,6 @@ class glance::policy (
include glance::deps
include glance::params
validate_legacy(Hash, 'validate_hash', $policies)
$policy_parameters = {
policies => $policies,
policy_path => $policy_path,

View File

@ -305,25 +305,6 @@ describe 'glance::api' do
it { is_expected.to contain_glance_api_config('paste_deploy/flavor').with_ensure('absent') }
end
[
'keystone/',
'keystone+',
'+keystone',
'keystone+cachemanagement+',
'+'
].each do |flavor|
describe "with flavor set by incorrect value #{flavor}" do
let :params do
{
:flavor => flavor
}
end
it { expect { is_expected.to contain_glance_api_config('filter:paste_deploy/flavor') }.to\
raise_error(Puppet::Error) }
end
end
describe 'with platform default oslo concurrency lock_path' do
it { is_expected.to contain_oslo__concurrency('glance_api_config').with(
:lock_path => platform_params[:lock_path]