From 730df0a37b571cf94ef26d1c6b680253e407d9c6 Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Mon, 29 Aug 2016 12:58:31 +0200 Subject: [PATCH] Add ironic::drivers::agent manifest Allows configuring a few IPA-related parameters. Change-Id: If2c6987d0f38aecabf41c09505c4f0dca1116034 --- manifests/conductor.pp | 4 + manifests/drivers/agent.pp | 80 +++++++++++++++++++ .../notes/agent-params-108552435cb995be.yaml | 6 ++ spec/classes/ironic_conductor_spec.rb | 1 + spec/classes/ironic_drivers_agent_spec.rb | 76 ++++++++++++++++++ 5 files changed, 167 insertions(+) create mode 100644 manifests/drivers/agent.pp create mode 100644 releasenotes/notes/agent-params-108552435cb995be.yaml create mode 100644 spec/classes/ironic_drivers_agent_spec.rb diff --git a/manifests/conductor.pp b/manifests/conductor.pp index 49e5ca5c..0dddd4de 100644 --- a/manifests/conductor.pp +++ b/manifests/conductor.pp @@ -101,6 +101,10 @@ class ironic::conductor ( validate_array($enabled_drivers_real) + # NOTE(dtantsur): all in-tree drivers are IPA-based, so it won't hurt + # including its manifest (which only contains configuration options) + include ::ironic::drivers::agent + # On Ubuntu, ipmitool dependency is missing and ironic-conductor fails to start. # https://bugs.launchpad.net/cloud-archive/+bug/1572800 if member($enabled_drivers_real, 'pxe_ipmitool') and $::osfamily == 'Debian' { diff --git a/manifests/drivers/agent.pp b/manifests/drivers/agent.pp new file mode 100644 index 00000000..21f70fa8 --- /dev/null +++ b/manifests/drivers/agent.pp @@ -0,0 +1,80 @@ +# 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. + +# Configure the IPA-related parameters in Ironic +# +# === Parameters +# +# [*stream_raw_images*] +# (optional) Whether to stream raw images directly on the hard drive instead +# of first caching them in memory. Ignored when iSCSI is used for deploy. +# Defaults to $::os_service_default +# +# [*post_deploy_get_power_state_retries*] +# (optional) Number of retries getting power state after a soft power off. +# Must be a valid interger. +# Defaults to $::os_service_default +# +# [*post_deploy_get_power_state_retry_interval*] +# (optional) Amount of time (in seconds) to wait between polling power state +# after the soft power off. +# Defaults to $::os_service_default +# +# [*deploy_logs_collect*] +# (optional) Whether and when to collect IPA logs after deployment. +# Accepts values "always", "on_failure", "never". +# Defaults to $::os_service_default +# +# [*deploy_logs_storage_backend*] +# (optional) The backend to store IPA logs, if enabled. +# Accepts values "local" and "swift". +# Defaults to $::os_service_default +# +# [*deploy_logs_local_path*] +# (optional) The path to store IPA logs if deploy_logs_storage_backend is +# "local" (ignored otherwise). +# Defaults to $::os_service_default +# +# [*deploy_logs_swift_container*] +# (optional) Swift container to store IPA logs if deploy_logs_storage_backend +# is "swift" (ignored otherwise). +# Defaults to $::os_service_default +# +# [*deploy_logs_swift_days_to_expire*] +# (optional) Number of days before IPA logs expire in Swift. +# Defaults to $::os_service_default +# + +class ironic::drivers::agent ( + $stream_raw_images = $::os_service_default, + $post_deploy_get_power_state_retries = $::os_service_default, + $post_deploy_get_power_state_retry_interval = $::os_service_default, + $deploy_logs_collect = $::os_service_default, + $deploy_logs_storage_backend = $::os_service_default, + $deploy_logs_local_path = $::os_service_default, + $deploy_logs_swift_container = $::os_service_default, + $deploy_logs_swift_days_to_expire = $::os_service_default, +) { + + # Configure ironic.conf + ironic_config { + 'agent/stream_raw_images': value => $stream_raw_images; + 'agent/post_deploy_get_power_state_retries': value => $post_deploy_get_power_state_retries; + 'agent/post_deploy_get_power_state_retry_interval': value => $post_deploy_get_power_state_retry_interval; + 'agent/deploy_logs_collect': value => $deploy_logs_collect; + 'agent/deploy_logs_storage_backend': value => $deploy_logs_storage_backend; + 'agent/deploy_logs_local_path': value => $deploy_logs_local_path; + 'agent/deploy_logs_swift_container': value => $deploy_logs_swift_container; + 'agent/deploy_logs_swift_days_to_expire': value => $deploy_logs_swift_days_to_expire; + } + +} diff --git a/releasenotes/notes/agent-params-108552435cb995be.yaml b/releasenotes/notes/agent-params-108552435cb995be.yaml new file mode 100644 index 00000000..e7619b77 --- /dev/null +++ b/releasenotes/notes/agent-params-108552435cb995be.yaml @@ -0,0 +1,6 @@ +--- +features: + - Add new manifest "ironic::drivers::agent" for configuring IPA-related + configuration options. Currently contains options for storing ramdisk + logs, for streaming raw images and configuring timeout for soft power off + after deployment. diff --git a/spec/classes/ironic_conductor_spec.rb b/spec/classes/ironic_conductor_spec.rb index dc8261d0..4cebf5af 100644 --- a/spec/classes/ironic_conductor_spec.rb +++ b/spec/classes/ironic_conductor_spec.rb @@ -40,6 +40,7 @@ describe 'ironic::conductor' do end it { is_expected.to contain_class('ironic::params') } + it { is_expected.to contain_class('ironic::drivers::agent') } it 'installs ironic conductor package' do if platform_params.has_key?(:conductor_package) diff --git a/spec/classes/ironic_drivers_agent_spec.rb b/spec/classes/ironic_drivers_agent_spec.rb new file mode 100644 index 00000000..10f7ef24 --- /dev/null +++ b/spec/classes/ironic_drivers_agent_spec.rb @@ -0,0 +1,76 @@ +# 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. +# +# Unit tests for ironic::drivers::agent class +# + +require 'spec_helper' + +describe 'ironic::drivers::agent' do + + let :params do + {} + end + + shared_examples_for 'ironic agent driver' do + let :p do + params + end + + it 'configures ironic.conf' do + is_expected.to contain_ironic_config('agent/stream_raw_images').with_value('') + is_expected.to contain_ironic_config('agent/post_deploy_get_power_state_retries').with_value('') + is_expected.to contain_ironic_config('agent/post_deploy_get_power_state_retry_interval').with_value('') + is_expected.to contain_ironic_config('agent/deploy_logs_collect').with_value('') + is_expected.to contain_ironic_config('agent/deploy_logs_storage_backend').with_value('') + is_expected.to contain_ironic_config('agent/deploy_logs_local_path').with_value('') + is_expected.to contain_ironic_config('agent/deploy_logs_swift_container').with_value('') + is_expected.to contain_ironic_config('agent/deploy_logs_swift_days_to_expire').with_value('') + end + + context 'when overriding parameters' do + before do + params.merge!(:stream_raw_images => false, + :post_deploy_get_power_state_retries => 20, + :post_deploy_get_power_state_retry_interval => 10, + :deploy_logs_collect => 'always', + :deploy_logs_storage_backend => 'swift', + :deploy_logs_local_path => '/tmp', + :deploy_logs_swift_container => 'cont', + :deploy_logs_swift_days_to_expire => 5) + end + it 'should replace default parameter with new value' do + is_expected.to contain_ironic_config('agent/stream_raw_images').with_value(p[:stream_raw_images]) + is_expected.to contain_ironic_config('agent/post_deploy_get_power_state_retries').with_value(p[:post_deploy_get_power_state_retries]) + is_expected.to contain_ironic_config('agent/post_deploy_get_power_state_retry_interval').with_value(p[:post_deploy_get_power_state_retry_interval]) + is_expected.to contain_ironic_config('agent/deploy_logs_collect').with_value(p[:deploy_logs_collect]) + is_expected.to contain_ironic_config('agent/deploy_logs_storage_backend').with_value(p[:deploy_logs_storage_backend]) + is_expected.to contain_ironic_config('agent/deploy_logs_local_path').with_value(p[:deploy_logs_local_path]) + is_expected.to contain_ironic_config('agent/deploy_logs_swift_container').with_value(p[:deploy_logs_swift_container]) + is_expected.to contain_ironic_config('agent/deploy_logs_swift_days_to_expire').with_value(p[:deploy_logs_swift_days_to_expire]) + end + 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 + it_configures 'ironic agent driver' + end + end + +end