Use validate_legacy

This changes all the puppet 3 validate_* functions
to use the validate_legacy function.

The validate_legacy function has been available since
about three years but require Puppet >= 4.4.0 and since
there is Puppet 4.10.12 as latest we should assume people
are running a fairly new Puppet 4 version.

This is the first step to then remove all validate function
calls and use proper types for parameter as described in spec [1].

[1] https://review.openstack.org/#/c/568929/

Change-Id: I99d3e1b6081bcd706e39de5ca7ffae9db8fc6cb0
This commit is contained in:
Tobias Urdin 2019-02-23 17:17:25 +01:00
parent 5fdbb26cbf
commit f472852b75
15 changed files with 46 additions and 47 deletions

View File

@ -84,9 +84,9 @@ class neutron::agents::ml2::linuxbridge (
$purge_config = false,
) {
validate_array($tunnel_types)
validate_array($physical_interface_mappings)
validate_array($bridge_mappings)
validate_legacy(Array, 'validate_array', $tunnel_types)
validate_legacy(Array, 'validate_array', $physical_interface_mappings)
validate_legacy(Array, 'validate_array', $bridge_mappings)
include ::neutron::deps
include ::neutron::params

View File

@ -211,7 +211,7 @@ class neutron::agents::ml2::ovs (
}
}
validate_array($tunnel_types)
validate_legacy(Array, 'validate_array', $tunnel_types)
if size($tunnel_types) > 0 {
$enable_tunneling = true
} else {

View File

@ -136,34 +136,34 @@ class neutron::config (
include ::neutron::deps
validate_hash($server_config)
validate_hash($api_config)
validate_hash($bgpvpn_bagpipe_config)
validate_hash($bgpvpn_service_config)
validate_hash($l2gw_agent_config)
validate_hash($l2gw_service_config)
validate_hash($sfc_service_config)
validate_hash($l3_agent_config)
validate_hash($dhcp_agent_config)
validate_hash($metadata_agent_config)
validate_hash($ovn_metadata_agent_config)
validate_hash($metering_agent_config)
validate_hash($vpnaas_agent_config)
validate_hash($bgp_dragent_config)
validate_hash($plugin_linuxbridge_config)
validate_hash($plugin_cisco_db_conn_config)
validate_hash($plugin_cisco_l2network_config)
validate_hash($plugin_cisco_config)
validate_hash($plugin_midonet_config)
validate_hash($plugin_plumgrid_config)
validate_hash($plugin_opencontrail_config)
validate_hash($plugin_nuage_config)
validate_hash($plugin_ml2_config)
validate_hash($plugin_nsx_config)
validate_hash($plugin_nvp_config)
validate_legacy(Hash, 'validate_hash', $server_config)
validate_legacy(Hash, 'validate_hash', $api_config)
validate_legacy(Hash, 'validate_hash', $bgpvpn_bagpipe_config)
validate_legacy(Hash, 'validate_hash', $bgpvpn_service_config)
validate_legacy(Hash, 'validate_hash', $l2gw_agent_config)
validate_legacy(Hash, 'validate_hash', $l2gw_service_config)
validate_legacy(Hash, 'validate_hash', $sfc_service_config)
validate_legacy(Hash, 'validate_hash', $l3_agent_config)
validate_legacy(Hash, 'validate_hash', $dhcp_agent_config)
validate_legacy(Hash, 'validate_hash', $metadata_agent_config)
validate_legacy(Hash, 'validate_hash', $ovn_metadata_agent_config)
validate_legacy(Hash, 'validate_hash', $metering_agent_config)
validate_legacy(Hash, 'validate_hash', $vpnaas_agent_config)
validate_legacy(Hash, 'validate_hash', $bgp_dragent_config)
validate_legacy(Hash, 'validate_hash', $plugin_linuxbridge_config)
validate_legacy(Hash, 'validate_hash', $plugin_cisco_db_conn_config)
validate_legacy(Hash, 'validate_hash', $plugin_cisco_l2network_config)
validate_legacy(Hash, 'validate_hash', $plugin_cisco_config)
validate_legacy(Hash, 'validate_hash', $plugin_midonet_config)
validate_legacy(Hash, 'validate_hash', $plugin_plumgrid_config)
validate_legacy(Hash, 'validate_hash', $plugin_opencontrail_config)
validate_legacy(Hash, 'validate_hash', $plugin_nuage_config)
validate_legacy(Hash, 'validate_hash', $plugin_ml2_config)
validate_legacy(Hash, 'validate_hash', $plugin_nsx_config)
validate_legacy(Hash, 'validate_hash', $plugin_nvp_config)
if $lbaas_agent_config {
validate_hash($lbaas_agent_config)
validate_legacy(Hash, 'validate_hash', $lbaas_agent_config)
warning('neutron::config::lbaas_agent_config is deprecated and will be removed in a future release')
create_resources('neutron_lbaas_agent_config', $lbaas_agent_config)

View File

@ -66,8 +66,8 @@ class neutron::db (
$database_retry_interval_real = pick($::neutron::server::database_retry_interval, $database_retry_interval)
$database_max_overflow_real = pick($::neutron::server::database_max_overflow, $database_max_overflow)
validate_re($database_connection_real,
'^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
validate_legacy(Oslo::Dbconn, 'validate_re', $database_connection_real,
['^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?'])
if $database_connection_real {

View File

@ -42,7 +42,7 @@ class neutron::db::mysql (
include ::neutron::deps
validate_string($password)
validate_legacy(String, 'validate_string', $password)
::openstacklib::db::mysql { 'neutron':
user => $user,

View File

@ -226,7 +226,7 @@ class neutron::plugins::ml2 (
'ml2/physical_network_mtus': ensure => absent;
}
} else {
validate_array($physical_network_mtus)
validate_legacy(Array, 'validate_array', $physical_network_mtus)
neutron_plugin_ml2 {
'ml2/physical_network_mtus': value => join($physical_network_mtus, ',');
}

View File

@ -61,7 +61,7 @@ class neutron::plugins::ml2::arista::l3(
require ::neutron::plugins::ml2
if !is_service_default($mlag_config) {
validate_bool($mlag_config)
validate_legacy(Boolean, 'validate_bool', $mlag_config)
if $mlag_config and is_service_default($secondary_l3_host) {
fail('Must set secondary_l3_host when mlag_config is true.')
}

View File

@ -76,7 +76,7 @@ class neutron::plugins::ml2::ovn(
require ::neutron::plugins::ml2
if ! is_service_default($ovn_l3_mode) {
validate_bool($ovn_l3_mode)
validate_legacy(Boolean, 'validate_bool', $ovn_l3_mode)
}
if ! ( $vif_type in ['ovs', 'vhostuser', $::os_service_default] ) {

View File

@ -121,7 +121,7 @@ define neutron::plugins::ml2::type_driver (
elsif ($name == 'geneve') {
validate_vni_ranges($vni_ranges)
if !is_service_default($max_header_size) {
validate_integer($max_header_size)
validate_legacy(Integer, 'validate_integer', $max_header_size)
}
neutron_plugin_ml2 {
'ml2_type_geneve/max_header_size': value => $max_header_size;

View File

@ -51,7 +51,7 @@ class neutron::plugins::nvp (
tag => ['neutron-package', 'openstack'],
}
validate_array($nvp_controllers)
validate_legacy(Array, 'validate_array', $nvp_controllers)
resources { 'neutron_plugin_nvp':
purge => $purge_config,

View File

@ -69,7 +69,7 @@ class neutron::plugins::opencontrail (
include ::neutron::deps
include ::neutron::params
validate_array($contrail_extensions)
validate_legacy(Array, 'validate_array', $contrail_extensions)
package { 'neutron-plugin-contrail':
ensure => $package_ensure,

View File

@ -31,7 +31,7 @@ class neutron::policy (
include ::neutron::deps
include ::neutron::params
validate_hash($policies)
validate_legacy(Hash, 'validate_hash', $policies)
Openstacklib::Policy::Base {
file_path => $policy_path,

View File

@ -302,17 +302,16 @@ class neutron::server (
include ::keystone::client
if !is_service_default($default_availability_zones) {
validate_array($default_availability_zones)
validate_legacy(Array, 'validate_array', $default_availability_zones)
}
if !is_service_default($dhcp_load_type) {
validate_re($dhcp_load_type,
['^networks$', '^subnets$', '^ports$'],
'Must pass either networks, subnets, or ports as values for dhcp_load_type')
validate_legacy(Enum['networks', 'subnets', 'ports'], 'validate_re', $dhcp_load_type,
[['^networks$', '^subnets$', '^ports$']])
}
if !is_service_default($service_providers) {
validate_array($service_providers)
validate_legacy(Array, 'validate_array', $service_providers)
}
if $ensure_fwaas_package {

View File

@ -57,7 +57,7 @@ class neutron::services::l2gw (
include ::neutron::params
if !is_service_default($service_providers) {
validate_array($service_providers)
validate_legacy(Array, 'validate_array', $service_providers)
}
ensure_resource( 'package', 'python-networking-l2gw', {

View File

@ -165,7 +165,7 @@ describe 'neutron::server' do
params.merge!(:dhcp_load_type => 'badvalue')
end
it { should raise_error(Puppet::Error, /Must pass either networks, subnets, or ports as values for dhcp_load_type/) }
it { should raise_error(Puppet::Error) }
end
context 'with multiple service providers' do