diff --git a/manifests/magnum.pp b/manifests/magnum.pp index 53c26795..9a999278 100644 --- a/manifests/magnum.pp +++ b/manifests/magnum.pp @@ -11,8 +11,9 @@ # Defaults to true # # [*image_source*] -# (Optional) If provision_image is true, the location of the image -# Defaults to 'https://fedorapeople.org/groups/magnum/fedora-atomic-latest.qcow2' +# (Optional) If provision_image is true, the location of the image. Required +# when provision_image is true +# Defaults to undef # # [*image_os_distro*] # (Optional) If provision_image is true, the os_distro propery of the image @@ -76,24 +77,24 @@ # Defaults to undef # class tempest::magnum ( - Boolean $provision_image = true, - String[1] $image_source = 'https://fedorapeople.org/groups/magnum/fedora-atomic-latest.qcow2', - String[1] $image_name = 'fedora-atomic-latest', - String[1] $image_os_distro = 'fedora-atomic', - Boolean $provision_flavors = true, - String[1] $flavor_id = 's1.magnum', - String[1] $master_flavor_id = 'm1.magnum', - Boolean $provision_keypair = false, - $keypair_name = $facts['os_service_default'], - $nic_id = $facts['os_service_default'], - $magnum_url = $facts['os_service_default'], - $copy_logs = $facts['os_service_default'], - $dns_nameserver = $facts['os_service_default'], - $catalog_type = $facts['os_service_default'], - Boolean $manage_tests_packages = true, + Boolean $provision_image = true, + Optional[String[1]] $image_source = undef, + String[1] $image_name = 'fedora-atomic-latest', + String[1] $image_os_distro = 'fedora-atomic', + Boolean $provision_flavors = true, + String[1] $flavor_id = 's1.magnum', + String[1] $master_flavor_id = 'm1.magnum', + Boolean $provision_keypair = false, + $keypair_name = $facts['os_service_default'], + $nic_id = $facts['os_service_default'], + $magnum_url = $facts['os_service_default'], + $copy_logs = $facts['os_service_default'], + $dns_nameserver = $facts['os_service_default'], + $catalog_type = $facts['os_service_default'], + Boolean $manage_tests_packages = true, # DEPRECATED PARAMETERS - $keypair_id = undef, - $tempest_config_file = undef, + $keypair_id = undef, + $tempest_config_file = undef, ) { include tempest::params include tempest @@ -108,6 +109,10 @@ Use the keypair_name parameter.") } if $provision_image { + if $image_source == undef { + fail('The image_source parameter must be set when provision_image is true') + } + $image_properties = { 'os_distro' => $image_os_distro } glance_image { $image_name: ensure => present, diff --git a/spec/classes/tempest_magnum_spec.rb b/spec/classes/tempest_magnum_spec.rb index 2b390198..3b7e96e1 100644 --- a/spec/classes/tempest_magnum_spec.rb +++ b/spec/classes/tempest_magnum_spec.rb @@ -10,16 +10,19 @@ describe 'tempest::magnum' do end let :params do - { :nic_id => 'b2e6021a-4956-4a1f-8329-790b9add05a9', } + { + :image_source => 'https://fedorapeople.org/groups/magnum/fedora-atomic-latest.qcow2', + :nic_id => 'b2e6021a-4956-4a1f-8329-790b9add05a9', + } end shared_examples 'tempest magnum' do context 'with default parameters' do it 'provisions resources and configures tempest for magnum' do is_expected.to contain_glance_image('fedora-atomic-latest').with( - :ensure => 'present', - :source => 'https://fedorapeople.org/groups/magnum/fedora-atomic-latest.qcow2', - :properties => '{"os_distro"=>"fedora-atomic"}' + :ensure => 'present', + :source => 'https://fedorapeople.org/groups/magnum/fedora-atomic-latest.qcow2', + :properties => {'os_distro' => 'fedora-atomic'} ) is_expected.to contain_nova_flavor('s1.magnum').with_ensure('present') is_expected.to contain_nova_flavor('m1.magnum').with_ensure('present') @@ -53,6 +56,10 @@ describe 'tempest::magnum' do }) end + it 'should not provision the image' do + is_expected.to_not contain_glance_image('coreos') + end + it 'configures tempest for magnum' do is_expected.to contain_tempest_config('magnum/image_id').with_value('coreos') is_expected.to contain_tempest_config('magnum/nic_id').with_value('b2e6021a-4956-4a1f-8329-790b9add05a9')