Merge "Add support for independent heat-dashboard configurations"

This commit is contained in:
Zuul 2021-06-07 18:25:00 +00:00 committed by Gerrit Code Review
commit a59473d369
8 changed files with 243 additions and 43 deletions

View File

@ -0,0 +1,74 @@
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# == Class: horizon::dashboards::heat
#
# Manage parameters of heat-dashboard
#
# === Parameters:
#
# [*enable_user_pass*]
# (optional) Enable the password field while launching a Heat stack.
# Defaults to true
#
# [*policy_file*]
# (optional) Local copy of service policy files.
# Defaults to 'heat_policy.yaml'
#
class horizon::dashboards::heat(
$enable_user_pass = true,
$policy_file = 'heat_policy.yaml',
) {
include horizon::deps
include horizon::params
# The horizon class should be included so that some common parameters
# can be picked here.
if ! defined(Class[horizon]) {
fail('The horizon class should be included before the horizon::dashboards::heat class')
}
$log_handlers = $::horizon::log_handlers
$log_level = $::horizon::log_level
$policy_files = $::horizon::policy_files
if $policy_files and $policy_files['orchestration'] {
$policy_file_real = $policy_files['orchestration']
} else {
$policy_file_real = $policy_file
}
$enable_user_pass_real = pick($::horizon::enable_user_pass, $enable_user_pass)
$config_file = "${::horizon::params::conf_d_dir}/_1699_orchestration_settings.py"
package { 'heat-dashboard':
ensure => $::horizon::package_ensure,
name => $::horizon::params::heat_dashboard_package_name,
tag => ['openstack', 'horizon-package'],
}
concat { $config_file:
mode => '0640',
owner => $::horizon::params::wsgi_user,
group => $::horizon::params::wsgi_group,
require => File[$::horizon::params::conf_d_dir],
tag => ['django-config'],
}
concat::fragment { '_1699_orchestration_settings.py':
target => $config_file,
content => template('horizon/_1699_orchestration_settings.py.erb'),
order => '50',
}
}

View File

@ -484,10 +484,6 @@
# [*password_validator_help*] # [*password_validator_help*]
# (optional) Help text to display when password validation fails in horizon. # (optional) Help text to display when password validation fails in horizon.
# #
# [*enable_user_pass*]
# (optional) Enable the password field while launching a Heat stack.
# Defaults to true
#
# [*customization_module*] # [*customization_module*]
# (optional) Horizon has a global override mechanism available to perform # (optional) Horizon has a global override mechanism available to perform
# customizations. This adds a key - customization_module - to HORIZON_CONFIG # customizations. This adds a key - customization_module - to HORIZON_CONFIG
@ -515,6 +511,10 @@
# [*horizon_ca*] # [*horizon_ca*]
# (required with listen_ssl) CA certificate to use for SSL support. # (required with listen_ssl) CA certificate to use for SSL support.
# #
# [*enable_user_pass*]
# (optional) Enable the password field while launching a Heat stack.
# Defaults to undef
#
# === Examples # === Examples
# #
# class { 'horizon': # class { 'horizon':
@ -616,17 +616,22 @@ class horizon(
$websso_default_redirect_logout = undef, $websso_default_redirect_logout = undef,
$password_validator = undef, $password_validator = undef,
$password_validator_help = undef, $password_validator_help = undef,
$enable_user_pass = true,
$customization_module = undef, $customization_module = undef,
$horizon_upload_mode = undef, $horizon_upload_mode = undef,
# DEPRECATED PARAMETERS # DEPRECATED PARAMETERS
$horizon_cert = undef, $horizon_cert = undef,
$horizon_key = undef, $horizon_key = undef,
$horizon_ca = undef, $horizon_ca = undef,
$enable_user_pass = undef,
) inherits horizon::params { ) inherits horizon::params {
include horizon::deps include horizon::deps
if $enable_user_pass != undef {
warning('The enable_user_pass parameter is deprecated. Use the horizon::dashboards::heat class')
include horizon::dashboards::heat
}
if $cache_server_url and $cache_server_ip { if $cache_server_url and $cache_server_ip {
fail('Only one of cache_server_url or cache_server_ip can be set.') fail('Only one of cache_server_url or cache_server_ip can be set.')
} }
@ -714,6 +719,7 @@ class horizon(
owner => $::horizon::params::wsgi_user, owner => $::horizon::params::wsgi_user,
group => $::horizon::params::wsgi_group, group => $::horizon::params::wsgi_group,
require => Anchor['horizon::config::begin'], require => Anchor['horizon::config::begin'],
tag => ['django-config'],
} }
concat::fragment { 'local_settings.py': concat::fragment { 'local_settings.py':
@ -722,6 +728,14 @@ class horizon(
order => '50', order => '50',
} }
file { $::horizon::params::conf_d_dir:
ensure => 'directory',
mode => '0755',
owner => $::horizon::params::wsgi_user,
group => $::horizon::params::wsgi_group,
require => Anchor['horizon::config::begin'],
}
exec { 'refresh_horizon_django_cache': exec { 'refresh_horizon_django_cache':
command => "${::horizon::params::manage_py} collectstatic --noinput --clear", command => "${::horizon::params::manage_py} collectstatic --noinput --clear",
refreshonly => true, refreshonly => true,
@ -735,9 +749,9 @@ class horizon(
} }
if $compress_offline { if $compress_offline {
Concat[$::horizon::params::config_file] ~> Exec['refresh_horizon_django_compress'] Concat<| tag == 'django-config' |> ~> Exec['refresh_horizon_django_compress']
if $::os_package_type == 'rpm' { if $::os_package_type == 'rpm' {
Concat[$::horizon::params::config_file] ~> Exec['refresh_horizon_django_cache'] -> Exec['refresh_horizon_django_compress'] Concat<| tag == 'django-config' |> ~> Exec['refresh_horizon_django_cache'] -> Exec['refresh_horizon_django_compress']
} }
} }

View File

@ -13,6 +13,8 @@ class horizon::params {
$http_service = 'httpd' $http_service = 'httpd'
$http_modwsgi = 'mod_wsgi' $http_modwsgi = 'mod_wsgi'
$package_name = 'openstack-dashboard' $package_name = 'openstack-dashboard'
$config_dir = '/etc/openstack-dashboard'
$conf_d_dir = '/etc/openstack-dashboard/local_settings.d'
$config_file = '/etc/openstack-dashboard/local_settings' $config_file = '/etc/openstack-dashboard/local_settings'
$httpd_config_file = '/etc/httpd/conf.d/openstack-dashboard.conf' $httpd_config_file = '/etc/httpd/conf.d/openstack-dashboard.conf'
$httpd_listen_config_file = '/etc/httpd/conf/httpd.conf' $httpd_listen_config_file = '/etc/httpd/conf/httpd.conf'
@ -23,9 +25,12 @@ class horizon::params {
$wsgi_user = 'apache' $wsgi_user = 'apache'
$wsgi_group = 'apache' $wsgi_group = 'apache'
$memcache_package = 'python3-memcached' $memcache_package = 'python3-memcached'
$heat_dashboard_package_name = 'openstack-heat-ui'
} }
'Debian': { 'Debian': {
$http_service = 'apache2' $http_service = 'apache2'
$config_dir = '/etc/openstack-dashboard'
$conf_d_dir = '/etc/openstack-dashboard/local_settings.d'
$config_file = '/etc/openstack-dashboard/local_settings.py' $config_file = '/etc/openstack-dashboard/local_settings.py'
$httpd_listen_config_file = '/etc/apache2/ports.conf' $httpd_listen_config_file = '/etc/apache2/ports.conf'
$root_url = '/horizon' $root_url = '/horizon'
@ -35,6 +40,7 @@ class horizon::params {
$wsgi_user = 'horizon' $wsgi_user = 'horizon'
$wsgi_group = 'horizon' $wsgi_group = 'horizon'
$memcache_package = 'python3-memcache' $memcache_package = 'python3-memcache'
$heat_dashboard_package_name = 'python3-heat-dashboard'
case $::os_package_type { case $::os_package_type {
'debian': { 'debian': {
$package_name = 'openstack-dashboard-apache' $package_name = 'openstack-dashboard-apache'

View File

@ -0,0 +1,10 @@
---
features:
- |
The new ``horizon::dashboards::heat`` class has been added. This class can
be used to manage parameters for heat-dashboard.
deprecations:
- |
The ``horizon::enable_user_pass`` parameter has been deprecated. Use
the ``horizon::dashboards::heat`` class instead.

View File

@ -0,0 +1,90 @@
require 'spec_helper'
describe 'horizon::dashboards::heat' do
let :params do
{}
end
shared_examples_for 'horizon::dashboards::heat' do
context 'with default parameters' do
let(:pre_condition) do
<<-eos
class { 'horizon':
secret_key => 'elj1IWiLoWHgcyYxFVLj7cM5rGOOxWl0',
}
eos
end
it 'installs heat-dashboard package' do
is_expected.to contain_package('heat-dashboard').with(
:ensure => 'present',
:name => platform_params[:heat_dashboard_package_name],
:tag => ['openstack', 'horizon-package']
)
end
it 'generates _1699_orchestration_settings.py' do
verify_concat_fragment_contents(catalogue, '_1699_orchestration_settings.py', [
"settings.POLICY_FILES.update({",
" 'orchestration': 'heat_policy.yaml',",
"})"
])
verify_concat_fragment_contents(catalogue, '_1699_orchestration_settings.py', [
"OPENSTACK_HEAT_STACK = {",
" 'enable_user_pass': True,",
"}",
])
end
end
context 'with enable_user_pass disabled' do
let(:pre_condition) do
<<-eos
class { 'horizon':
secret_key => 'elj1IWiLoWHgcyYxFVLj7cM5rGOOxWl0',
}
eos
end
before do
params.merge!({ :enable_user_pass => false })
end
it {
verify_concat_fragment_contents(catalogue, '_1699_orchestration_settings.py', [
"OPENSTACK_HEAT_STACK = {",
" 'enable_user_pass': False,",
"}",
])
}
end
context 'without the horizon class defined' do
it { should raise_error(Puppet::Error) }
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
let(:platform_params) do
case facts[:osfamily]
when 'Debian'
{ :heat_dashboard_package_name => 'python3-heat-dashboard' }
when 'RedHat'
{ :heat_dashboard_package_name => 'openstack-heat-ui' }
end
end
it_behaves_like 'horizon::dashboards::heat'
end
end
end

View File

@ -78,9 +78,6 @@ describe 'horizon' do
" 'handlers': ['file'],", " 'handlers': ['file'],",
'COMPRESS_OFFLINE = True', 'COMPRESS_OFFLINE = True',
"FILE_UPLOAD_TEMP_DIR = '/tmp'", "FILE_UPLOAD_TEMP_DIR = '/tmp'",
"OPENSTACK_HEAT_STACK = {",
" 'enable_user_pass': True",
"}",
]) ])
# From internals of verify_contents, get the contents to check for absence of a line # From internals of verify_contents, get the contents to check for absence of a line
@ -212,25 +209,13 @@ describe 'horizon' do
]) ])
end end
it { is_expected.to contain_file(platforms_params[:conf_d_dir]).with_ensure('directory') }
it { is_expected.not_to contain_file(platforms_params[:config_file]).that_notifies('Exec[refresh_horizon_django_cache]') } it { is_expected.not_to contain_file(platforms_params[:config_file]).that_notifies('Exec[refresh_horizon_django_cache]') }
it { is_expected.not_to contain_file(platforms_params[:config_file]).that_notifies('Exec[refresh_horizon_django_compress]') } it { is_expected.not_to contain_file(platforms_params[:config_file]).that_notifies('Exec[refresh_horizon_django_compress]') }
it { is_expected.to contain_file(params[:file_upload_temp_dir]) } it { is_expected.to contain_file(params[:file_upload_temp_dir]) }
end end
context 'with enable_user_pass disabled' do
before do
params.merge!({ :enable_user_pass => false })
end
it {
verify_concat_fragment_contents(catalogue, 'local_settings.py', [
"OPENSTACK_HEAT_STACK = {",
" 'enable_user_pass': False",
"}",
])
}
end
context 'with overridden parameters and cache_server_ip array' do context 'with overridden parameters and cache_server_ip array' do
before do before do
params.merge!({ params.merge!({
@ -767,6 +752,7 @@ describe 'horizon' do
when 'Debian' when 'Debian'
if facts[:os_package_type] == 'debian' if facts[:os_package_type] == 'debian'
{ :config_file => '/etc/openstack-dashboard/local_settings.py', { :config_file => '/etc/openstack-dashboard/local_settings.py',
:conf_d_dir => '/etc/openstack-dashboard/local_settings.d',
:package_name => 'openstack-dashboard-apache', :package_name => 'openstack-dashboard-apache',
:root_url => '/horizon', :root_url => '/horizon',
:root_path => '/var/lib/openstack-dashboard', :root_path => '/var/lib/openstack-dashboard',
@ -774,6 +760,7 @@ describe 'horizon' do
} }
else else
{ :config_file => '/etc/openstack-dashboard/local_settings.py', { :config_file => '/etc/openstack-dashboard/local_settings.py',
:conf_d_dir => '/etc/openstack-dashboard/local_settings.d',
:package_name => 'openstack-dashboard', :package_name => 'openstack-dashboard',
:root_url => '/horizon', :root_url => '/horizon',
:root_path => '/var/lib/openstack-dashboard', :root_path => '/var/lib/openstack-dashboard',
@ -782,6 +769,7 @@ describe 'horizon' do
end end
when 'RedHat' when 'RedHat'
{ :config_file => '/etc/openstack-dashboard/local_settings', { :config_file => '/etc/openstack-dashboard/local_settings',
:conf_d_dir => '/etc/openstack-dashboard/local_settings.d',
:package_name => 'openstack-dashboard', :package_name => 'openstack-dashboard',
:root_url => '/dashboard', :root_url => '/dashboard',
:root_path => '/usr/share/openstack-dashboard', :root_path => '/usr/share/openstack-dashboard',

View File

@ -0,0 +1,38 @@
from django.conf import settings
OPENSTACK_HEAT_STACK = {
'enable_user_pass': <%= @enable_user_pass_real.to_s.capitalize %>,
}
settings.POLICY_FILES.update({
'orchestration': '<%= @policy_file_real %>',
})
settings.DEFAULT_POLICY_FILES.update({
'orchestration': 'default_policies/heat.yaml',
})
# Sample
# settings.LOGGING['loggers'].update({
# 'heatclient': {
# 'handlers': ['console'],
# 'level': 'DEBUG',
# 'propagate': False,
# }
# })
settings.LOGGING['loggers'].update({
'heatclient': {
# 'handlers': ['console'],
'handlers': ['<%= @log_handlers.join("', '") %>']
# level': 'DEBUG',
'level': '<%= @log_level %>',
'propagate': False,
}
})
# Template Generator retrieve options API TIMEOUT
HEAT_TEMPLATE_GENERATOR_API_TIMEOUT = 60
# Template Generator retrieve options API PARALLEL LEVEL
HEAT_TEMPLATE_GENERATOR_API_PARALLEL = 2

View File

@ -529,19 +529,6 @@ OPENSTACK_NEUTRON_NETWORK = {
} }
<%-end-%> <%-end-%>
# The OPENSTACK_HEAT_STACK settings can be used to disable password
# field required while launching the stack.
#OPENSTACK_HEAT_STACK = {
# 'enable_user_pass': True,
#}
OPENSTACK_HEAT_STACK = {
<%- if @enable_user_pass -%>
'enable_user_pass': True
<%- else -%>
'enable_user_pass': False
<%- end -%>
}
# The OPENSTACK_IMAGE_BACKEND settings can be used to customize features # The OPENSTACK_IMAGE_BACKEND settings can be used to customize features
# in the OpenStack Dashboard related to the Image service, such as the list # in the OpenStack Dashboard related to the Image service, such as the list
# of supported image formats. # of supported image formats.
@ -835,13 +822,6 @@ LOGGING = {
'level': '<%= @log_level %>', 'level': '<%= @log_level %>',
'propagate': False, 'propagate': False,
}, },
'heatclient': {
# 'handlers': ['console'],
'handlers': ['<%= @log_handlers.join("', '") %>'],
# 'level': 'DEBUG',
'level': '<%= @log_level %>',
'propagate': False,
},
'swiftclient': { 'swiftclient': {
# 'handlers': ['console'], # 'handlers': ['console'],
'handlers': ['<%= @log_handlers.join("', '") %>'], 'handlers': ['<%= @log_handlers.join("', '") %>'],