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: I53648532bc2aa7031f33b82e2b8486f6927be49d
This commit is contained in:
parent
d1f6a53cd6
commit
abf035e3b0
@ -252,7 +252,7 @@ class nova::compute (
|
||||
}
|
||||
|
||||
if !empty($neutron_physnets_numa_nodes_mapping) {
|
||||
validate_hash($neutron_physnets_numa_nodes_mapping)
|
||||
validate_legacy(Hash, 'validate_hash', $neutron_physnets_numa_nodes_mapping)
|
||||
$neutron_physnets_real = keys($neutron_physnets_numa_nodes_mapping)
|
||||
nova_config {
|
||||
'neutron/physnets': value => join(any2array($neutron_physnets_real), ',');
|
||||
|
@ -275,7 +275,7 @@ class nova::compute::libvirt (
|
||||
# cpu_model param is only valid if cpu_mode=custom
|
||||
# otherwise it should be commented out
|
||||
if $libvirt_cpu_mode_real == 'custom' {
|
||||
validate_string($libvirt_cpu_model)
|
||||
validate_legacy(String, 'validate_string', $libvirt_cpu_model)
|
||||
nova_config {
|
||||
'libvirt/cpu_model': value => $libvirt_cpu_model;
|
||||
}
|
||||
@ -289,7 +289,7 @@ class nova::compute::libvirt (
|
||||
}
|
||||
|
||||
if $libvirt_cpu_mode_real != 'none' {
|
||||
validate_string($libvirt_cpu_model_extra_flags)
|
||||
validate_legacy(String, 'validate_string', $libvirt_cpu_model_extra_flags)
|
||||
nova_config {
|
||||
'libvirt/cpu_model_extra_flags': value => $libvirt_cpu_model_extra_flags;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class nova::compute::libvirt::config (
|
||||
$libvirtd_config = {},
|
||||
) {
|
||||
|
||||
validate_hash($libvirtd_config)
|
||||
validate_legacy(Hash, 'validate_hash', $libvirtd_config)
|
||||
|
||||
create_resources('libvirtd_config', $libvirtd_config)
|
||||
}
|
||||
|
@ -34,8 +34,8 @@ class nova::config (
|
||||
|
||||
include ::nova::deps
|
||||
|
||||
validate_hash($nova_config)
|
||||
validate_hash($nova_paste_api_ini)
|
||||
validate_legacy(Hash, 'validate_hash', $nova_config)
|
||||
validate_legacy(Hash, 'validate_hash', $nova_paste_api_ini)
|
||||
|
||||
create_resources('nova_config', $nova_config)
|
||||
create_resources('nova_paste_api_ini', $nova_paste_api_ini)
|
||||
|
@ -116,8 +116,8 @@ class nova::db (
|
||||
|
||||
if !is_service_default($database_connection_real) {
|
||||
|
||||
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+)?'])
|
||||
|
||||
oslo::db { 'nova_config':
|
||||
db_max_retries => $database_db_max_retries,
|
||||
@ -135,8 +135,8 @@ class nova::db (
|
||||
|
||||
if !is_service_default($api_database_connection_real) {
|
||||
|
||||
validate_re($api_database_connection_real,
|
||||
'^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
|
||||
validate_legacy(Oslo::Dbconn, 'validate_re', $api_database_connection_real,
|
||||
['^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?'])
|
||||
|
||||
nova_config {
|
||||
'api_database/connection': value => $api_database_connection_real, secret => true;
|
||||
@ -147,8 +147,8 @@ class nova::db (
|
||||
|
||||
if !is_service_default($placement_database_connection_real) {
|
||||
|
||||
validate_re($placement_database_connection_real,
|
||||
'^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
|
||||
validate_legacy(Oslo::Dbconn, 'validate_re', $placement_database_connection_real,
|
||||
['^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?'])
|
||||
|
||||
nova_config {
|
||||
'placement_database/connection': value => $placement_database_connection_real, secret => true;
|
||||
|
@ -527,7 +527,7 @@ class nova(
|
||||
warning('nova::use_ipv6 is deprecated and will be removed in a future release')
|
||||
}
|
||||
|
||||
validate_array($enabled_ssl_apis)
|
||||
validate_legacy(Array, 'validate_array', $enabled_ssl_apis)
|
||||
if empty($enabled_ssl_apis) and $use_ssl {
|
||||
warning('enabled_ssl_apis is empty but use_ssl is set to true')
|
||||
}
|
||||
|
@ -101,8 +101,10 @@ class nova::migration::libvirt(
|
||||
$transport_real = 'tcp'
|
||||
}
|
||||
|
||||
validate_re($transport_real, ['^tcp$', '^tls$', '^ssh$'], 'Valid options for transport are tcp, tls, ssh.')
|
||||
validate_re($auth, [ '^sasl$', '^none$' ], 'Valid options for auth are none and sasl.')
|
||||
validate_legacy(Enum['tcp', 'tls', 'ssh'], 'validate_re', $transport_real,
|
||||
[['^tcp$', '^tls$', '^ssh$'], 'Valid options for transport are tcp, tls, ssh.'])
|
||||
validate_legacy(Enum['sasl', 'none'], 'validate_re', $auth,
|
||||
[['^sasl$', '^none$'], 'Valid options for auth are none and sasl.'])
|
||||
|
||||
if $transport_real == 'tls' {
|
||||
$listen_tls = '1'
|
||||
|
@ -98,6 +98,8 @@ class nova::placement(
|
||||
|
||||
include ::nova::deps
|
||||
|
||||
validate_legacy(Boolean, 'validate_bool', $enabled)
|
||||
|
||||
if $os_interface {
|
||||
warning('nova::placement::os_interface is deprecated for removal, please use valid_interfaces instead.')
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ class nova::policy (
|
||||
include ::nova::deps
|
||||
include ::nova::params
|
||||
|
||||
validate_hash($policies)
|
||||
validate_legacy(Hash, 'validate_hash', $policies)
|
||||
|
||||
$policy_defaults = {
|
||||
file_path => $policy_path,
|
||||
|
@ -141,7 +141,7 @@ class nova::scheduler::filter (
|
||||
# - if set, we'll validate it's an array that is not empty and configure the parameter.
|
||||
# - Otherwise, fallback to default.
|
||||
if !is_service_default($scheduler_default_filters) and !empty($scheduler_default_filters){
|
||||
validate_array($scheduler_default_filters)
|
||||
validate_legacy(Array, 'validate_array', $scheduler_default_filters)
|
||||
$scheduler_default_filters_real = join($scheduler_default_filters, ',')
|
||||
} else {
|
||||
$scheduler_default_filters_real = $::os_service_default
|
||||
@ -165,13 +165,13 @@ no effect. Baremetal scheduling now uses custom resource classes.')
|
||||
}
|
||||
|
||||
if !is_service_default($isolated_images) and !empty($isolated_images){
|
||||
validate_array($isolated_images)
|
||||
validate_legacy(Array, 'validate_array', $isolated_images)
|
||||
$isolated_images_real = join($isolated_images, ',')
|
||||
} else {
|
||||
$isolated_images_real = $::os_service_default
|
||||
}
|
||||
if !is_service_default($isolated_hosts) and !empty($isolated_hosts){
|
||||
validate_array($isolated_hosts)
|
||||
validate_legacy(Array, 'validate_array', $isolated_hosts)
|
||||
$isolated_hosts_real = join($isolated_hosts, ',')
|
||||
} else {
|
||||
$isolated_hosts_real = $::os_service_default
|
||||
|
@ -153,14 +153,14 @@ class nova::vendordata(
|
||||
}
|
||||
|
||||
if !is_service_default($vendordata_providers_pick) and !empty($vendordata_providers_pick){
|
||||
validate_array($vendordata_providers_pick)
|
||||
validate_legacy(Array, 'validate_array', $vendordata_providers_pick)
|
||||
$vendordata_providers_real = join($vendordata_providers_pick, ',')
|
||||
} else {
|
||||
$vendordata_providers_real = $::os_service_default
|
||||
}
|
||||
|
||||
if !is_service_default($vendordata_dynamic_targets_pick) and !empty($vendordata_dynamic_targets_pick){
|
||||
validate_array($vendordata_dynamic_targets_pick)
|
||||
validate_legacy(Array, 'validate_array', $vendordata_dynamic_targets_pick)
|
||||
$vendordata_dynamic_targets_real = join($vendordata_dynamic_targets_pick, ',')
|
||||
} else {
|
||||
$vendordata_dynamic_targets_real = $::os_service_default
|
||||
|
@ -146,7 +146,7 @@ describe 'nova::migration::libvirt' do
|
||||
}
|
||||
end
|
||||
it { expect { is_expected.to contain_class('nova::compute::libvirt') }.to \
|
||||
raise_error(Puppet::Error, /Valid options for auth are none and sasl./) }
|
||||
raise_error(Puppet::Error) }
|
||||
end
|
||||
|
||||
context 'when not configuring libvirt' do
|
||||
|
Loading…
Reference in New Issue
Block a user