From b956399c2a80035e9d30c098e5a7b54e964ee744 Mon Sep 17 00:00:00 2001 From: Simon Murray Date: Mon, 19 Oct 2015 13:07:01 +0100 Subject: [PATCH] Allow Orchestration of Image Backend Adds a horizon::image_backend parameter that can be overriden to allow explicit definition of the supported image types etc. that are supported for the end user. The underlying python representation per setting is an array of tuples, however in puppet and hiera this is a hash as all options have an order of 2. A typical configuration may look like: horizon::image_backend: image_formats: '': 'Select image format' qcow2: 'QCOW2 - QEMU Emulator' raw: 'Raw' Change-Id: Ieb92240ed86f67b73911ec627312093e797fa15f --- manifests/init.pp | 7 +++++ spec/classes/horizon_init_spec.rb | 50 +++++++++++++++++++++++++++++++ templates/local_settings.py.erb | 11 +++++++ 3 files changed, 68 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index 1e7df3d2..ddfe1233 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -243,6 +243,12 @@ # All entities will be created in the default domain. # Default to undefined # +# [*image_backend*] +# (optional) Overrides the default image backend settings. This allows the list of supported +# image types etc. to be explicitly defined. +# Example: image_backend => { 'image_formats' => { '' => 'Select type', 'qcow2' => 'QCOW2' } } +# Default to empty hash +# # === Examples # # class { 'horizon': @@ -301,6 +307,7 @@ class horizon( $api_versions = {}, $keystone_multidomain_support = false, $keystone_default_domain = undef, + $image_backend = {}, # DEPRECATED PARAMETERS $can_set_mount_point = undef, $vhost_extra_params = undef, diff --git a/spec/classes/horizon_init_spec.rb b/spec/classes/horizon_init_spec.rb index 87e2b6bc..3b771c86 100644 --- a/spec/classes/horizon_init_spec.rb +++ b/spec/classes/horizon_init_spec.rb @@ -332,6 +332,56 @@ describe 'horizon' do it { is_expected.not_to contain_file(params[:file_upload_temp_dir]) } end + + context 'with image_backend' do + before do + params.merge!({ + :image_backend => { + 'image_formats' => { + '' => 'Select image format', + 'aki' => 'AKI - Amazon Kernel Image', + 'ami' => 'AMI - Amazon Machine Image', + 'ari' => 'ARI - Amazon Ramdisk Image', + 'iso' => 'ISO - Optical Disk Image', + 'qcow2' => 'QCOW2 - QEMU Emulator', + 'raw' => 'Raw', + 'vdi' => 'VDI', + 'vhi' => 'VHI', + 'vmdk' => 'VMDK', + }, + 'architectures' => { + '' => 'Select architecture', + 'x86_64' => 'x86-64', + 'aarch64' => 'ARMv8', + }, + }, + }) + end + + it 'configures OPENSTACK_IMAGE_BACKEND' do + verify_concat_fragment_contents(catalogue, 'local_settings.py', [ + "OPENSTACK_IMAGE_BACKEND = {", + " 'image_formats': [", + " ('', _('Select image format')),", + " ('aki', _('AKI - Amazon Kernel Image')),", + " ('ami', _('AMI - Amazon Machine Image')),", + " ('ari', _('ARI - Amazon Ramdisk Image')),", + " ('iso', _('ISO - Optical Disk Image')),", + " ('qcow2', _('QCOW2 - QEMU Emulator')),", + " ('raw', _('Raw')),", + " ('vdi', _('VDI')),", + " ('vhi', _('VHI')),", + " ('vmdk', _('VMDK')),", + " ], # image_formats", + " 'architectures': [", + " ('', _('Select architecture')),", + " ('x86_64', _('x86-64')),", + " ('aarch64', _('ARMv8')),", + " ], # architectures", + "} # OPENSTACK_IMAGE_BACKEND", + ]) + end + end end context 'on RedHat platforms' do diff --git a/templates/local_settings.py.erb b/templates/local_settings.py.erb index 87ab9683..a3a94286 100644 --- a/templates/local_settings.py.erb +++ b/templates/local_settings.py.erb @@ -256,6 +256,17 @@ OPENSTACK_NEUTRON_NETWORK = { # ('vmdk', _('VMDK')) # ] # } +<%- if !(@image_backend.empty?) -%> +OPENSTACK_IMAGE_BACKEND = { + <%- @image_backend.each do |opt_name,opt_val| -%> + '<%= opt_name %>': [ + <%- opt_val.each do |val,label| -%> + ('<%= val %>', _('<%= label %>')), + <%- end -%> + ], # <%= opt_name %> + <%- end -%> +} # OPENSTACK_IMAGE_BACKEND +<%- end -%> # OPENSTACK_ENDPOINT_TYPE specifies the endpoint type to use for the endpoints # in the Keystone service catalog. Use this setting when Horizon is running