From f64f7a0db54ec76bf08def05c6246a990aed505a Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Wed, 21 Jun 2023 11:01:44 +0900 Subject: [PATCH] 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 --- manifests/api.pp | 7 +-- manifests/conductor.pp | 15 ++----- manifests/config.pp | 4 +- manifests/drivers/pxe.pp | 4 +- manifests/inspector.pp | 83 ++++++++++++++++------------------- manifests/inspector/config.pp | 4 +- manifests/inspector/policy.pp | 4 +- manifests/inventory.pp | 5 ++- manifests/json_rpc.pp | 4 +- manifests/policy.pp | 4 +- manifests/pxe.pp | 36 +++++++-------- 11 files changed, 68 insertions(+), 102 deletions(-) diff --git a/manifests/api.pp b/manifests/api.pp index be996304..cba65457 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -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; diff --git a/manifests/conductor.pp b/manifests/conductor.pp index e19854f8..c7bef6df 100644 --- a/manifests/conductor.pp +++ b/manifests/conductor.pp @@ -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 diff --git a/manifests/config.pp b/manifests/config.pp index 437526f6..e39d8711 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -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) } diff --git a/manifests/drivers/pxe.pp b/manifests/drivers/pxe.pp index 9cd03d9f..df26324a 100644 --- a/manifests/drivers/pxe.pp +++ b/manifests/drivers/pxe.pp @@ -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) diff --git a/manifests/inspector.pp b/manifests/inspector.pp index 3cedd17a..5596fd90 100644 --- a/manifests/inspector.pp +++ b/manifests/inspector.pp @@ -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 diff --git a/manifests/inspector/config.pp b/manifests/inspector/config.pp index 73ece67c..3e39582a 100644 --- a/manifests/inspector/config.pp +++ b/manifests/inspector/config.pp @@ -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) } diff --git a/manifests/inspector/policy.pp b/manifests/inspector/policy.pp index 7cd3cd5e..9f7370bd 100644 --- a/manifests/inspector/policy.pp +++ b/manifests/inspector/policy.pp @@ -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, diff --git a/manifests/inventory.pp b/manifests/inventory.pp index 60517acc..71493a89 100644 --- a/manifests/inventory.pp +++ b/manifests/inventory.pp @@ -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 { diff --git a/manifests/json_rpc.pp b/manifests/json_rpc.pp index 2241157b..6c9efe5a 100644 --- a/manifests/json_rpc.pp +++ b/manifests/json_rpc.pp @@ -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 diff --git a/manifests/policy.pp b/manifests/policy.pp index b8e934bc..af4fa4d8 100644 --- a/manifests/policy.pp +++ b/manifests/policy.pp @@ -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, diff --git a/manifests/pxe.pp b/manifests/pxe.pp index cdcfdcb4..7a565253 100644 --- a/manifests/pxe.pp +++ b/manifests/pxe.pp @@ -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)