Browse Source

Merge "Add support for independent heat-dashboard configurations"

master
Zuul 2 weeks ago
committed by Gerrit Code Review
parent
commit
a59473d369
8 changed files with 243 additions and 43 deletions
  1. +74
    -0
      manifests/dashboards/heat.pp
  2. +21
    -7
      manifests/init.pp
  3. +6
    -0
      manifests/params.pp
  4. +10
    -0
      releasenotes/notes/heat-dashboard-c34cea1d256164cd.yaml
  5. +90
    -0
      spec/classes/horizon_dashboards_heat_spec.rb
  6. +4
    -16
      spec/classes/horizon_init_spec.rb
  7. +38
    -0
      templates/_1699_orchestration_settings.py.erb
  8. +0
    -20
      templates/local_settings.py.erb

+ 74
- 0
manifests/dashboards/heat.pp 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',
}
}

+ 21
- 7
manifests/init.pp View File

@ -484,10 +484,6 @@
# [*password_validator_help*]
# (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*]
# (optional) Horizon has a global override mechanism available to perform
# customizations. This adds a key - customization_module - to HORIZON_CONFIG
@ -515,6 +511,10 @@
# [*horizon_ca*]
# (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
#
# class { 'horizon':
@ -616,17 +616,22 @@ class horizon(
$websso_default_redirect_logout = undef,
$password_validator = undef,
$password_validator_help = undef,
$enable_user_pass = true,
$customization_module = undef,
$horizon_upload_mode = undef,
# DEPRECATED PARAMETERS
$horizon_cert = undef,
$horizon_key = undef,
$horizon_ca = undef,
$enable_user_pass = undef,
) inherits horizon::params {
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 {
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,
group => $::horizon::params::wsgi_group,
require => Anchor['horizon::config::begin'],
tag => ['django-config'],
}
concat::fragment { 'local_settings.py':
@ -722,6 +728,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,
@ -735,9 +749,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']
}
}


+ 6
- 0
manifests/params.pp View File

@ -13,6 +13,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'
@ -23,9 +25,12 @@ class horizon::params {
$wsgi_user = 'apache'
$wsgi_group = 'apache'
$memcache_package = 'python3-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'
@ -35,6 +40,7 @@ class horizon::params {
$wsgi_user = 'horizon'
$wsgi_group = 'horizon'
$memcache_package = 'python3-memcache'
$heat_dashboard_package_name = 'python3-heat-dashboard'
case $::os_package_type {
'debian': {
$package_name = 'openstack-dashboard-apache'


+ 10
- 0
releasenotes/notes/heat-dashboard-c34cea1d256164cd.yaml 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.

+ 90
- 0
spec/classes/horizon_dashboards_heat_spec.rb 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

+ 4
- 16
spec/classes/horizon_init_spec.rb View File

@ -78,9 +78,6 @@ describe 'horizon' do
" 'handlers': ['file'],",
'COMPRESS_OFFLINE = True',
"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
@ -212,25 +209,13 @@ 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]') }
it { is_expected.to contain_file(params[:file_upload_temp_dir]) }
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
before do
params.merge!({
@ -767,6 +752,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',
@ -774,6 +760,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',
@ -782,6 +769,7 @@ describe 'horizon' do
end
when 'RedHat'
{ :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',


+ 38
- 0
templates/_1699_orchestration_settings.py.erb 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

+ 0
- 20
templates/local_settings.py.erb View File

@ -529,19 +529,6 @@ OPENSTACK_NEUTRON_NETWORK = {
}
<%-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
# in the OpenStack Dashboard related to the Image service, such as the list
# of supported image formats.
@ -835,13 +822,6 @@ LOGGING = {
'level': '<%= @log_level %>',
'propagate': False,
},
'heatclient': {
# 'handlers': ['console'],
'handlers': ['<%= @log_handlers.join("', '") %>'],
# 'level': 'DEBUG',
'level': '<%= @log_level %>',
'propagate': False,
},
'swiftclient': {
# 'handlers': ['console'],
'handlers': ['<%= @log_handlers.join("', '") %>'],


Loading…
Cancel
Save