From e14074e4fcff3c2499c7bda32846ec9602311b7f Mon Sep 17 00:00:00 2001 From: Eigil Obrestad Date: Mon, 25 Jun 2018 09:35:45 +0200 Subject: [PATCH] Add option for populating a dropdown list instead of the textfield for selecting domain at the horizon login Depends-On: https://review.openstack.org/579475 Change-Id: I67c4c8923ef4d6e4c3420e0a2b0d38ee3c6e2819 --- manifests/init.pp | 10 ++++++++++ ...in_choices-parameter-17bdbef68e57299c.yaml | 8 ++++++++ spec/classes/horizon_init_spec.rb | 20 +++++++++++++++++++ templates/local_settings.py.erb | 9 +++++++++ 4 files changed, 47 insertions(+) create mode 100644 releasenotes/notes/add-keystone_domain_choices-parameter-17bdbef68e57299c.yaml diff --git a/manifests/init.pp b/manifests/init.pp index 17d1c725..e42a30ba 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -256,6 +256,15 @@ # All entities will be created in the default domain. # Default to undef # +# [*keystone_domain_choices*] +# (optional) A hash of hashes to populate a dropdown for the domain field on +# the horizon login page. +# Example: [ +# {'name' => 'default', 'display' => 'The default domain'}, +# {'name' => 'LDAP', 'display' => 'The LDAP Catalog'}, +# ] +# Defaults to undef +# # [*image_backend*] # (optional) Overrides the default image backend settings. This allows the list of supported # image types etc. to be explicitly defined. @@ -472,6 +481,7 @@ class horizon( $api_versions = {'identity' => '3'}, $keystone_multidomain_support = false, $keystone_default_domain = undef, + $keystone_domain_choices = undef, $image_backend = {}, $overview_days_range = undef, $root_url = $::horizon::params::root_url, diff --git a/releasenotes/notes/add-keystone_domain_choices-parameter-17bdbef68e57299c.yaml b/releasenotes/notes/add-keystone_domain_choices-parameter-17bdbef68e57299c.yaml new file mode 100644 index 00000000..b32256f6 --- /dev/null +++ b/releasenotes/notes/add-keystone_domain_choices-parameter-17bdbef68e57299c.yaml @@ -0,0 +1,8 @@ +--- +features: + - | + Added the parameter "keystone_domain_choices" to the ::horizon class. + Setting this parameter would replace the domain text-field at the horizon + login-page with a drop-down menu. The parameter should be an array with + hashes, and the hashes should have two items each (name, display) containing + the domain name and a human-readable description of the domain respectively. diff --git a/spec/classes/horizon_init_spec.rb b/spec/classes/horizon_init_spec.rb index 1eda63a8..710dec36 100644 --- a/spec/classes/horizon_init_spec.rb +++ b/spec/classes/horizon_init_spec.rb @@ -645,6 +645,26 @@ describe 'horizon' do ]) end end + + context 'with keystone_domain_choices' do + before do + params.merge!({ + :keystone_domain_choices => [ + {'name' => 'default', 'display' => 'The default domain'}, + {'name' => 'LDAP', 'display' => 'The LDAP Catalog'}, + ], + }) + end + it 'sets OPENSTACK_KEYSTONE_DOMAIN_DROPDOWN in local_settings.py' do + verify_concat_fragment_contents(catalogue, 'local_settings.py', [ + 'OPENSTACK_KEYSTONE_DOMAIN_DROPDOWN = True', + 'OPENSTACK_KEYSTONE_DOMAIN_CHOICES = (', + " ('default', 'The default domain'),", + " ('LDAP', 'The LDAP Catalog'),", + ')', + ]) + end + end end shared_examples_for 'horizon on RedHat' do diff --git a/templates/local_settings.py.erb b/templates/local_settings.py.erb index 08d59da9..7f9c2c26 100644 --- a/templates/local_settings.py.erb +++ b/templates/local_settings.py.erb @@ -94,6 +94,15 @@ OPENSTACK_API_VERSIONS = { OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True <% end %> +<% if @keystone_domain_choices.kind_of?(Array) %> +OPENSTACK_KEYSTONE_DOMAIN_DROPDOWN = True +OPENSTACK_KEYSTONE_DOMAIN_CHOICES = ( +<% @keystone_domain_choices.each do |d| -%> + ('<%= d['name'] -%>', '<%= d['display'] -%>'), +<% end -%> +) +<% end -%> + # Overrides the default domain used when running on single-domain model # with Keystone V3. All entities will be created in the default domain. #OPENSTACK_KEYSTONE_DEFAULT_DOMAIN = 'Default'