From 1219aab8983b1ed44bd5ecab73f1190e44d48ade Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Mon, 13 Nov 2023 23:13:18 +0900 Subject: [PATCH] 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 --- manifests/dashboard.pp | 2 +- manifests/dashboards/ironic.pp | 55 +++++++++++++++++++ manifests/params.pp | 2 + .../ironic-dashboard-0dc5814a56121d5b.yaml | 4 ++ .../classes/horizon_dashboards_ironic_spec.rb | 55 +++++++++++++++++++ templates/_2299_baremetal_settings.py.erb | 20 +++++++ 6 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 manifests/dashboards/ironic.pp create mode 100644 releasenotes/notes/ironic-dashboard-0dc5814a56121d5b.yaml create mode 100644 spec/classes/horizon_dashboards_ironic_spec.rb create mode 100644 templates/_2299_baremetal_settings.py.erb diff --git a/manifests/dashboard.pp b/manifests/dashboard.pp index 87d42d15..2ae4658c 100644 --- a/manifests/dashboard.pp +++ b/manifests/dashboard.pp @@ -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.") } diff --git a/manifests/dashboards/ironic.pp b/manifests/dashboards/ironic.pp new file mode 100644 index 00000000..7361a57e --- /dev/null +++ b/manifests/dashboards/ironic.pp @@ -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', + } +} diff --git a/manifests/params.pp b/manifests/params.pp index dad54515..50f812e5 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -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'] { diff --git a/releasenotes/notes/ironic-dashboard-0dc5814a56121d5b.yaml b/releasenotes/notes/ironic-dashboard-0dc5814a56121d5b.yaml new file mode 100644 index 00000000..a83182e7 --- /dev/null +++ b/releasenotes/notes/ironic-dashboard-0dc5814a56121d5b.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + The new ``horizon::dashboards::ironic`` class has been added. diff --git a/spec/classes/horizon_dashboards_ironic_spec.rb b/spec/classes/horizon_dashboards_ironic_spec.rb new file mode 100644 index 00000000..76c8c209 --- /dev/null +++ b/spec/classes/horizon_dashboards_ironic_spec.rb @@ -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 diff --git a/templates/_2299_baremetal_settings.py.erb b/templates/_2299_baremetal_settings.py.erb new file mode 100644 index 00000000..965d8652 --- /dev/null +++ b/templates/_2299_baremetal_settings.py.erb @@ -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, + } +})