Add support for independent octavia-dashboard configurations
This change introduces the new horizon::dashboards::octavia class, which allows users to manage the independent configuration file for octavia dashboard (_1499_load_balancer_settings.py). Change-Id: I54f7fb778bc2487bf977e23e193773d627d91dd9
This commit is contained in:
parent
382877dd4c
commit
c29622ee45
68
manifests/dashboards/octavia.pp
Normal file
68
manifests/dashboards/octavia.pp
Normal file
@ -0,0 +1,68 @@
|
||||
#
|
||||
# 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::octavia
|
||||
#
|
||||
# Manage parameters of octavia-dashboard
|
||||
#
|
||||
# === Parameters:
|
||||
#
|
||||
# [*policy_file*]
|
||||
# (optional) Local copy of service policy files.
|
||||
# Defaults to 'octavia_policy.yaml'
|
||||
#
|
||||
class horizon::dashboards::octavia(
|
||||
$policy_file = 'octavia_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::octavia class')
|
||||
}
|
||||
|
||||
$log_handlers = $::horizon::log_handlers
|
||||
$log_level = $::horizon::log_level
|
||||
$policy_files = $::horizon::policy_files
|
||||
|
||||
if $policy_files and $policy_files['load-balancer'] {
|
||||
$policy_file_real = $policy_files['load-balancer']
|
||||
} else {
|
||||
$policy_file_real = $policy_file
|
||||
}
|
||||
|
||||
$config_file = "${::horizon::params::conf_d_dir}/_1499_load_balancer_settings.py"
|
||||
|
||||
package { 'octavia-dashboard':
|
||||
ensure => $::horizon::package_ensure,
|
||||
name => $::horizon::params::octavia_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 { '_1499_load_balancer_settings.py':
|
||||
target => $config_file,
|
||||
content => template('horizon/_1499_load_balancer_settings.py.erb'),
|
||||
order => '50',
|
||||
}
|
||||
}
|
@ -10,45 +10,47 @@ class horizon::params {
|
||||
|
||||
case $::osfamily {
|
||||
'RedHat': {
|
||||
$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'
|
||||
$root_url = '/dashboard'
|
||||
$static_path = '/usr/share'
|
||||
$apache_user = 'apache'
|
||||
$apache_group = 'apache'
|
||||
$wsgi_user = 'apache'
|
||||
$wsgi_group = 'apache'
|
||||
$memcache_package = 'python3-memcached'
|
||||
$heat_dashboard_package_name = 'openstack-heat-ui'
|
||||
$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'
|
||||
$root_url = '/dashboard'
|
||||
$static_path = '/usr/share'
|
||||
$apache_user = 'apache'
|
||||
$apache_group = 'apache'
|
||||
$wsgi_user = 'apache'
|
||||
$wsgi_group = 'apache'
|
||||
$memcache_package = 'python3-memcached'
|
||||
$heat_dashboard_package_name = 'openstack-heat-ui'
|
||||
$octavia_dashboard_package_name = 'openstack-octavia-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'
|
||||
$static_path = '/var/lib'
|
||||
$apache_user = 'www-data'
|
||||
$apache_group = 'www-data'
|
||||
$wsgi_user = 'horizon'
|
||||
$wsgi_group = 'horizon'
|
||||
$memcache_package = 'python3-memcache'
|
||||
$heat_dashboard_package_name = 'python3-heat-dashboard'
|
||||
$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'
|
||||
$static_path = '/var/lib'
|
||||
$apache_user = 'www-data'
|
||||
$apache_group = 'www-data'
|
||||
$wsgi_user = 'horizon'
|
||||
$wsgi_group = 'horizon'
|
||||
$memcache_package = 'python3-memcache'
|
||||
$heat_dashboard_package_name = 'python3-heat-dashboard'
|
||||
$octavia_dashboard_package_name = 'python3-octavia-dashboard'
|
||||
case $::os_package_type {
|
||||
'debian': {
|
||||
$package_name = 'openstack-dashboard-apache'
|
||||
$httpd_config_file = '/etc/apache2/sites-available/openstack-dashboard-alias-only.conf'
|
||||
$package_name = 'openstack-dashboard-apache'
|
||||
$httpd_config_file = '/etc/apache2/sites-available/openstack-dashboard-alias-only.conf'
|
||||
}
|
||||
default: {
|
||||
$package_name = 'openstack-dashboard'
|
||||
$httpd_config_file = '/etc/apache2/conf-available/openstack-dashboard.conf'
|
||||
$package_name = 'openstack-dashboard'
|
||||
$httpd_config_file = '/etc/apache2/conf-available/openstack-dashboard.conf'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
The new ``horizon::dashboards::octavia`` class has been added. This class
|
||||
can be used to manage parameters for octavia-dashboard.
|
63
spec/classes/horizon_dashboards_octavia_spec.rb
Normal file
63
spec/classes/horizon_dashboards_octavia_spec.rb
Normal file
@ -0,0 +1,63 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'horizon::dashboards::octavia' do
|
||||
|
||||
let :params do
|
||||
{}
|
||||
end
|
||||
|
||||
shared_examples_for 'horizon::dashboards::octavia' do
|
||||
|
||||
context 'with default parameters' do
|
||||
let(:pre_condition) do
|
||||
<<-eos
|
||||
class { 'horizon':
|
||||
secret_key => 'elj1IWiLoWHgcyYxFVLj7cM5rGOOxWl0',
|
||||
}
|
||||
eos
|
||||
end
|
||||
|
||||
it 'installs octavia-dashboard package' do
|
||||
is_expected.to contain_package('octavia-dashboard').with(
|
||||
:ensure => 'present',
|
||||
:name => platform_params[:octavia_dashboard_package_name],
|
||||
:tag => ['openstack', 'horizon-package']
|
||||
)
|
||||
end
|
||||
|
||||
it 'generates _1499_load_balancer_settings.py' do
|
||||
verify_concat_fragment_contents(catalogue, '_1499_load_balancer_settings.py', [
|
||||
"settings.POLICY_FILES.update({",
|
||||
" 'load-balancer': 'octavia_policy.yaml',",
|
||||
"})"
|
||||
])
|
||||
end
|
||||
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'
|
||||
{ :octavia_dashboard_package_name => 'python3-octavia-dashboard' }
|
||||
when 'RedHat'
|
||||
{ :octavia_dashboard_package_name => 'openstack-octavia-ui' }
|
||||
end
|
||||
end
|
||||
|
||||
it_behaves_like 'horizon::dashboards::octavia'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
40
templates/_1499_load_balancer_settings.py.erb
Normal file
40
templates/_1499_load_balancer_settings.py.erb
Normal file
@ -0,0 +1,40 @@
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
settings.POLICY_FILES.update({
|
||||
'load-balancer': '<%= @policy_file_real %>',
|
||||
})
|
||||
|
||||
settings.DEFAULT_POLICY_FILES.update({
|
||||
'load-balancer': 'default_policies/octavia.yaml',
|
||||
})
|
||||
|
||||
# Sample
|
||||
# settings.LOGGING['loggers'].update({
|
||||
# 'openstack': {
|
||||
# 'handlers': ['console'],
|
||||
# 'level': 'DEBUG',
|
||||
# 'propagate': False,
|
||||
# }
|
||||
# 'barbicanclient': {
|
||||
# 'handlers': ['console'],
|
||||
# 'level': 'DEBUG',
|
||||
# 'propagate': False,
|
||||
# }
|
||||
# })
|
||||
settings.LOGGING['loggers'].update({
|
||||
'openstack': {
|
||||
# 'handlers': ['console'],
|
||||
'handlers': ['<%= @log_handlers.join("', '") %>']
|
||||
# level': 'DEBUG',
|
||||
'level': '<%= @log_level %>',
|
||||
'propagate': False,
|
||||
}
|
||||
'barbicanclient': {
|
||||
# 'handlers': ['console'],
|
||||
'handlers': ['<%= @log_handlers.join("', '") %>']
|
||||
# level': 'DEBUG',
|
||||
'level': '<%= @log_level %>',
|
||||
'propagate': False,
|
||||
}
|
||||
})
|
Loading…
x
Reference in New Issue
Block a user