Add support for independent heat-dashboard configurations
Currently horizon supports per-dashboard configurations in /etc/openstack-dashboard/local_settings.d. Each dashboard plugin provides a specific file to define its parameters, and any parameters used in dashboard plugins have been removed from the base local_settings(.py) in horizon repo. To follow how each plugin is supposed to have its configurations managed, this change introduces an independent file for heat-dashboard. Support for the other dashboards like manila-ui, octavia-ui, and etc will be added later. Conflicts: manifests/init.pp manifests/params.pp spec/classes/horizon_init_spec.rb templates/local_settings.py.erb Backport note: To minimize effect of this backport, the following change was made. - The enable_user_pass parameter is not deprecated by this patch. - Users can set the enable_user_pass parameter to undef to remove OPENSTACK_HEAT_STACK from local_settings. - heatclient logging setting is left in local_settings, because consistent configuration is added. Backport note to Ussuri: - The log_handlers option is not available in Ussuri so it is replaced by the old log_handler option. - This change includes what was fixed by follow-up commit[1] in Victoria. [1]23ebe3bf02
Backport note to Train: - Replaced relative names used to include classes because the old lint rules in train enforces usage of absolute names. Change-Id: I5999c2eaf8d7788d3c0d76e69a56a0b10058dfe9 (cherry picked from commit382877dd4c
) (cherry picked from commit655e0df25e
) (cherry picked from commit80acdcca4d
) (cherry picked from commitbf021098cc
)
This commit is contained in:
parent
cac4987cc1
commit
d260a8d1c8
|
@ -0,0 +1,78 @@
|
|||
#
|
||||
# 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.json'
|
||||
#
|
||||
class horizon::dashboards::heat(
|
||||
$enable_user_pass = true,
|
||||
$policy_file = 'heat_policy.json',
|
||||
) {
|
||||
|
||||
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_handler = $::horizon::log_handler
|
||||
$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
|
||||
}
|
||||
|
||||
if $::horizon::enable_user_pass != undef {
|
||||
warning('The horizon::dashboards::heat::enable_user_pass parameter is ignored \
|
||||
because horizon::enable_user_pass parameter is set.')
|
||||
}
|
||||
$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',
|
||||
}
|
||||
}
|
|
@ -445,6 +445,7 @@
|
|||
#
|
||||
# [*enable_user_pass*]
|
||||
# (optional) Enable the password field while launching a Heat stack.
|
||||
# Set this parameter to undef if horizon::dashboards::heat is used.
|
||||
# Defaults to true
|
||||
#
|
||||
# [*customization_module*]
|
||||
|
@ -653,6 +654,7 @@ class horizon(
|
|||
owner => $::horizon::params::wsgi_user,
|
||||
group => $::horizon::params::wsgi_group,
|
||||
require => Anchor['horizon::config::begin'],
|
||||
tag => ['django-config'],
|
||||
}
|
||||
|
||||
concat::fragment { 'local_settings.py':
|
||||
|
@ -661,6 +663,14 @@ class horizon(
|
|||
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':
|
||||
command => "${::horizon::params::manage_py} collectstatic --noinput --clear",
|
||||
refreshonly => true,
|
||||
|
@ -674,9 +684,9 @@ class horizon(
|
|||
}
|
||||
|
||||
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' {
|
||||
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']
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@ class horizon::params {
|
|||
$http_service = 'httpd'
|
||||
$http_modwsgi = 'mod_wsgi'
|
||||
$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'
|
||||
$httpd_config_file = '/etc/httpd/conf.d/openstack-dashboard.conf'
|
||||
$httpd_listen_config_file = '/etc/httpd/conf/httpd.conf'
|
||||
|
@ -24,9 +26,12 @@ class horizon::params {
|
|||
$wsgi_user = 'apache'
|
||||
$wsgi_group = 'apache'
|
||||
$memcache_package = "python${pyvers}-memcached"
|
||||
$heat_dashboard_package_name = 'openstack-heat-ui'
|
||||
}
|
||||
'Debian': {
|
||||
$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'
|
||||
$httpd_listen_config_file = '/etc/apache2/ports.conf'
|
||||
$root_url = '/horizon'
|
||||
|
@ -36,6 +41,7 @@ class horizon::params {
|
|||
$wsgi_user = 'horizon'
|
||||
$wsgi_group = 'horizon'
|
||||
$memcache_package = "python${pyvers}-memcache"
|
||||
$heat_dashboard_package_name = "python${pyvers}-heat-dashboard"
|
||||
case $::os_package_type {
|
||||
'debian': {
|
||||
$package_name = 'openstack-dashboard-apache'
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
features:
|
||||
- |
|
||||
The new ``horizon::dashboards::heat`` class has been added. This class can
|
||||
be used to manage parameters for heat-dashboard.
|
|
@ -0,0 +1,94 @@
|
|||
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.json',",
|
||||
"})"
|
||||
])
|
||||
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':
|
||||
enable_user_pass => false,
|
||||
secret_key => 'elj1IWiLoWHgcyYxFVLj7cM5rGOOxWl0',
|
||||
}
|
||||
eos
|
||||
end
|
||||
|
||||
before do
|
||||
# NOTE(tkajinam): We should test the enable_user_pass parameter in this
|
||||
# class but setting undef in the base horizon class
|
||||
# doesn't work for some reason...
|
||||
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
|
|
@ -218,6 +218,7 @@ describe 'horizon' do
|
|||
])
|
||||
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_compress]') }
|
||||
|
||||
|
@ -754,6 +755,7 @@ describe 'horizon' do
|
|||
when 'Debian'
|
||||
if facts[:os_package_type] == 'debian'
|
||||
{ :config_file => '/etc/openstack-dashboard/local_settings.py',
|
||||
:conf_d_dir => '/etc/openstack-dashboard/local_settings.d',
|
||||
:package_name => 'openstack-dashboard-apache',
|
||||
:root_url => '/horizon',
|
||||
:root_path => '/var/lib/openstack-dashboard',
|
||||
|
@ -761,6 +763,7 @@ describe 'horizon' do
|
|||
}
|
||||
else
|
||||
{ :config_file => '/etc/openstack-dashboard/local_settings.py',
|
||||
:conf_d_dir => '/etc/openstack-dashboard/local_settings.d',
|
||||
:package_name => 'openstack-dashboard',
|
||||
:root_url => '/horizon',
|
||||
:root_path => '/var/lib/openstack-dashboard',
|
||||
|
@ -770,6 +773,7 @@ describe 'horizon' do
|
|||
when 'RedHat'
|
||||
if facts[:operatingsystem] == 'Fedora'
|
||||
{ :config_file => '/etc/openstack-dashboard/local_settings',
|
||||
:conf_d_dir => '/etc/openstack-dashboard/local_settings.d',
|
||||
:package_name => 'openstack-dashboard',
|
||||
:root_url => '/dashboard',
|
||||
:root_path => '/usr/share/openstack-dashboard',
|
||||
|
@ -778,6 +782,7 @@ describe 'horizon' do
|
|||
else
|
||||
if facts[:operatingsystemmajrelease] > '7'
|
||||
{ :config_file => '/etc/openstack-dashboard/local_settings',
|
||||
:conf_d_dir => '/etc/openstack-dashboard/local_settings.d',
|
||||
:package_name => 'openstack-dashboard',
|
||||
:root_url => '/dashboard',
|
||||
:root_path => '/usr/share/openstack-dashboard',
|
||||
|
@ -785,6 +790,7 @@ describe 'horizon' do
|
|||
}
|
||||
else
|
||||
{ :config_file => '/etc/openstack-dashboard/local_settings',
|
||||
:conf_d_dir => '/etc/openstack-dashboard/local_settings.d',
|
||||
:package_name => 'openstack-dashboard',
|
||||
:root_url => '/dashboard',
|
||||
:root_path => '/usr/share/openstack-dashboard',
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
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 %>',
|
||||
})
|
||||
|
||||
# Sample
|
||||
# settings.LOGGING['loggers'].update({
|
||||
# 'heatclient': {
|
||||
# 'handlers': ['console'],
|
||||
# 'level': 'DEBUG',
|
||||
# 'propagate': False,
|
||||
# }
|
||||
# })
|
||||
settings.LOGGING['loggers'].update({
|
||||
'heatclient': {
|
||||
# 'handlers': ['console'],
|
||||
'handlers': ['<%= @log_handler %>'],
|
||||
# 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
|
|
@ -489,6 +489,7 @@ OPENSTACK_NEUTRON_NETWORK = {
|
|||
}
|
||||
<%-end-%>
|
||||
|
||||
<%- if ! (@enable_user_pass.nil?) -%>
|
||||
# The OPENSTACK_HEAT_STACK settings can be used to disable password
|
||||
# field required while launching the stack.
|
||||
#OPENSTACK_HEAT_STACK = {
|
||||
|
@ -502,6 +503,7 @@ OPENSTACK_HEAT_STACK = {
|
|||
<%- end -%>
|
||||
}
|
||||
|
||||
<%- end -%>
|
||||
# The OPENSTACK_IMAGE_BACKEND settings can be used to customize features
|
||||
# in the OpenStack Dashboard related to the Image service, such as the list
|
||||
# of supported image formats.
|
||||
|
|
Loading…
Reference in New Issue