replace validate_legacy with proper data types

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

This also adds validations about the following parameters to enforce
the implicit requirements.
 - ironic::inspector::pxe_transfer_protocol
 - ironic::pxe::tftp_use_xinetd

Change-Id: I6a69e90f81c98abbba32a423bdda2b58e0e826af
This commit is contained in:
Takashi Kajinami 2023-06-21 11:01:44 +09:00
parent 447c836c60
commit f64f7a0db5
11 changed files with 68 additions and 102 deletions

View File

@ -75,8 +75,8 @@
#
class ironic::api (
$package_ensure = 'present',
$manage_service = true,
$enabled = true,
Boolean $manage_service = true,
Boolean $enabled = true,
$service_name = $::ironic::params::api_service,
$host_ip = $facts['os_service_default'],
$port = $facts['os_service_default'],
@ -92,9 +92,6 @@ class ironic::api (
include ironic::policy
include ironic::api::authtoken
validate_legacy(Boolean, 'validate_bool', $manage_service)
validate_legacy(Boolean, 'validate_bool', $enabled)
# Configure ironic.conf
ironic_config {
'api/host_ip': value => $host_ip;

View File

@ -239,8 +239,8 @@
#
class ironic::conductor (
$package_ensure = 'present',
$enabled = true,
$manage_service = true,
Boolean $enabled = true,
Boolean $manage_service = true,
$enabled_hardware_types = $facts['os_service_default'],
$force_power_state_during_sync = $facts['os_service_default'],
$http_url = $facts['os_service_default'],
@ -248,7 +248,8 @@ class ironic::conductor (
$force_raw_images = $facts['os_service_default'],
$automated_clean = $facts['os_service_default'],
$cleaning_network = $facts['os_service_default'],
$cleaning_disk_erase = undef,
Optional[Enum['full', 'metadata', 'none']] $cleaning_disk_erase
= undef,
$continue_if_disk_secure_erase_fails = $facts['os_service_default'],
$provisioning_network = $facts['os_service_default'],
$rescuing_network = $facts['os_service_default'],
@ -286,9 +287,6 @@ class ironic::conductor (
include ironic::deps
include ironic::params
validate_legacy(Boolean, 'validate_bool', $enabled)
validate_legacy(Boolean, 'validate_bool', $manage_service)
# For backward compatibility
include ironic::glance
@ -312,11 +310,6 @@ class ironic::conductor (
# including its manifest (which only contains configuration options)
include ironic::drivers::agent
if $cleaning_disk_erase {
validate_legacy(Enum['full', 'metadata', 'none'], 'validate_re', $cleaning_disk_erase,
[['^full$', '^metadata$', '^none$']])
}
case $cleaning_disk_erase {
'full': {
$erase_devices_priority = 10

View File

@ -21,12 +21,10 @@
# or Puppet catalog compilation will fail with duplicate resources.
#
class ironic::config (
$ironic_config = {},
Hash $ironic_config = {},
) {
include ironic::deps
validate_legacy(Hash, 'validate_hash', $ironic_config)
create_resources('ironic_config', $ironic_config)
}

View File

@ -143,7 +143,7 @@ class ironic::drivers::pxe (
$uefi_pxe_config_template = $facts['os_service_default'],
$uefi_ipxe_bootfile_name = $::ironic::params::uefi_ipxe_bootfile_name,
$ipxe_timeout = $facts['os_service_default'],
$enable_ppc64le = false,
Boolean $enable_ppc64le = false,
$boot_retry_timeout = $facts['os_service_default'],
$boot_retry_check_interval = $facts['os_service_default'],
$dir_permission = $facts['os_service_default'],
@ -155,8 +155,6 @@ class ironic::drivers::pxe (
include ironic::deps
validate_legacy(Boolean, 'validate_bool', $enable_ppc64le)
include ironic::pxe::common
$tftp_root_real = pick($::ironic::pxe::common::tftp_root, $tftp_root)
$ipxe_timeout_real = pick($::ironic::pxe::common::ipxe_timeout, $ipxe_timeout)

View File

@ -199,54 +199,45 @@
# Defaults to $::ironic::parmas::uefi_ipxe_bootfile_name
#
class ironic::inspector (
$package_ensure = 'present',
$manage_service = true,
$enabled = true,
$listen_address = $facts['os_service_default'],
$pxe_transfer_protocol = 'tftp',
$dhcp_debug = false,
$auth_strategy = 'keystone',
$timeout = $facts['os_service_default'],
$api_max_limit = $facts['os_service_default'],
$dnsmasq_interface = 'br-ctlplane',
$ramdisk_logs_dir = '/var/log/ironic-inspector/ramdisk/',
$always_store_ramdisk_logs = $facts['os_service_default'],
$add_ports = $facts['os_service_default'],
$keep_ports = 'all',
$store_data = 'none',
$dnsmasq_ip_subnets = [],
$dnsmasq_local_ip = '192.168.0.1',
$dnsmasq_dhcp_sequential_ip = true,
$dnsmasq_dhcp_hostsdir = undef,
$dnsmasq_log_facility = undef,
$sync_db = true,
$ramdisk_collectors = 'default',
$ramdisk_filename = 'agent.ramdisk',
$kernel_filename = 'agent.kernel',
$additional_processing_hooks = undef,
$ramdisk_kernel_args = undef,
$ipxe_timeout = $facts['os_service_default'],
$http_port = '8088',
$detect_boot_mode = $facts['os_service_default'],
$tftp_root = '/tftpboot',
$http_root = '/httpboot',
$node_not_found_hook = $facts['os_service_default'],
$discovery_default_driver = $facts['os_service_default'],
$enable_ppc64le = false,
$default_transport_url = 'fake://',
$port_physnet_cidr_map = {},
$uefi_ipxe_bootfile_name = $::ironic::params::uefi_ipxe_bootfile_name,
$package_ensure = 'present',
Boolean $manage_service = true,
Boolean $enabled = true,
$listen_address = $facts['os_service_default'],
Enum['http', 'tftp'] $pxe_transfer_protocol = 'tftp',
Boolean $dhcp_debug = false,
$auth_strategy = 'keystone',
$timeout = $facts['os_service_default'],
$api_max_limit = $facts['os_service_default'],
$dnsmasq_interface = 'br-ctlplane',
$ramdisk_logs_dir = '/var/log/ironic-inspector/ramdisk/',
$always_store_ramdisk_logs = $facts['os_service_default'],
$add_ports = $facts['os_service_default'],
$keep_ports = 'all',
$store_data = 'none',
Array[Hash] $dnsmasq_ip_subnets = [],
$dnsmasq_local_ip = '192.168.0.1',
Boolean $dnsmasq_dhcp_sequential_ip = true,
$dnsmasq_dhcp_hostsdir = undef,
$dnsmasq_log_facility = undef,
Boolean $sync_db = true,
$ramdisk_collectors = 'default',
$ramdisk_filename = 'agent.ramdisk',
$kernel_filename = 'agent.kernel',
$additional_processing_hooks = undef,
$ramdisk_kernel_args = undef,
$ipxe_timeout = $facts['os_service_default'],
$http_port = '8088',
$detect_boot_mode = $facts['os_service_default'],
$tftp_root = '/tftpboot',
$http_root = '/httpboot',
$node_not_found_hook = $facts['os_service_default'],
$discovery_default_driver = $facts['os_service_default'],
Boolean $enable_ppc64le = false,
$default_transport_url = 'fake://',
Hash $port_physnet_cidr_map = {},
$uefi_ipxe_bootfile_name = $::ironic::params::uefi_ipxe_bootfile_name,
) inherits ironic::params {
validate_legacy(Boolean, 'validate_bool', $manage_service)
validate_legacy(Boolean, 'validate_bool', $enabled)
validate_legacy(Boolean, 'validate_bool', $dhcp_debug)
validate_legacy(Boolean, 'validate_bool', $dnsmasq_dhcp_sequential_ip)
validate_legacy(Boolean, 'validate_bool', $sync_db)
validate_legacy(Boolean, 'validate_bool', $enable_ppc64le)
validate_legacy(Array, 'validate_array', $dnsmasq_ip_subnets)
validate_legacy(Hash, 'validate_hash', $port_physnet_cidr_map)
include ironic::deps
include ironic::pxe::common
include ironic::inspector::db

View File

@ -21,12 +21,10 @@
# or Puppet catalog compilation will fail with duplicate resources.
#
class ironic::inspector::config (
$ironic_inspector_config = {},
Hash $ironic_inspector_config = {},
) {
include ironic::deps
validate_legacy(Hash, 'validate_hash', $ironic_inspector_config)
create_resources('ironic_inspector_config', $ironic_inspector_config)
}

View File

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

View File

@ -22,8 +22,9 @@ class ironic::inventory (
include ironic::params
if ! is_service_default($data_backend) {
validate_legacy(Enum['none', 'database', 'swift'], 'validate_re', $data_backend,
['^none$', '^database$', '^swift$'])
if ! member(['none', 'database', 'swift'], $data_backend) {
fail('Unsupported data backend')
}
}
ironic_config {

View File

@ -87,7 +87,7 @@ class ironic::json_rpc (
$http_basic_auth_user_file = $facts['os_service_default'],
$host_ip = $facts['os_service_default'],
$port = $facts['os_service_default'],
$use_ssl = false,
Boolean $use_ssl = false,
$auth_type = 'password',
$auth_url = $facts['os_service_default'],
$project_name = 'services',
@ -103,8 +103,6 @@ class ironic::json_rpc (
include ironic::deps
validate_legacy(Boolean, 'validate_bool', $use_ssl)
if is_service_default($system_scope) {
$project_name_real = $project_name
$project_domain_name_real = $project_domain_name

View File

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

View File

@ -92,31 +92,27 @@
# Defaults to true
#
class ironic::pxe (
$package_ensure = 'present',
$manage_service = true,
$enabled = true,
$tftp_root = '/tftpboot',
$http_root = '/httpboot',
$http_port = 8088,
$pxelinux_path = $::ironic::params::pxelinux_path,
$syslinux_path = $::ironic::params::syslinux_path,
$syslinux_files = $::ironic::params::syslinux_files,
$tftp_bind_host = undef,
$ipxe_name_base = $::ironic::params::ipxe_name_base,
$uefi_ipxe_bootfile_name = $::ironic::params::uefi_ipxe_bootfile_name,
$uefi_pxe_bootfile_name = 'bootx64.efi',
$tftp_use_xinetd = $::ironic::params::xinetd_available,
$dnsmasq_log_facility = undef,
$manage_http_server = true,
$package_ensure = 'present',
Boolean $manage_service = true,
Boolean $enabled = true,
$tftp_root = '/tftpboot',
$http_root = '/httpboot',
$http_port = 8088,
$pxelinux_path = $::ironic::params::pxelinux_path,
$syslinux_path = $::ironic::params::syslinux_path,
$syslinux_files = $::ironic::params::syslinux_files,
$tftp_bind_host = undef,
$ipxe_name_base = $::ironic::params::ipxe_name_base,
$uefi_ipxe_bootfile_name = $::ironic::params::uefi_ipxe_bootfile_name,
$uefi_pxe_bootfile_name = 'bootx64.efi',
Boolean $tftp_use_xinetd = $::ironic::params::xinetd_available,
$dnsmasq_log_facility = undef,
Boolean $manage_http_server = true,
) inherits ironic::params {
include ironic::deps
include ironic::pxe::common
validate_legacy(Boolean, 'validate_bool', $manage_service)
validate_legacy(Boolean, 'validate_bool', $enabled)
validate_legacy(Boolean, 'validate_bool', $manage_http_server)
$tftp_root_real = pick($::ironic::pxe::common::tftp_root, $tftp_root)
$http_root_real = pick($::ironic::pxe::common::http_root, $http_root)
$http_port_real = pick($::ironic::pxe::common::http_port, $http_port)