Create dedicated class for ironic-ui

The package name of ironic-ui in Ubnutu/Debian does not follow
the general naming rule and the existing horizon::dashboard can't be
used.

Closes-Bug: #2033929
Change-Id: I7703550897c6b31f2b45ffce75f0ab2bae7a4157
This commit is contained in:
Takashi Kajinami 2023-11-13 23:13:18 +09:00
parent d94647073a
commit 1219aab898
6 changed files with 137 additions and 1 deletions

View File

@ -37,7 +37,7 @@ define horizon::dashboard (
$dashboard = downcase($name)
if $dashboard in ['designate', 'heat', 'octavia', 'manila'] {
if $dashboard in ['designate', 'ironic', 'heat', 'octavia', 'manila'] {
warning("Use the horizon::dashboard::${dashboard} class instead. \
The class allows more flexible customization of the ${dashboard} dashboard.")
}

View File

@ -0,0 +1,55 @@
#
# 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::ironic
#
# Manage parameters of ironic-dashboard
#
# === Parameters:
#
class horizon::dashboards::ironic() {
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::ironic class')
}
$log_handlers = $::horizon::log_handlers
$log_level = $::horizon::log_level
$config_file = "${::horizon::params::conf_d_dir}/_2299_baremetal_settings.py"
package { 'ironic-dashboard':
ensure => $::horizon::package_ensure,
name => $::horizon::params::ironic_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 { '_2299_baremetal_settings.py':
target => $config_file,
content => template('horizon/_2299_baremetal_settings.py.erb'),
order => '50',
}
}

View File

@ -25,6 +25,7 @@ class horizon::params {
$pymemcache_package = 'python3-pymemcache'
$designate_dashboard_package_name = 'openstack-designate-ui'
$heat_dashboard_package_name = 'openstack-heat-ui'
$ironic_dashboard_package_name = 'openstack-ironic-ui'
$manila_dashboard_package_name = 'openstack-manila-ui'
$octavia_dashboard_package_name = 'openstack-octavia-ui'
}
@ -42,6 +43,7 @@ class horizon::params {
$pymemcache_package = 'python3-pymemcache'
$designate_dashboard_package_name = 'python3-designate-dashboard'
$heat_dashboard_package_name = 'python3-heat-dashboard'
$ironic_dashboard_package_name = 'python3-ironic-ui'
$manila_dashboard_package_name = 'python3-manila-ui'
$octavia_dashboard_package_name = 'python3-octavia-dashboard'
case $facts['os']['name'] {

View File

@ -0,0 +1,4 @@
---
features:
- |
The new ``horizon::dashboards::ironic`` class has been added.

View File

@ -0,0 +1,55 @@
require 'spec_helper'
describe 'horizon::dashboards::ironic' do
let :params do
{}
end
shared_examples_for 'horizon::dashboards::ironic' do
context 'with default parameters' do
let(:pre_condition) do
<<-eos
class { 'horizon':
secret_key => 'elj1IWiLoWHgcyYxFVLj7cM5rGOOxWl0',
}
eos
end
it 'installs ironic-dashboard package' do
is_expected.to contain_package('ironic-dashboard').with(
:ensure => 'present',
:name => platform_params[:ironic_dashboard_package_name],
:tag => ['openstack', 'horizon-package']
)
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[:os]['family']
when 'Debian'
{ :ironic_dashboard_package_name => 'python3-ironic-ui' }
when 'RedHat'
{ :ironic_dashboard_package_name => 'openstack-ironic-ui' }
end
end
it_behaves_like 'horizon::dashboards::ironic'
end
end
end

View File

@ -0,0 +1,20 @@
from django.conf import settings
# Sample
# settings.LOGGING['loggers'].update({
# 'ironicclient': {
# 'handlers': ['console'],
# 'level': 'DEBUG',
# 'propagate': False,
# }
# })
settings.LOGGING['loggers'].update({
'ironicclient': {
# 'handlers': ['console'],
'handlers': ['<%= @log_handlers.join("', '") %>'],
# level': 'DEBUG',
'level': '<%= @log_level %>',
'propagate': False,
}
})