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: Ie0133b0b05a58ffe86e5474c1150f935ca9f30d2
This commit is contained in:
Tobias Urdin 2019-02-10 13:55:56 +01:00
parent 8f647a94f7
commit 45303fec6d
11 changed files with 19 additions and 17 deletions

View File

@ -195,8 +195,8 @@ class cinder::api (
include ::cinder::params
include ::cinder::policy
validate_bool($manage_service)
validate_bool($enabled)
validate_legacy(Boolean, 'validate_bool', $manage_service)
validate_legacy(Boolean, 'validate_bool', $enabled)
$deprecated_param_names = [
'nova_catalog_info',

View File

@ -236,7 +236,8 @@ define cinder::backend::netapp (
include ::cinder::deps
if $nfs_shares {
validate_array($nfs_shares)
validate_legacy(Array, 'validate_array', $nfs_shares)
file {$nfs_shares_config:
content => join($nfs_shares, "\n"),
require => Anchor['cinder::install::end'],

View File

@ -60,8 +60,8 @@ class cinder::backup (
include ::cinder::deps
include ::cinder::params
validate_bool($manage_service)
validate_bool($enabled)
validate_legacy(Boolean, 'validate_bool', $manage_service)
validate_legacy(Boolean, 'validate_bool', $enabled)
if $::cinder::params::backup_package {
package { 'cinder-backup':

View File

@ -81,7 +81,8 @@ class cinder::backup::nfs (
) {
include ::cinder::deps
validate_string($backup_share)
validate_legacy(String, 'validate_string', $backup_share)
cinder_config {
'DEFAULT/backup_mount_options': value => $backup_mount_options;

View File

@ -35,8 +35,8 @@ class cinder::config (
include ::cinder::deps
validate_hash($cinder_config)
validate_hash($api_paste_ini_config)
validate_legacy(Hash, 'validate_hash', $cinder_config)
validate_legacy(Hash, 'validate_hash', $api_paste_ini_config)
create_resources('cinder_config', $cinder_config)
create_resources('cinder_api_paste_ini', $api_paste_ini_config)

View File

@ -66,8 +66,8 @@ class cinder::db (
$database_retry_interval_real = pick($::cinder::database_retry_interval,$database_retry_interval)
$database_max_overflow_real = pick($::cinder::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+)?'])
oslo::db { 'cinder_config':
db_max_retries => $database_db_max_retries,

View File

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

View File

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

View File

@ -31,8 +31,8 @@ class cinder::scheduler (
include ::cinder::deps
include ::cinder::params
validate_bool($manage_service)
validate_bool($enabled)
validate_legacy(Boolean, 'validate_bool', $manage_service)
validate_legacy(Boolean, 'validate_bool', $enabled)
cinder_config { 'DEFAULT/scheduler_driver': value => $scheduler_driver; }

View File

@ -46,8 +46,8 @@ class cinder::volume (
include ::cinder::deps
include ::cinder::params
validate_bool($manage_service)
validate_bool($enabled)
validate_legacy(Boolean, 'validate_bool', $manage_service)
validate_legacy(Boolean, 'validate_bool', $enabled)
if $::cinder::params::volume_package {
package { 'cinder-volume':

View File

@ -124,7 +124,7 @@ describe 'cinder::backend::netapp' do
})
end
it { should raise_error(Puppet::Error, /"not an array" is not an Array. It looks to be a String/) }
it { should raise_error(Puppet::Error) }
end
context 'with name search pattern' do