From c60cb1a3927839014005af8ffda0433081331146 Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Thu, 24 Aug 2017 10:40:46 -0400 Subject: [PATCH] Allow configuring 'CREATE_IMAGE_DEFAULTS' setting Horizon now has the option of selecting various defaults for the create image panel. This patch allows configuring those options. Change-Id: I01d9fc44d957394acc4243f3ee34e6e50eec0bdf --- manifests/init.pp | 5 +++++ spec/classes/horizon_init_spec.rb | 3 +++ templates/local_settings.py.erb | 15 ++++++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index ed8d2864..f47b30b5 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -285,6 +285,10 @@ # Valid values are 'legacy' and 'angular' # Defaults to 'legacy' # +# [*create_image_defaults*] +# (optional) A dictionary of default settings for create image modal. +# Defaults to undef - will not add entry to local settings. +# # [*password_retrieve*] # (optional) Enables the use of 'Retrieve Password' in the Horizon Web UI. # Defaults to false @@ -456,6 +460,7 @@ class horizon( $default_theme = false, $password_autocomplete = 'off', $images_panel = 'legacy', + $create_image_defaults = undef, $password_retrieve = false, $disable_password_reveal = false, $enforce_password_check = false, diff --git a/spec/classes/horizon_init_spec.rb b/spec/classes/horizon_init_spec.rb index 52db0f6a..59b49e08 100644 --- a/spec/classes/horizon_init_spec.rb +++ b/spec/classes/horizon_init_spec.rb @@ -130,6 +130,7 @@ describe 'horizon' do :default_theme => 'default', :password_autocomplete => 'on', :images_panel => 'angular', + :create_image_defaults => {'image_visibility' => 'private'}, :password_retrieve => true, :enable_secure_proxy_ssl_header => true, }) @@ -178,6 +179,8 @@ describe 'horizon' do " 'supported_provider_types': ['flat', 'vxlan'],", " 'supported_vnic_types': ['*'],", 'OPENSTACK_ENABLE_PASSWORD_RETRIEVE = True', + 'CREATE_IMAGE_DEFAULTS = {', + " 'image_visibility': 'private',", 'OPENSTACK_ENDPOINT_TYPE = "internalURL"', 'SECONDARY_ENDPOINT_TYPE = "ANY-VALUE"', 'API_RESULT_LIMIT = 4682', diff --git a/templates/local_settings.py.erb b/templates/local_settings.py.erb index 1a223e42..7ec10af8 100644 --- a/templates/local_settings.py.erb +++ b/templates/local_settings.py.erb @@ -508,6 +508,18 @@ OPENSTACK_IMAGE_BACKEND = { # table. #IMAGE_RESERVED_CUSTOM_PROPERTIES = [] +# A dictionary of default settings for create image modal. +#CREATE_IMAGE_DEFAULTS = { +# 'image_visibility': "public", +#} +<% if @create_image_defaults %> +CREATE_IMAGE_DEFAULTS = { +<%- @create_image_defaults.sort.each do |opt_name,opt_val| -%> + '<%= opt_name %>': '<%= opt_val %>', +<%- end -%> +} +<% 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 # external to the OpenStack environment. The default is 'publicURL'. @@ -985,7 +997,8 @@ OVERVIEW_DAYS_RANGE = <%= @overview_days_range %> # See: https://wiki.openstack.org/wiki/Horizon/RESTAPI REST_API_REQUIRED_SETTINGS = ['OPENSTACK_HYPERVISOR_FEATURES', 'LAUNCH_INSTANCE_DEFAULTS', - 'OPENSTACK_IMAGE_FORMATS'] + 'OPENSTACK_IMAGE_FORMATS', + 'CREATE_IMAGE_DEFAULTS'] # Additional settings can be made available to the client side for # extensibility by specifying them in REST_API_ADDITIONAL_SETTINGS