Improve notifications parameters

Reasons:
- The monitoring_notifications parameter is old and only valid for
stable/essex.
- We need to change the driver and topics notification
- We need to notify on VM or/and task state changes

Changes:
- Add notification_driver option
- Add notification_topics option
- Add notify_api_faults option
- Add notify_on_state_change option

Change-Id: I9d1c5c57a4a5f805e174390d53a0f54319b16c79
This commit is contained in:
Pierre RAMBAUD 2014-03-27 17:18:13 +01:00
parent 05ddd0ae03
commit 3ca8d4d8c8
2 changed files with 85 additions and 14 deletions

View File

@ -194,6 +194,27 @@
# are 0.9 and 2.2
# Defaults to '0.9'
#
# [*notification_driver*]
# (optional) Driver or drivers to handle sending notifications.
# Value can be a string or a list.
# Defaults to []
#
# [*notification_topics*]
# (optional) AMQP topic used for OpenStack notifications
# Defaults to 'notifications'
#
# [*notify_api_faults*]
# (optional) If set, send api.fault notifications on caught
# exceptions in the API service
# Defaults to false
#
# [*notify_on_state_change*]
# (optional) If set, send compute.instance.update notifications
# on instance state changes. Valid values are None for no notifications,
# "vm_state" for notifications on VM state changes, or "vm_and_task_state"
# for notifications on VM and task state changes.
# Defaults to undef
#
class nova(
$ensure_package = 'present',
$database_connection = false,
@ -243,6 +264,10 @@ class nova(
$log_facility = 'LOG_USER',
$install_utilities = true,
$mysql_module = '0.9',
$notification_driver = [],
$notification_topics = 'notifications',
$notify_api_faults = false,
$notify_on_state_change = undef,
# DEPRECATED PARAMETERS
# this is how to query all resources from our clutser
$nova_cluster_id = undef,
@ -477,21 +502,36 @@ class nova(
nova_config { 'DEFAULT/log_dir': ensure => absent;}
}
nova_config {
'DEFAULT/verbose': value => $verbose;
'DEFAULT/debug': value => $debug;
'DEFAULT/rpc_backend': value => $rpc_backend;
# Following may need to be broken out to different nova services
'DEFAULT/state_path': value => $state_path;
'DEFAULT/lock_path': value => $lock_path;
'DEFAULT/service_down_time': value => $service_down_time;
'DEFAULT/rootwrap_config': value => $rootwrap_config;
if $monitoring_notifications {
warning('The monitoring_notifications parameter is deprecated, use notification_driver instead.')
$notification_driver_real = 'nova.openstack.common.notifier.rpc_notifier'
} else {
$notification_driver_real = is_string($notification_driver) ? {
true => $notification_driver,
default => join($notification_driver, ',')
}
}
if $monitoring_notifications {
nova_config {
'DEFAULT/verbose': value => $verbose;
'DEFAULT/debug': value => $debug;
'DEFAULT/rpc_backend': value => $rpc_backend;
'DEFAULT/notification_driver': value => $notification_driver_real;
'DEFAULT/notification_topics': value => $notification_topics;
'DEFAULT/notify_api_faults': value => $notify_api_faults;
# Following may need to be broken out to different nova services
'DEFAULT/state_path': value => $state_path;
'DEFAULT/lock_path': value => $lock_path;
'DEFAULT/service_down_time': value => $service_down_time;
'DEFAULT/rootwrap_config': value => $rootwrap_config;
}
if $notify_on_state_change and $notify_on_state_change in ['vm_state', 'vm_and_task_state'] {
nova_config {
'DEFAULT/notification_driver': value => 'nova.openstack.common.notifier.rpc_notifier'
'DEFAULT/notify_on_state_change': value => $notify_on_state_change;
}
} else {
nova_config { 'DEFAULT/notify_on_state_change': ensure => absent; }
}
# Syslog configuration

View File

@ -95,7 +95,6 @@ describe 'nova' do
should contain_nova_config('DEFAULT/lock_path').with_value(platform_params[:lock_path])
should contain_nova_config('DEFAULT/service_down_time').with_value('60')
should contain_nova_config('DEFAULT/rootwrap_config').with_value('/etc/nova/rootwrap.conf')
should_not contain_nova_config('DEFAULT/notification_driver')
end
it 'installs utilities' do
@ -125,9 +124,11 @@ describe 'nova' do
:service_down_time => '120',
:auth_strategy => 'foo',
:ensure_package => '2012.1.1-15.el6',
:monitoring_notifications => true,
:memcached_servers => ['memcached01:11211', 'memcached02:11211'],
:install_utilities => false,
:notification_driver => 'ceilometer.compute.nova_notifier',
:notification_topics => 'openstack',
:notify_api_faults => true,
:nova_user_id => '499',
:nova_group_id => '499' }
end
@ -191,7 +192,17 @@ describe 'nova' do
should contain_nova_config('DEFAULT/state_path').with_value('/var/lib/nova2')
should contain_nova_config('DEFAULT/lock_path').with_value('/var/locky/path')
should contain_nova_config('DEFAULT/service_down_time').with_value('120')
should contain_nova_config('DEFAULT/notification_driver').with_value('nova.openstack.common.notifier.rpc_notifier')
should contain_nova_config('DEFAULT/notification_driver').with_value('ceilometer.compute.nova_notifier')
should contain_nova_config('DEFAULT/notification_topics').with_value('openstack')
should contain_nova_config('DEFAULT/notify_api_faults').with_value(true)
end
context 'with multiple notification_driver' do
before { params.merge!( :notification_driver => ['ceilometer.compute.nova_notifier', 'nova.openstack.common.notifier.rpc_notifier']) }
it { should contain_nova_config('DEFAULT/notification_driver').with_value(
'ceilometer.compute.nova_notifier,nova.openstack.common.notifier.rpc_notifier'
) }
end
it 'does not install utilities' do
@ -205,6 +216,26 @@ describe 'nova' do
end
end
context 'with wrong notify_on_state_change parameter' do
let :params do
{ :notify_on_state_change => 'vm_status' }
end
it 'configures database' do
should contain_nova_config('DEFAULT/notify_on_state_change').with_ensure('absent')
end
end
context 'with notify_on_state_change parameter' do
let :params do
{ :notify_on_state_change => 'vm_state' }
end
it 'configures database' do
should contain_nova_config('DEFAULT/notify_on_state_change').with_value('vm_state')
end
end
context 'with deprecated sql parameters' do
let :params do
{ :sql_connection => 'mysql://user:pass@db/db',