diff --git a/manifests/api.pp b/manifests/api.pp index d7ba9f10..6ffd8a6f 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -42,19 +42,19 @@ # (optional) OpenStack privileged account username. Used for requests to # other services (such as Nova) that require an account with # special rights. -# Defaults to undef. +# Defaults to $::os_service_default. # # [*os_privileged_user_password*] # (optional) Password associated with the OpenStack privileged account. -# Defaults to undef. +# Defaults to $::os_service_default. # # [*os_privileged_user_tenant*] # (optional) Tenant name associated with the OpenStack privileged account. -# Defaults to undef. +# Defaults to $::os_service_default. # # [*os_privileged_user_auth_url*] # (optional) Auth URL associated with the OpenStack privileged account. -# Defaults to undef. +# Defaults to $::os_service_default. # # [*os_region_name*] # (optional) Some operations require cinder to make API requests @@ -117,7 +117,7 @@ # # [*ratelimits*] # (optional) The state of the service -# Defaults to undef. If undefined the default ratelimiting values are used. +# Defaults to $::os_service_default. If undefined the default ratelimiting values are used. # # [*ratelimits_factory*] # (optional) Factory to use for ratelimiting @@ -165,16 +165,16 @@ class cinder::api ( $nova_catalog_admin_info = 'compute:Compute Service:adminURL', $os_region_name = $::os_service_default, $privileged_user = false, - $os_privileged_user_name = undef, - $os_privileged_user_password = undef, - $os_privileged_user_tenant = undef, - $os_privileged_user_auth_url = undef, + $os_privileged_user_name = $::os_service_default, + $os_privileged_user_password = $::os_service_default, + $os_privileged_user_tenant = $::os_service_default, + $os_privileged_user_auth_url = $::os_service_default, $service_workers = $::processorcount, $package_ensure = 'present', $bind_host = '0.0.0.0', $enabled = true, $manage_service = true, - $ratelimits = undef, + $ratelimits = $::os_service_default, $default_volume_type = $::os_service_default, $ratelimits_factory = 'cinder.api.v1.limits:RateLimitingMiddleware.factory', @@ -244,40 +244,25 @@ class cinder::api ( } if $privileged_user { - if !$os_privileged_user_name { + if is_service_default($os_privileged_user_name) { fail('The os_privileged_user_name parameter is required when privileged_user is set to true') } - if !$os_privileged_user_password { + if is_service_default($os_privileged_user_password) { fail('The os_privileged_user_password parameter is required when privileged_user is set to true') } - if !$os_privileged_user_tenant { + if is_service_default($os_privileged_user_tenant) { fail('The os_privileged_user_tenant parameter is required when privileged_user is set to true') } - - cinder_config { - 'DEFAULT/os_privileged_user_password': value => $os_privileged_user_password; - 'DEFAULT/os_privileged_user_tenant': value => $os_privileged_user_tenant; - 'DEFAULT/os_privileged_user_name': value => $os_privileged_user_name; - } - - if $os_privileged_user_auth_url { - cinder_config { - 'DEFAULT/os_privileged_user_auth_url': value => $os_privileged_user_auth_url; - } - } else { - cinder_config { - 'DEFAULT/os_privileged_user_auth_url': ensure => absent; - } - } - } else { - cinder_config { - 'DEFAULT/os_privileged_user_password': ensure => absent; - 'DEFAULT/os_privileged_user_tenant': ensure => absent; - 'DEFAULT/os_privileged_user_name': ensure => absent; - 'DEFAULT/os_privileged_user_auth_url': ensure => absent; - } } + cinder_config { + 'DEFAULT/os_privileged_user_password': value => $os_privileged_user_password; + 'DEFAULT/os_privileged_user_tenant': value => $os_privileged_user_tenant; + 'DEFAULT/os_privileged_user_name': value => $os_privileged_user_name; + 'DEFAULT/os_privileged_user_auth_url': value => $os_privileged_user_auth_url; + } + + if $keystone_auth_uri and $auth_uri { fail('both keystone_auth_uri and auth_uri are set and they have the same meaning') } @@ -393,7 +378,7 @@ class cinder::api ( } } - if ($ratelimits != undef) { + if (!is_service_default($ratelimits)) { cinder_api_paste_ini { 'filter:ratelimit/paste.filter_factory': value => $ratelimits_factory; 'filter:ratelimit/limits': value => $ratelimits; diff --git a/manifests/backup.pp b/manifests/backup.pp index 50dd0b9e..beeb7c5b 100644 --- a/manifests/backup.pp +++ b/manifests/backup.pp @@ -14,19 +14,19 @@ # # [*backup_topic*] # (optional) The topic volume backup nodes listen on. -# Defaults to 'cinder-backup' +# Defaults to $::os_service_default # # [*backup_manager*] # (optional) Full class name for the Manager for volume backup. -# Defaults to 'cinder.backup.manager.BackupManager' +# Defaults to $::os_service_default # # [*backup_api_class*] # (optional) The full class name of the volume backup API class. -# Defaults to 'cinder.backup.api.API' +# Defaults to $::os_service_default # # [*backup_name_template*] # (optional) Template string to be used to generate backup names. -# Defaults to 'backup-%s' +# Defaults to $::os_service_default # # === Author(s) # @@ -52,10 +52,10 @@ class cinder::backup ( $enabled = true, $package_ensure = 'present', - $backup_topic = 'cinder-backup', - $backup_manager = 'cinder.backup.manager.BackupManager', - $backup_api_class = 'cinder.backup.api.API', - $backup_name_template = 'backup-%s' + $backup_topic = $::os_service_default, + $backup_manager = $::os_service_default, + $backup_api_class = $::os_service_default, + $backup_name_template = $::os_service_default, ) { include ::cinder::params diff --git a/manifests/backup/nfs.pp b/manifests/backup/nfs.pp index 95fe83c7..575aff54 100644 --- a/manifests/backup/nfs.pp +++ b/manifests/backup/nfs.pp @@ -17,23 +17,23 @@ # backups. If the volume being backed up exceeds this size, then # it will be backed up into multiple files. This must be a multiple # of the backup_sha_block_size_bytes parameter. -# Defaults to 1999994880 +# Defaults to $::os_service_default # # [*backup_sha_block_size_bytes*] # (optional) The size in bytes that changes are tracked for # incremental backups. -# Defaults to 32768 +# Defaults to $::os_service_default # # [*backup_enable_progress_timer*] # (optional) Enable or Disable the timer to send the periodic # progress notifications to Ceilometer when backing up the volume # to the backend storage. -# Defaults to true +# Defaults to $::os_service_default # # [*backup_mount_point_base*] # (optional) The base directory containing the mount point for the # NFS share. -# Defaults to '$state_path/backup_mount' +# Defaults to $::os_service_default # # [*backup_mount_options*] # (optional) The mount options that are passed to the NFS client. @@ -45,7 +45,7 @@ # # [*backup_compression_algorithm*] # (optional) Compression algorithm to use when writing backup data. -# Defaults to 'zlib' +# Defaults to $::os_service_default # # === Author(s) # @@ -71,13 +71,13 @@ class cinder::backup::nfs ( $backup_share, $backup_driver = 'cinder.backup.drivers.nfs', - $backup_file_size = 1999994880, - $backup_sha_block_size_bytes = 32768, - $backup_enable_progress_timer = true, - $backup_mount_point_base = '$state_path/backup_mount', + $backup_file_size = $::os_service_default, + $backup_sha_block_size_bytes = $::os_service_default, + $backup_enable_progress_timer = $::os_service_default, + $backup_mount_point_base = $::os_service_default, $backup_mount_options = $::os_service_default, $backup_container = $::os_service_default, - $backup_compression_algorithm = 'zlib', + $backup_compression_algorithm = $::os_service_default, ) { validate_string($backup_share) diff --git a/manifests/backup/swift.pp b/manifests/backup/swift.pp index 8baf8bbe..b17a3120 100644 --- a/manifests/backup/swift.pp +++ b/manifests/backup/swift.pp @@ -19,19 +19,19 @@ # # [*backup_swift_object_size*] # (optional) The size in bytes of Swift backup objects. -# Defaults to '52428800' +# Defaults to $::os_service_default # # [*backup_swift_retry_attempts*] # (optional) The number of retries to make for Swift operations. -# Defaults to '3' +# Defaults to $::os_service_default # # [*backup_swift_retry_backoff*] # (optional) The backoff time in seconds between Swift retries. -# Defaults to '2' +# Defaults to $::os_service_default # # [*backup_compression_algorithm*] # (optional) The compression algorithm for the chunks sent to swift -# Defaults to 'zlib' +# Defaults to $::os_service_default # set to None to disable compression # # === Author(s) @@ -59,12 +59,16 @@ class cinder::backup::swift ( $backup_driver = 'cinder.backup.drivers.swift', $backup_swift_url = 'http://localhost:8080/v1/AUTH_', $backup_swift_container = 'volumes_backup', - $backup_swift_object_size = '52428800', - $backup_swift_retry_attempts = '3', - $backup_swift_retry_backoff = '2', - $backup_compression_algorithm = 'zlib', + $backup_swift_object_size = $::os_service_default, + $backup_swift_retry_attempts = $::os_service_default, + $backup_swift_retry_backoff = $::os_service_default, + $backup_compression_algorithm = $::os_service_default, ) { + if ($backup_swift_container == 'volumes_backup') { + warning('WARNING: The default backup_swift_container value in puppet differs from the OpenStack default and may change in future releases') + } + cinder_config { 'DEFAULT/backup_driver': value => $backup_driver; 'DEFAULT/backup_swift_url': value => $backup_swift_url; diff --git a/manifests/glance.pp b/manifests/glance.pp index 8e9d146f..b4ebf024 100644 --- a/manifests/glance.pp +++ b/manifests/glance.pp @@ -16,11 +16,11 @@ # # [*glance_num_retries*] # (optional) Number retries when downloading an image from glance. -# Defaults to 0 +# Defaults to $::os_service_default # # [*glance_api_insecure*] # (optional) Allow to perform insecure SSL (https) requests to glance. -# Defaults to false +# Defaults to $::os_service_default # # [*glance_api_ssl_compression*] # (optional) Whether to attempt to negotiate SSL layer compression when @@ -28,11 +28,11 @@ # layer compression. In some cases disabling this may improve # data throughput, eg when high network bandwidth is available # and you are using already compressed image formats such as qcow2. -# Defaults to false +# Defaults to $::os_service_default # # [*glance_request_timeout*] # (optional) http/https timeout value for glance operations. -# Defaults to undef +# Defaults to $::os_service_default # # === Author(s) # @@ -57,23 +57,14 @@ class cinder::glance ( $glance_api_servers = undef, $glance_api_version = '2', - $glance_num_retries = '0', - $glance_api_insecure = false, - $glance_api_ssl_compression = false, - $glance_request_timeout = undef + $glance_num_retries = $::os_service_default, + $glance_api_insecure = $::os_service_default, + $glance_api_ssl_compression = $::os_service_default, + $glance_request_timeout = $::os_service_default, ) { - if is_array($glance_api_servers) { - cinder_config { - 'DEFAULT/glance_api_servers': value => join($glance_api_servers, ','); - } - } elsif is_string($glance_api_servers) { - cinder_config { - 'DEFAULT/glance_api_servers': value => $glance_api_servers; - } - } - cinder_config { + 'DEFAULT/glance_api_servers': value => join(any2array($glance_api_servers), ','); 'DEFAULT/glance_api_version': value => $glance_api_version; 'DEFAULT/glance_num_retries': value => $glance_num_retries; 'DEFAULT/glance_api_insecure': value => $glance_api_insecure; diff --git a/manifests/quota.pp b/manifests/quota.pp index a4f2322f..41dbbe9f 100644 --- a/manifests/quota.pp +++ b/manifests/quota.pp @@ -6,26 +6,26 @@ # # [*quota_volumes*] # (Optional) Number of volumes allowed per project. -# Defaults to '10'. +# Defaults to $::os_service_default # # [*quota_snapshots*] # (Optional) Number of volume snapshots allowed per project. -# Defaults to '10'. +# Defaults to $::os_service_default # # [*quota_gigabytes*] # (Optional) Number of volume gigabytes (snapshots are also included) # allowed per project. -# Defaults to 1000. +# Defaults to $::os_service_default. # # [*quota_driver*] # (Optional) Default driver to use for quota checks. -# Defaults to 'cinder.quota.DbQuotaDriver'. +# Defaults to $::os_service_default. # class cinder::quota ( - $quota_volumes = 10, - $quota_snapshots = 10, - $quota_gigabytes = 1000, - $quota_driver = 'cinder.quota.DbQuotaDriver' + $quota_volumes = $::os_service_default, + $quota_snapshots = $::os_service_default, + $quota_gigabytes = $::os_service_default, + $quota_driver = $::os_service_default, ) { cinder_config { diff --git a/manifests/scheduler/filter.pp b/manifests/scheduler/filter.pp index fa43fc5c..75a68b6f 100644 --- a/manifests/scheduler/filter.pp +++ b/manifests/scheduler/filter.pp @@ -6,17 +6,19 @@ # # [*scheduler_default_filters*] # A comma separated list of filters to be used by default -# Defaults to false +# Defaults to $::os_service_default class cinder::scheduler::filter ( - $scheduler_default_filters = false, + $scheduler_default_filters = $::os_service_default, ) { - if ($scheduler_default_filters) { - cinder_config { 'DEFAULT/scheduler_default_filters': value => join($scheduler_default_filters,',') + if (!is_service_default($scheduler_default_filters)) { + cinder_config { + 'DEFAULT/scheduler_default_filters': value => join(any2array($scheduler_default_filters),',') } } else { - cinder_config { 'DEFAULT/scheduler_default_filters': ensure => absent + cinder_config { + 'DEFAULT/scheduler_default_filters': ensure => absent } } diff --git a/manifests/volume/gpfs.pp b/manifests/volume/gpfs.pp index 04ede80d..d6f9288c 100644 --- a/manifests/volume/gpfs.pp +++ b/manifests/volume/gpfs.pp @@ -12,7 +12,7 @@ # (optional) Specifies the path of the Image service repository in GPFS. # Leave undefined if not storing images in GPFS. Defaults to "None" via # driver. -# Defaults to +# Defaults to $::os_service_default # # [*gpfs_images_share_mode*] # (optional) Specifies the type of image copy to be used. Set this when the @@ -22,7 +22,7 @@ # the image is made; "copy_on_write" specifies that copy-on-write # optimization strategy is used and unmodified blocks of the image file are # shared efficiently. Defaults to "None" via driver. -# Defaults to +# Defaults to $::os_service_default # # [*gpfs_max_clone_depth*] # (optional) Specifies an upper limit on the number of indirections required @@ -30,19 +30,19 @@ # copy-on-write snapshots or clones can have a negative impact on # performance, but improves space utilization. 0 indicates unlimited clone # depth. Defaults to "0" via driver implementation -# Defaults to +# Defaults to $::os_service_default # # [*gpfs_sparse_volumes*] # (optional) Specifies that volumes are created as sparse files which # initially consume no space. If set to False, the volume is created as a # fully allocated file, in which case, creation may take a significantly # longer time. Defaults to "True" via driver. -# Defaults to +# Defaults to $::os_service_default # # [*gpfs_storage_pool*] # (optional) Specifies the storage pool that volumes are assigned to. By # default, the system storage pool is used. Defaults to "system" via driver. -# Defaults to +# Defaults to $::os_service_default # # [*extra_options*] # (optional) Hash of extra options to pass to the backend stanza @@ -60,11 +60,11 @@ # class cinder::volume::gpfs( $gpfs_mount_point_base, - $gpfs_images_dir = '', - $gpfs_images_share_mode = '', - $gpfs_max_clone_depth = '', - $gpfs_sparse_volumes = '', - $gpfs_storage_pool = '', + $gpfs_images_dir = $::os_service_default, + $gpfs_images_share_mode = $::os_service_default, + $gpfs_max_clone_depth = $::os_service_default, + $gpfs_sparse_volumes = $::os_service_default, + $gpfs_storage_pool = $::os_service_default, $extra_options = {} ) { cinder::backend::gpfs { 'DEFAULT': diff --git a/spec/classes/cinder_api_spec.rb b/spec/classes/cinder_api_spec.rb index 7b5f9bde..15bcba38 100644 --- a/spec/classes/cinder_api_spec.rb +++ b/spec/classes/cinder_api_spec.rb @@ -80,10 +80,10 @@ describe 'cinder::api' do :value => 'http://localhost:5000/' ) - is_expected.to contain_cinder_config('DEFAULT/os_privileged_user_name').with_ensure('absent') - is_expected.to contain_cinder_config('DEFAULT/os_privileged_user_password').with_ensure('absent') - is_expected.to contain_cinder_config('DEFAULT/os_privileged_user_tenant').with_ensure('absent') - is_expected.to contain_cinder_config('DEFAULT/os_privileged_user_auth_url').with_ensure('absent') + is_expected.to contain_cinder_config('DEFAULT/os_privileged_user_name').with_value('') + is_expected.to contain_cinder_config('DEFAULT/os_privileged_user_password').with_value('') + is_expected.to contain_cinder_config('DEFAULT/os_privileged_user_tenant').with_value('') + is_expected.to contain_cinder_config('DEFAULT/os_privileged_user_auth_url').with_value('') end end @@ -141,7 +141,7 @@ describe 'cinder::api' do it { is_expected.to contain_cinder_config('DEFAULT/os_privileged_user_name').with_value('admin') } it { is_expected.to contain_cinder_config('DEFAULT/os_privileged_user_password').with_value('password') } it { is_expected.to contain_cinder_config('DEFAULT/os_privileged_user_tenant').with_value('admin') } - it { is_expected.to contain_cinder_config('DEFAULT/os_privileged_user_auth_url').with_ensure('absent') } + it { is_expected.to contain_cinder_config('DEFAULT/os_privileged_user_auth_url').with_value('') } end context 'without os_privileged_user' do diff --git a/spec/classes/cinder_backup_nfs_spec.rb b/spec/classes/cinder_backup_nfs_spec.rb index f805572b..f7e1a1c7 100644 --- a/spec/classes/cinder_backup_nfs_spec.rb +++ b/spec/classes/cinder_backup_nfs_spec.rb @@ -33,13 +33,13 @@ describe 'cinder::backup::nfs' do let :default_params do { :backup_driver => 'cinder.backup.drivers.nfs', - :backup_file_size => 1999994880, - :backup_sha_block_size_bytes => 32768, - :backup_enable_progress_timer => true, - :backup_mount_point_base => '$state_path/backup_mount', + :backup_file_size => '', + :backup_sha_block_size_bytes => '', + :backup_enable_progress_timer => '', + :backup_mount_point_base => '', :backup_mount_options => '', :backup_container => '', - :backup_compression_algorithm => 'zlib', + :backup_compression_algorithm => '', } end diff --git a/spec/classes/cinder_backup_spec.rb b/spec/classes/cinder_backup_spec.rb index 7a12cc5f..585db9d2 100644 --- a/spec/classes/cinder_backup_spec.rb +++ b/spec/classes/cinder_backup_spec.rb @@ -24,10 +24,10 @@ describe 'cinder::backup' do let :default_params do { :enable => true, - :backup_topic => 'cinder-backup', - :backup_manager => 'cinder.backup.manager.BackupManager', - :backup_api_class => 'cinder.backup.api.API', - :backup_name_template => 'backup-%s' } + :backup_topic => '', + :backup_manager => '', + :backup_api_class => '', + :backup_name_template => '' } end let :params do @@ -78,7 +78,7 @@ describe 'cinder::backup' do context 'on Debian platforms' do let :facts do - { :osfamily => 'Debian' } + @default_facts.merge!({ :osfamily => 'Debian' }) end let :platform_params do @@ -91,7 +91,7 @@ describe 'cinder::backup' do context 'on RedHat platforms' do let :facts do - { :osfamily => 'RedHat' } + @default_facts.merge!({ :osfamily => 'RedHat' }) end let :platform_params do diff --git a/spec/classes/cinder_backup_swift_spec.rb b/spec/classes/cinder_backup_swift_spec.rb index 50593798..f7ba02fa 100644 --- a/spec/classes/cinder_backup_swift_spec.rb +++ b/spec/classes/cinder_backup_swift_spec.rb @@ -25,10 +25,10 @@ describe 'cinder::backup::swift' do let :default_params do { :backup_swift_url => 'http://localhost:8080/v1/AUTH_', :backup_swift_container => 'volumes_backup', - :backup_swift_object_size => '52428800', - :backup_swift_retry_attempts => '3', - :backup_swift_retry_backoff => '2', - :backup_compression_algorithm => 'zlib' } + :backup_swift_object_size => '', + :backup_swift_retry_attempts => '', + :backup_swift_retry_backoff => '', + :backup_compression_algorithm => '' } end let :params do @@ -72,7 +72,7 @@ describe 'cinder::backup::swift' do context 'on Debian platforms' do let :facts do - { :osfamily => 'Debian' } + @default_facts.merge({ :osfamily => 'Debian' }) end it_configures 'cinder backup with swift' @@ -80,7 +80,7 @@ describe 'cinder::backup::swift' do context 'on RedHat platforms' do let :facts do - { :osfamily => 'RedHat' } + @default_facts.merge({ :osfamily => 'RedHat' }) end it_configures 'cinder backup with swift' diff --git a/spec/classes/cinder_glance_spec.rb b/spec/classes/cinder_glance_spec.rb index b915504e..d3203133 100644 --- a/spec/classes/cinder_glance_spec.rb +++ b/spec/classes/cinder_glance_spec.rb @@ -24,9 +24,10 @@ describe 'cinder::glance' do let :default_params do { :glance_api_version => '2', - :glance_num_retries => '0', - :glance_api_insecure => false, - :glance_api_ssl_compression => false } + :glance_num_retries => '', + :glance_api_insecure => '', + :glance_api_ssl_compression => '', + :glance_request_timeout => '' } end let :params do @@ -42,6 +43,8 @@ describe 'cinder::glance' do is_expected.to contain_cinder_config('DEFAULT/glance_api_version').with_value(p[:glance_api_version]) is_expected.to contain_cinder_config('DEFAULT/glance_num_retries').with_value(p[:glance_num_retries]) is_expected.to contain_cinder_config('DEFAULT/glance_api_insecure').with_value(p[:glance_api_insecure]) + is_expected.to contain_cinder_config('DEFAULT/glance_api_ssl_compression').with_value(p[:glance_api_ssl_compression]) + is_expected.to contain_cinder_config('DEFAULT/glance_request_timeout').with_value(p[:glance_request_timeout]) end context 'configure cinder with one glance server' do @@ -65,7 +68,7 @@ describe 'cinder::glance' do context 'on Debian platforms' do let :facts do - { :osfamily => 'Debian' } + @default_facts.merge({ :osfamily => 'Debian' }) end it_configures 'cinder with glance' @@ -73,7 +76,7 @@ describe 'cinder::glance' do context 'on RedHat platforms' do let :facts do - { :osfamily => 'RedHat' } + @default_facts.merge({ :osfamily => 'RedHat' }) end it_configures 'cinder with glance' diff --git a/spec/classes/cinder_quota_spec.rb b/spec/classes/cinder_quota_spec.rb index 54d34287..ea9971d4 100644 --- a/spec/classes/cinder_quota_spec.rb +++ b/spec/classes/cinder_quota_spec.rb @@ -1,35 +1,60 @@ require 'spec_helper' describe 'cinder::quota' do + let :default_params do + { :quota_volumes => '', + :quota_snapshots => '', + :quota_gigabytes => '', + :quota_driver => '' } + end + + let :params do + {} + end + + shared_examples_for 'cinder quota' do + + let :p do + default_params.merge(params) + end - describe 'with default parameters' do it 'contains default values' do - is_expected.to contain_cinder_config('DEFAULT/quota_volumes').with( - :value => 10) - is_expected.to contain_cinder_config('DEFAULT/quota_snapshots').with( - :value => 10) - is_expected.to contain_cinder_config('DEFAULT/quota_gigabytes').with( - :value => 1000) - is_expected.to contain_cinder_config('DEFAULT/quota_driver').with( - :value => 'cinder.quota.DbQuotaDriver') + is_expected.to contain_cinder_config('DEFAULT/quota_volumes').with_value(p[:quota_volumes]) + is_expected.to contain_cinder_config('DEFAULT/quota_snapshots').with_value(p[:quota_snapshots]) + is_expected.to contain_cinder_config('DEFAULT/quota_gigabytes').with_value(p[:quota_gigabytes]) + is_expected.to contain_cinder_config('DEFAULT/quota_driver').with_value(p[:quota_driver]) + end + + context 'configure quota with parameters' do + before :each do + params.merge!({ :quota_volumes => 1000, + :quota_snapshots => 1000, + :quota_gigabytes => 100000 }) + end + + it 'contains overrided values' do + is_expected.to contain_cinder_config('DEFAULT/quota_volumes').with_value(p[:quota_volumes]) + is_expected.to contain_cinder_config('DEFAULT/quota_snapshots').with_value(p[:quota_snapshots]) + is_expected.to contain_cinder_config('DEFAULT/quota_gigabytes').with_value(p[:quota_gigabytes]) + is_expected.to contain_cinder_config('DEFAULT/quota_driver').with_value(p[:quota_driver]) + end end end - describe 'with overridden parameters' do - let :params do - { :quota_volumes => 1000, - :quota_snapshots => 1000, - :quota_gigabytes => 100000 } - end - it 'contains overrided values' do - is_expected.to contain_cinder_config('DEFAULT/quota_volumes').with( - :value => 1000) - is_expected.to contain_cinder_config('DEFAULT/quota_snapshots').with( - :value => 1000) - is_expected.to contain_cinder_config('DEFAULT/quota_gigabytes').with( - :value => 100000) - is_expected.to contain_cinder_config('DEFAULT/quota_driver').with( - :value => 'cinder.quota.DbQuotaDriver') + context 'on Debian platforms' do + let :facts do + @default_facts.merge({ :osfamily => 'Debian' }) end + + it_configures 'cinder quota' end + + context 'on RedHat platforms' do + let :facts do + @default_facts.merge({ :osfamily => 'RedHat' }) + end + + it_configures 'cinder quota' + end + end diff --git a/spec/classes/cinder_scheduler_filter_spec.rb b/spec/classes/cinder_scheduler_filter_spec.rb index 927f46a7..9dd5644b 100644 --- a/spec/classes/cinder_scheduler_filter_spec.rb +++ b/spec/classes/cinder_scheduler_filter_spec.rb @@ -2,16 +2,64 @@ require 'spec_helper' describe 'cinder::scheduler::filter' do - describe 'when overriding params' do + let :default_params do + { :scheduler_default_filters => '' } + end - let :params do - { - :scheduler_default_filters => ['AvailabilityZoneFilter', 'CapacityFilter', 'CapabilitiesFilter'] - } + let :params do + {} + end + + shared_examples_for 'cinder scheduler filter' do + + let :p do + default_params.merge(params) end - it { is_expected.to contain_cinder_config('DEFAULT/scheduler_default_filters').with_value('AvailabilityZoneFilter,CapacityFilter,CapabilitiesFilter') } + it 'contains default values' do + is_expected.to contain_cinder_config('DEFAULT/scheduler_default_filters').with_ensure('absent') + end + + context 'configure filters with array' do + before :each do + params.merge!({ + :scheduler_default_filters => ['AvailabilityZoneFilter', 'CapacityFilter', 'CapabilitiesFilter'] + }) + end + + it 'contains overrided values' do + is_expected.to contain_cinder_config('DEFAULT/scheduler_default_filters').with_value(p[:scheduler_default_filters].join(',')) + end + end + + context 'configure filters with string' do + before :each do + params.merge!({ + :scheduler_default_filters => 'AvailabilityZoneFilter,CapacityFilter,CapabilitiesFilter' + }) + end + + it 'contains overrided values' do + is_expected.to contain_cinder_config('DEFAULT/scheduler_default_filters').with_value(p[:scheduler_default_filters]) + end + end end + context 'on Debian platforms' do + let :facts do + @default_facts.merge({ :osfamily => 'Debian' }) + end + + it_configures 'cinder scheduler filter' + end + + context 'on RedHat platforms' do + let :facts do + @default_facts.merge({ :osfamily => 'RedHat' }) + end + + it_configures 'cinder scheduler filter' + end + end