Add support for notification handler options

The designate-sink service has some options to customize behavior of
notification handlers which handles notifications from nova and
neutron. This adds a few classes to support these options.

Change-Id: If041b3d788d26016367134a9447161fb830dd09e
This commit is contained in:
Takashi Kajinami 2024-01-30 17:06:00 +09:00
parent c9da9cf718
commit 5a39b5bb37
6 changed files with 189 additions and 3 deletions

View File

@ -0,0 +1,44 @@
# == Class designate::sink::neutron_floatingip
#
# Configure neutron notification handler options for designate sink service
#
# == Parameters
#
# [*notification_topics*]
# (Optional) Notification any events from neutron.
# Defaults to $facts['os_service_default'].
#
# [*control_exchange*]
# (Optional) control-exchange for neutron notifications
# Defaults to $facts['os_service_default'].
#
# [*zone_id*]
# (Optional) Zone ID with each notification
# Defaults to $facts['os_service_default'].
#
# [*formatv4*]
# (Optional) IPv4 format.
# Defaults to $facts['os_service_default'].
#
# [*formatv6*]
# (Optional) IPv6 format.
# Defaults to $facts['os_service_default'].
#
class designate::sink::neutron_floatingip (
$notification_topics = $facts['os_service_default'],
$control_exchange = $facts['os_service_default'],
$zone_id = $facts['os_service_default'],
$formatv4 = $facts['os_service_default'],
$formatv6 = $facts['os_service_default'],
) {
include designate::deps
designate_config {
'handler:neutron_floatingip/notification_topics': value => join(any2array($notification_topics), ',');
'handler:neutron_floatingip/control_exchange': value => $control_exchange;
'handler:neutron_floatingip/zone_id': value => $zone_id;
'handler:neutron_floatingip/formatv4': value => $formatv4;
'handler:neutron_floatingip/formatv6': value => $formatv6;
}
}

View File

@ -0,0 +1,44 @@
# == Class designate::sink::nova_fixed
#
# Configure nova notification handler options for designate sink service
#
# == Parameters
#
# [*notification_topics*]
# (Optional) Notification any events from nova.
# Defaults to $facts['os_service_default'].
#
# [*control_exchange*]
# (Optional) control-exchange for nova notifications
# Defaults to $facts['os_service_default'].
#
# [*zone_id*]
# (Optional) Zone ID with each notification
# Defaults to $facts['os_service_default'].
#
# [*formatv4*]
# (Optional) IPv4 format.
# Defaults to $facts['os_service_default'].
#
# [*formatv6*]
# (Optional) IPv6 format.
# Defaults to $facts['os_service_default'].
#
class designate::sink::nova_fixed (
$notification_topics = $facts['os_service_default'],
$control_exchange = $facts['os_service_default'],
$zone_id = $facts['os_service_default'],
$formatv4 = $facts['os_service_default'],
$formatv6 = $facts['os_service_default'],
) {
include designate::deps
designate_config {
'handler:nova_fixed/notification_topics': value => join(any2array($notification_topics), ',');
'handler:nova_fixed/control_exchange': value => $control_exchange;
'handler:nova_fixed/zone_id': value => $zone_id;
'handler:nova_fixed/formatv4': value => $formatv4;
'handler:nova_fixed/formatv6': value => $formatv6;
}
}

View File

@ -0,0 +1,7 @@
---
features:
- |
The following classes have been added.
- ``designate::sink::neutron_fixedip``
- ``designate::sink::nova_fixed``

View File

@ -0,0 +1,47 @@
require 'spec_helper'
describe 'designate::sink::neutron_floatingip' do
shared_examples 'designate::sink::neutron_floatingip' do
context 'with default parameters' do
it 'should confiure neutron notification handler options' do
is_expected.to contain_designate_config('handler:neutron_floatingip/notification_topics').with_value('<SERVICE DEFAULT>')
is_expected.to contain_designate_config('handler:neutron_floatingip/control_exchange').with_value('<SERVICE DEFAULT>')
is_expected.to contain_designate_config('handler:neutron_floatingip/zone_id').with_value('<SERVICE DEFAULT>')
is_expected.to contain_designate_config('handler:neutron_floatingip/formatv4').with_value('<SERVICE DEFAULT>')
is_expected.to contain_designate_config('handler:neutron_floatingip/formatv6').with_value('<SERVICE DEFAULT>')
end
end
context 'with overridden parameters' do
let :params do
{
:notification_topics => 'notifications',
:control_exchange => 'neutron',
:zone_id => 'ZONEID',
:formatv4 => 'v4format',
:formatv6 => 'v6format',
}
end
it 'should confiure neutron notification handler options' do
is_expected.to contain_designate_config('handler:neutron_floatingip/notification_topics').with_value('notifications')
is_expected.to contain_designate_config('handler:neutron_floatingip/control_exchange').with_value('neutron')
is_expected.to contain_designate_config('handler:neutron_floatingip/zone_id').with_value('ZONEID')
is_expected.to contain_designate_config('handler:neutron_floatingip/formatv4').with_value('v4format')
is_expected.to contain_designate_config('handler:neutron_floatingip/formatv6').with_value('v6format')
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_behaves_like 'designate::sink::neutron_floatingip'
end
end
end

View File

@ -0,0 +1,47 @@
require 'spec_helper'
describe 'designate::sink::nova_fixed' do
shared_examples 'designate::sink::nova_fixed' do
context 'with default parameters' do
it 'should confiure nova notification handler options' do
is_expected.to contain_designate_config('handler:nova_fixed/notification_topics').with_value('<SERVICE DEFAULT>')
is_expected.to contain_designate_config('handler:nova_fixed/control_exchange').with_value('<SERVICE DEFAULT>')
is_expected.to contain_designate_config('handler:nova_fixed/zone_id').with_value('<SERVICE DEFAULT>')
is_expected.to contain_designate_config('handler:nova_fixed/formatv4').with_value('<SERVICE DEFAULT>')
is_expected.to contain_designate_config('handler:nova_fixed/formatv6').with_value('<SERVICE DEFAULT>')
end
end
context 'with overridden parameters' do
let :params do
{
:notification_topics => 'notifications',
:control_exchange => 'nova',
:zone_id => 'ZONEID',
:formatv4 => 'v4format',
:formatv6 => 'v6format',
}
end
it 'should confiure nova notification handler options' do
is_expected.to contain_designate_config('handler:nova_fixed/notification_topics').with_value('notifications')
is_expected.to contain_designate_config('handler:nova_fixed/control_exchange').with_value('nova')
is_expected.to contain_designate_config('handler:nova_fixed/zone_id').with_value('ZONEID')
is_expected.to contain_designate_config('handler:nova_fixed/formatv4').with_value('v4format')
is_expected.to contain_designate_config('handler:nova_fixed/formatv6').with_value('v6format')
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_behaves_like 'designate::sink::nova_fixed'
end
end
end

View File

@ -1,6 +1,3 @@
#
# Unit tests for designate::sink
#
require 'spec_helper'
describe 'designate::sink' do