replace validate_legacy with proper data types

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

Change-Id: I25ceb3215a4a198e7a8545eeec6f2eeeafbd81c2
This commit is contained in:
Takashi Kajinami 2023-06-20 11:05:12 +09:00
parent 1559bd8320
commit 658a12dda5
3 changed files with 114 additions and 140 deletions

View File

@ -568,131 +568,112 @@
#
class horizon(
$secret_key,
$package_ensure = 'present',
$cache_backend = 'django.core.cache.backends.locmem.LocMemCache',
$cache_options = undef,
$cache_timeout = undef,
$cache_server_url = undef,
$cache_server_ip = undef,
$cache_server_port = '11211',
$cache_tls_enabled = false,
$cache_tls_cafile = undef,
$cache_tls_certfile = undef,
$cache_tls_keyfile = undef,
$cache_tls_allowed_ciphers = undef,
$manage_memcache_package = true,
$horizon_app_links = undef,
$keystone_url = 'http://127.0.0.1:5000',
$keystone_default_role = 'member',
$django_debug = 'False',
$site_branding = undef,
$openstack_endpoint_type = undef,
$secondary_endpoint_type = undef,
$openstack_keystone_endpoint_type = undef,
$available_regions = undef,
$api_result_limit = undef,
$api_result_page_size = undef,
$dropdown_max_items = undef,
$log_handlers = ['file'],
$log_level = 'INFO',
$django_log_level = undef,
$django_template_log_level = 'INFO',
$syslog_facility = 'local1',
$help_url = undef,
$bug_url = undef,
$local_settings_template = 'horizon/local_settings.py.erb',
$configure_apache = true,
$bind_address = undef,
$servername = $facts['networking']['fqdn'],
$server_aliases = $facts['networking']['fqdn'],
$allowed_hosts = $facts['networking']['fqdn'],
$listen_ssl = false,
$http_port = 80,
$https_port = 443,
$ssl_no_verify = false,
$openstack_ssl_cacert = '',
$ssl_redirect = true,
$ssl_cert = undef,
$ssl_key = undef,
$ssl_ca = undef,
$ssl_verify_client = undef,
$wsgi_processes = $facts['os_workers'],
$wsgi_threads = '1',
$compress_offline = true,
$hypervisor_options = {},
$cinder_options = {},
$keystone_options = {},
$neutron_options = {},
$instance_options = {},
$use_simple_tenant_usage = undef,
$file_upload_temp_dir = '/tmp',
$policy_files_path = undef,
$policy_files = undef,
$redirect_type = 'permanent',
$api_versions = {},
$keystone_multidomain_support = false,
$keystone_default_domain = undef,
$keystone_domain_choices = undef,
$image_backend = {},
$overview_days_range = undef,
$root_url = $::horizon::params::root_url,
$root_path = "${::horizon::params::static_path}/openstack-dashboard",
$access_log_format = undef,
$session_timeout = 1800,
$timezone = 'UTC',
$secure_cookies = false,
$django_session_engine = undef,
$vhost_extra_params = undef,
$available_themes = false,
$default_theme = false,
$password_autocomplete = 'off',
$create_image_defaults = undef,
$password_retrieve = false,
$disable_password_reveal = false,
$enforce_password_check = false,
$enable_secure_proxy_ssl_header = false,
$secure_proxy_addr_header = undef,
$disallow_iframe_embed = true,
$websso_enabled = false,
$websso_initial_choice = undef,
$websso_choices = undef,
$websso_choices_hide_keystone = false,
$websso_idp_mapping = undef,
$websso_default_redirect = false,
$websso_default_redirect_protocol = undef,
$websso_default_redirect_region = undef,
$websso_default_redirect_logout = undef,
$password_validator = undef,
$password_validator_help = undef,
$customization_module = undef,
$horizon_upload_mode = undef,
$default_boot_source = undef,
$system_scope_services = undef,
$package_ensure = 'present',
$cache_backend = 'django.core.cache.backends.locmem.LocMemCache',
$cache_options = undef,
$cache_timeout = undef,
$cache_server_url = undef,
$cache_server_ip = undef,
$cache_server_port = '11211',
Boolean $cache_tls_enabled = false,
$cache_tls_cafile = undef,
$cache_tls_certfile = undef,
$cache_tls_keyfile = undef,
$cache_tls_allowed_ciphers = undef,
Boolean $manage_memcache_package = true,
$horizon_app_links = undef,
$keystone_url = 'http://127.0.0.1:5000',
$keystone_default_role = 'member',
$django_debug = 'False',
$site_branding = undef,
$openstack_endpoint_type = undef,
$secondary_endpoint_type = undef,
$openstack_keystone_endpoint_type = undef,
$available_regions = undef,
$api_result_limit = undef,
$api_result_page_size = undef,
$dropdown_max_items = undef,
$log_handlers = ['file'],
$log_level = 'INFO',
$django_log_level = undef,
$django_template_log_level = 'INFO',
$syslog_facility = 'local1',
$help_url = undef,
$bug_url = undef,
$local_settings_template = 'horizon/local_settings.py.erb',
Boolean $configure_apache = true,
$bind_address = undef,
$servername = $facts['networking']['fqdn'],
$server_aliases = $facts['networking']['fqdn'],
$allowed_hosts = $facts['networking']['fqdn'],
Boolean $listen_ssl = false,
$http_port = 80,
$https_port = 443,
Boolean $ssl_no_verify = false,
$openstack_ssl_cacert = '',
Boolean $ssl_redirect = true,
$ssl_cert = undef,
$ssl_key = undef,
$ssl_ca = undef,
$ssl_verify_client = undef,
$wsgi_processes = $facts['os_workers'],
$wsgi_threads = '1',
Boolean $compress_offline = true,
$hypervisor_options = {},
$cinder_options = {},
$keystone_options = {},
$neutron_options = {},
$instance_options = {},
$use_simple_tenant_usage = undef,
$file_upload_temp_dir = '/tmp',
Optional[String] $policy_files_path = undef,
$policy_files = undef,
$redirect_type = 'permanent',
Hash $api_versions = {},
Boolean $keystone_multidomain_support = false,
$keystone_default_domain = undef,
$keystone_domain_choices = undef,
$image_backend = {},
$overview_days_range = undef,
$root_url = $::horizon::params::root_url,
Stdlib::Absolutepath $root_path = "${::horizon::params::static_path}/openstack-dashboard",
$access_log_format = undef,
$session_timeout = 1800,
$timezone = 'UTC',
Boolean $secure_cookies = false,
$django_session_engine = undef,
$vhost_extra_params = undef,
$available_themes = false,
$default_theme = false,
Enum['on', 'off'] $password_autocomplete = 'off',
$create_image_defaults = undef,
Boolean $password_retrieve = false,
Boolean $disable_password_reveal = false,
Boolean $enforce_password_check = false,
Boolean $enable_secure_proxy_ssl_header = false,
$secure_proxy_addr_header = undef,
Boolean $disallow_iframe_embed = true,
Boolean $websso_enabled = false,
$websso_initial_choice = undef,
$websso_choices = undef,
Boolean $websso_choices_hide_keystone = false,
$websso_idp_mapping = undef,
Boolean $websso_default_redirect = false,
$websso_default_redirect_protocol = undef,
$websso_default_redirect_region = undef,
$websso_default_redirect_logout = undef,
$password_validator = undef,
$password_validator_help = undef,
$customization_module = undef,
$horizon_upload_mode = undef,
$default_boot_source = undef,
$system_scope_services = undef,
# DEPRECATED PARAMETERS
$images_panel = undef,
$images_panel = undef,
) inherits horizon::params {
include horizon::deps
# Validate boolean parameters to avoid unexpected if-statement result
validate_legacy(Boolean, 'validate_bool', $cache_tls_enabled)
validate_legacy(Boolean, 'validate_bool', $manage_memcache_package)
validate_legacy(Boolean, 'validate_bool', $configure_apache)
validate_legacy(Boolean, 'validate_bool', $listen_ssl)
validate_legacy(Boolean, 'validate_bool', $ssl_no_verify)
validate_legacy(Boolean, 'validate_bool', $ssl_redirect)
validate_legacy(Boolean, 'validate_bool', $compress_offline)
validate_legacy(Boolean, 'validate_bool', $keystone_multidomain_support)
validate_legacy(Boolean, 'validate_bool', $secure_cookies)
validate_legacy(Boolean, 'validate_bool', $password_retrieve)
validate_legacy(Boolean, 'validate_bool', $disable_password_reveal)
validate_legacy(Boolean, 'validate_bool', $enforce_password_check)
validate_legacy(Boolean, 'validate_bool', $enable_secure_proxy_ssl_header)
validate_legacy(Boolean, 'validate_bool', $disallow_iframe_embed)
validate_legacy(Boolean, 'validate_bool', $websso_enabled)
validate_legacy(Boolean, 'validate_bool', $websso_choices_hide_keystone)
validate_legacy(Boolean, 'validate_bool', $websso_default_redirect)
if $images_panel {
warning('The images_panel parameter has been deprecated and has no effect.')
}
@ -771,16 +752,11 @@ class horizon(
$instance_options_real = merge($instance_defaults,$instance_options)
if $policy_files_path != undef {
validate_legacy(String, 'validate_string', $policy_files_path)
$policy_files_path_real = $policy_files_path
} else {
$policy_files_path_real = $::horizon::params::policy_dir
}
validate_legacy(Hash, 'validate_hash', $api_versions)
validate_legacy(Enum['on', 'off'], 'validate_re', $password_autocomplete, [['^on$', '^off$']])
validate_legacy(Stdlib::Absolutepath, 'validate_absolute_path', $root_path)
if $manage_memcache_package {
if $cache_backend =~ /\.MemcachedCache$/ {
ensure_packages('python-memcache', {

View File

@ -39,15 +39,15 @@
#
class horizon::policy(
# common parameters
$file_mode = '0640',
$file_format = 'yaml',
$purge_config = false,
$file_mode = '0640',
$file_format = 'yaml',
$purge_config = false,
# service specific parameters
$cinder_policies = {},
$glance_policies = {},
$keystone_policies = {},
$neutron_policies = {},
$nova_policies = {},
Hash $cinder_policies = {},
Hash $glance_policies = {},
Hash $keystone_policies = {},
Hash $neutron_policies = {},
Hash $nova_policies = {},
) {
include horizon::deps

View File

@ -25,17 +25,15 @@
# Defaults to false.
#
define horizon::policy::base(
$policy_file = $name,
$policies = {},
$file_mode = '0640',
$file_format = 'yaml',
$purge_config = false,
String[1] $policy_file = $name,
Hash $policies = {},
$file_mode = '0640',
$file_format = 'yaml',
$purge_config = false,
) {
include horizon::deps
include horizon::params
validate_legacy(String, 'validate_string', $policy_file)
if !defined(Class[horizon]){
fail('The horizon class should be included in advance')
}