diff --git a/manifests/backend/nfs.pp b/manifests/backend/nfs.pp index 6716a4c8..32808e97 100644 --- a/manifests/backend/nfs.pp +++ b/manifests/backend/nfs.pp @@ -2,6 +2,9 @@ # # === Parameters # +# [*nfs_servers*] +# (Required) List of available NFS shares. +# # [*volume_backend_name*] # (optional) Allows for the volume_backend_name to be separate of $name. # Defaults to: $name @@ -12,10 +15,6 @@ # is used as the default for all backends. # Defaults to $facts['os_service_default']. # -# [*nfs_servers*] -# (Required) Description -# Defaults to '[]' -# # [*nfs_mount_attempts*] # (optional) The number of attempts to mount nfs shares before raising an # error. At least one attempt will be made to mount an nfs share, regardless @@ -90,9 +89,9 @@ # { 'nfs_backend/param1' => { 'value' => value1 } } # define cinder::backend::nfs ( + Array[String[1], 1] $nfs_servers, $volume_backend_name = $name, $backend_availability_zone = $facts['os_service_default'], - Array[String] $nfs_servers = [], $nfs_mount_attempts = $facts['os_service_default'], $nfs_mount_options = $facts['os_service_default'], $nfs_sparsed_volumes = $facts['os_service_default'], diff --git a/spec/defines/cinder_backend_nfs_spec.rb b/spec/defines/cinder_backend_nfs_spec.rb index 14cf6bd8..84446c67 100644 --- a/spec/defines/cinder_backend_nfs_spec.rb +++ b/spec/defines/cinder_backend_nfs_spec.rb @@ -5,24 +5,54 @@ describe 'cinder::backend::nfs' do let :params do { - :backend_availability_zone => 'my_zone', - :nfs_servers => ['10.10.10.10:/shares', '10.10.10.10:/shares2'], - :nfs_mount_attempts => '4', - :nfs_mount_options => 'vers=3', - :nfs_shares_config => '/etc/cinder/other_shares.conf', - :nfs_sparsed_volumes => true, - :nfs_mount_point_base => '/cinder_mount_point', - :nfs_used_ratio => '0.7', - :nfs_oversub_ratio => '0.9', - :nas_secure_file_operations => 'auto', - :nas_secure_file_permissions => 'false', - :nfs_snapshot_support => 'true', - :nfs_qcow2_volumes => 'true', + :nfs_servers => ['10.10.10.10:/shares', '10.10.10.10:/shares2'], } end shared_examples 'cinder::backend::nfs' do - context 'nfs volume driver' do + context 'with defaults' do + it { + is_expected.to contain_cinder_config('hippo/volume_backend_name').with_value('hippo') + is_expected.to contain_cinder_config('hippo/backend_availability_zone').with_value('') + is_expected.to contain_cinder_config('hippo/volume_driver').with_value('cinder.volume.drivers.nfs.NfsDriver') + is_expected.to contain_cinder_config('hippo/nfs_shares_config').with_value('/etc/cinder/shares.conf') + is_expected.to contain_cinder_config('hippo/nfs_mount_attempts').with_value('') + is_expected.to contain_cinder_config('hippo/nfs_mount_options').with_value('') + is_expected.to contain_cinder_config('hippo/nfs_sparsed_volumes').with_value('') + is_expected.to contain_cinder_config('hippo/nfs_mount_point_base').with_value('') + is_expected.to contain_cinder_config('hippo/nfs_used_ratio').with_value('') + is_expected.to contain_cinder_config('hippo/nfs_oversub_ratio').with_value('') + is_expected.to contain_cinder_config('hippo/nas_secure_file_operations').with_value('') + is_expected.to contain_cinder_config('hippo/nas_secure_file_permissions').with_value('') + is_expected.to contain_cinder_config('hippo/nfs_snapshot_support').with_value('') + is_expected.to contain_cinder_config('hippo/nfs_qcow2_volumes').with_value('') + } + + it { is_expected.to contain_file('/etc/cinder/shares.conf').with( + :content => "10.10.10.10:/shares\n10.10.10.10:/shares2", + :require => 'Anchor[cinder::install::end]', + :notify => 'Anchor[cinder::service::begin]' + )} + end + + context 'with parameters' do + before :each do + params.merge!({ + :backend_availability_zone => 'my_zone', + :nfs_mount_attempts => '4', + :nfs_mount_options => 'vers=3', + :nfs_shares_config => '/etc/cinder/other_shares.conf', + :nfs_sparsed_volumes => true, + :nfs_mount_point_base => '/cinder_mount_point', + :nfs_used_ratio => '0.7', + :nfs_oversub_ratio => '0.9', + :nas_secure_file_operations => 'auto', + :nas_secure_file_permissions => 'false', + :nfs_snapshot_support => 'true', + :nfs_qcow2_volumes => 'true', + }) + end + it { is_expected.to contain_cinder_config('hippo/volume_backend_name').with_value('hippo') is_expected.to contain_cinder_config('hippo/backend_availability_zone').with_value('my_zone')