Added support for QPID in Heat

This patch is adding the support for Apache Qpid in Heat.

Change-Id: I0ea4bd403e09426b0173a1aa3493d5c7c23fc688
Signed-off-by: Francesco Vollero <fvollero@redhat.com>
This commit is contained in:
Francesco Vollero 2013-08-07 22:28:18 +02:00
parent 4476150d94
commit 99b9286ef5
2 changed files with 134 additions and 23 deletions

View File

@ -22,17 +22,46 @@
# password to connect to the rabbit_server. Optional. Defaults to empty.
# [*rabbit_virtualhost*]
# virtualhost to use. Optional. Defaults to '/'
# [*qpid_hostname*]
# [*qpid_port*]
# [*qpid_username*]
# [*qpid_password*]
# [*qpid_heartbeat*]
# [*qpid_protocol*]
# [*qpid_tcp_nodelay*]
# [*qpid_reconnect*]
# [*qpid_reconnect_timeout*]
# [*qpid_reconnect_limit*]
# [*qpid_reconnect_interval*]
# [*qpid_reconnect_interval_min*]
# [*qpid_reconnect_interval_max*]
# (optional) various QPID options
#
class heat(
$package_ensure = 'present',
$verbose = 'False',
$debug = 'False',
$rpc_backend = 'heat.openstack.common.rpc.impl_kombu',
$rabbit_host = '127.0.0.1',
$rabbit_port = 5672,
$rabbit_hosts = undef,
$rabbit_userid = 'guest',
$rabbit_password = '',
$rabbit_virtualhost = '/',
$qpid_hostname = 'localhost',
$qpid_port = 5672,
$qpid_username = 'guest',
$qpid_password = 'guest',
$qpid_heartbeat = 60,
$qpid_protocol = 'tcp',
$qpid_tcp_nodelay = true,
$qpid_reconnect = true,
$qpid_reconnect_timeout = 0,
$qpid_reconnect_limit = 0,
$qpid_reconnect_interval_min = 0,
$qpid_reconnect_interval_max = 0,
$qpid_reconnect_interval = 0,
) {
include heat::params
@ -74,30 +103,57 @@ class heat(
Package['heat-common'] -> Heat_config<||>
if $rabbit_hosts {
heat_config { 'DEFAULT/rabbit_host': ensure => absent }
heat_config { 'DEFAULT/rabbit_port': ensure => absent }
heat_config { 'DEFAULT/rabbit_hosts':
value => join($rabbit_hosts, ',')
}
} else {
heat_config { 'DEFAULT/rabbit_host': value => $rabbit_host }
heat_config { 'DEFAULT/rabbit_port': value => $rabbit_port }
heat_config { 'DEFAULT/rabbit_hosts':
value => "${rabbit_host}:${rabbit_port}"
if $rpc_backend == 'heat.openstack.common.rpc.impl_kombu' {
if $rabbit_hosts {
heat_config { 'DEFAULT/rabbit_host': ensure => absent }
heat_config { 'DEFAULT/rabbit_port': ensure => absent }
heat_config { 'DEFAULT/rabbit_hosts':
value => join($rabbit_hosts, ',')
}
} else {
heat_config { 'DEFAULT/rabbit_host': value => $rabbit_host }
heat_config { 'DEFAULT/rabbit_port': value => $rabbit_port }
heat_config { 'DEFAULT/rabbit_hosts':
value => "${rabbit_host}:${rabbit_port}"
}
}
if size($rabbit_hosts) > 1 {
heat_config { 'DEFAULT/rabbit_ha_queues': value => true }
} else {
heat_config { 'DEFAULT/rabbit_ha_queues': value => false }
}
heat_config {
'DEFAULT/rabbit_userid' : value => $rabbit_userid;
'DEFAULT/rabbit_password' : value => $rabbit_password;
'DEFAULT/rabbit_virtualhost' : value => $rabbit_virtualhost;
}
}
if size($rabbit_hosts) > 1 {
heat_config { 'DEFAULT/rabbit_ha_queues': value => true }
} else {
heat_config { 'DEFAULT/rabbit_ha_queues': value => false }
if $rpc_backend == 'heat.openstack.common.rpc.impl_qpid' {
heat_config {
'DEFAULT/qpid_hostname': value => $qpid_hostname;
'DEFAULT/qpid_port': value => $qpid_port;
'DEFAULT/qpid_username': value => $qpid_username;
'DEFAULT/qpid_password': value => $qpid_password;
'DEFAULT/qpid_heartbeat': value => $qpid_heartbeat;
'DEFAULT/qpid_protocol': value => $qpid_protocol;
'DEFAULT/qpid_tcp_nodelay': value => $qpid_tcp_nodelay;
'DEFAULT/qpid_reconnect': value => $qpid_reconnect;
'DEFAULT/qpid_reconnect_timeout': value => $qpid_reconnect_timeout;
'DEFAULT/qpid_reconnect_limit': value => $qpid_reconnect_limit;
'DEFAULT/qpid_reconnect_interval_min': value => $qpid_reconnect_interval_min;
'DEFAULT/qpid_reconnect_interval_max': value => $qpid_reconnect_interval_max;
'DEFAULT/qpid_reconnect_interval': value => $qpid_reconnect_interval;
}
}
heat_config {
'DEFAULT/rabbit_userid' : value => $rabbit_userid;
'DEFAULT/rabbit_password' : value => $rabbit_password;
'DEFAULT/rabbit_virtualhost' : value => $rabbit_virtualhost;
'DEFAULT/rpc_backend' : value => $rpc_backend;
'DEFAULT/debug' : value => $debug;
'DEFAULT/verbose' : value => $verbose;
}

View File

@ -15,6 +15,16 @@ describe 'heat' do
}
end
let :qpid_params do
{
:rpc_backend => "heat.openstack.common.rpc.impl_qpid",
:qpid_hostname => 'localhost',
:qpid_port => 5672,
:qpid_username => 'guest',
:qpid_password => 'guest',
}
end
shared_examples_for 'heat' do
context 'with rabbit_host parameter' do
@ -35,6 +45,13 @@ describe 'heat' do
it_configures 'rabbit with HA support'
end
end
context 'with qpid instance' do
before {params.merge!(qpid_params) }
it_configures 'a heat base installation'
it_configures 'qpid as rpc backend'
end
end
shared_examples_for 'a heat base installation' do
@ -84,11 +101,6 @@ describe 'heat' do
)
end
it 'configures rabbit' do
should contain_heat_config('DEFAULT/rabbit_userid').with_value( params[:rabbit_userid] )
should contain_heat_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] )
should contain_heat_config('DEFAULT/rabbit_virtualhost').with_value( params[:rabbit_virtualhost] )
end
it 'configures debug and verbose' do
should contain_heat_config('DEFAULT/debug').with_value( params[:debug] )
@ -98,6 +110,11 @@ describe 'heat' do
end
shared_examples_for 'rabbit without HA support (with backward compatibility)' do
it 'configures rabbit' do
should contain_heat_config('DEFAULT/rabbit_userid').with_value( params[:rabbit_userid] )
should contain_heat_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] )
should contain_heat_config('DEFAULT/rabbit_virtualhost').with_value( params[:rabbit_virtualhost] )
end
it { should contain_heat_config('DEFAULT/rabbit_host').with_value( params[:rabbit_host] ) }
it { should contain_heat_config('DEFAULT/rabbit_port').with_value( params[:rabbit_port] ) }
it { should contain_heat_config('DEFAULT/rabbit_hosts').with_value( "#{params[:rabbit_host]}:#{params[:rabbit_port]}" ) }
@ -105,6 +122,11 @@ describe 'heat' do
end
shared_examples_for 'rabbit without HA support (without backward compatibility)' do
it 'configures rabbit' do
should contain_heat_config('DEFAULT/rabbit_userid').with_value( params[:rabbit_userid] )
should contain_heat_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] )
should contain_heat_config('DEFAULT/rabbit_virtualhost').with_value( params[:rabbit_virtualhost] )
end
it { should contain_heat_config('DEFAULT/rabbit_host').with_ensure('absent') }
it { should contain_heat_config('DEFAULT/rabbit_port').with_ensure('absent') }
it { should contain_heat_config('DEFAULT/rabbit_hosts').with_value( params[:rabbit_hosts].join(',') ) }
@ -112,12 +134,45 @@ describe 'heat' do
end
shared_examples_for 'rabbit with HA support' do
it 'configures rabbit' do
should contain_heat_config('DEFAULT/rabbit_userid').with_value( params[:rabbit_userid] )
should contain_heat_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] )
should contain_heat_config('DEFAULT/rabbit_virtualhost').with_value( params[:rabbit_virtualhost] )
end
it { should contain_heat_config('DEFAULT/rabbit_host').with_ensure('absent') }
it { should contain_heat_config('DEFAULT/rabbit_port').with_ensure('absent') }
it { should contain_heat_config('DEFAULT/rabbit_hosts').with_value( params[:rabbit_hosts].join(',') ) }
it { should contain_heat_config('DEFAULT/rabbit_ha_queues').with_value('true') }
end
shared_examples_for 'qpid as rpc backend' do
context("with default parameters") do
it { should contain_heat_config('DEFAULT/qpid_reconnect').with_value(true) }
it { should contain_heat_config('DEFAULT/qpid_reconnect_timeout').with_value('0') }
it { should contain_heat_config('DEFAULT/qpid_reconnect_limit').with_value('0') }
it { should contain_heat_config('DEFAULT/qpid_reconnect_interval_min').with_value('0') }
it { should contain_heat_config('DEFAULT/qpid_reconnect_interval_max').with_value('0') }
it { should contain_heat_config('DEFAULT/qpid_reconnect_interval').with_value('0') }
it { should contain_heat_config('DEFAULT/qpid_heartbeat').with_value('60') }
it { should contain_heat_config('DEFAULT/qpid_protocol').with_value('tcp') }
it { should contain_heat_config('DEFAULT/qpid_tcp_nodelay').with_value(true) }
end
context("with mandatory parameters set") do
it { should contain_heat_config('DEFAULT/rpc_backend').with_value('heat.openstack.common.rpc.impl_qpid') }
it { should contain_heat_config('DEFAULT/qpid_hostname').with_value( params[:qpid_hostname] ) }
it { should contain_heat_config('DEFAULT/qpid_port').with_value( params[:qpid_port] ) }
it { should contain_heat_config('DEFAULT/qpid_username').with_value( params[:qpid_username]) }
it { should contain_heat_config('DEFAULT/qpid_password').with_value(params[:qpid_password]) }
end
context("failing if the rpc_backend is not present") do
before { params.delete( :rpc_backend) }
it { expect { should raise_error(Puppet::Error) } }
end
end
context 'on Debian platforms' do
let :facts do
{ :osfamily => 'Debian' }