Accept a string and hash for contrail_extensions
... following the logic we have for DictOpt options. Change-Id: I20204bc6c63336d2e04d3e19a058e8b2f23b0778
This commit is contained in:
parent
dbad032e33
commit
d70cabeb52
@ -49,7 +49,10 @@ class neutron::plugins::opencontrail (
|
||||
include neutron::deps
|
||||
include neutron::params
|
||||
|
||||
validate_legacy(Array, 'validate_array', $contrail_extensions)
|
||||
$contrail_extensions_real = $contrail_extensions ? {
|
||||
Hash => join(join_keys_to_values($contrail_extensions, ':'), ','),
|
||||
default => join(any2array($contrail_extensions), ','),
|
||||
}
|
||||
|
||||
package { 'neutron-plugin-contrail':
|
||||
ensure => $package_ensure,
|
||||
@ -89,7 +92,7 @@ class neutron::plugins::opencontrail (
|
||||
neutron_plugin_opencontrail {
|
||||
'APISERVER/api_server_ip': value => $api_server_ip;
|
||||
'APISERVER/api_server_port': value => $api_server_port;
|
||||
'APISERVER/contrail_extensions': value => join($contrail_extensions, ',');
|
||||
'APISERVER/contrail_extensions': value => $contrail_extensions_real;
|
||||
'APISERVER/timeout': value => $timeout;
|
||||
'APISERVER/connection_timeout': value => $connection_timeout;
|
||||
}
|
||||
|
@ -2,15 +2,8 @@ require 'spec_helper'
|
||||
|
||||
describe 'neutron::plugins::opencontrail' do
|
||||
shared_examples 'neutron::plugins::contrail' do
|
||||
let :params do
|
||||
{
|
||||
:api_server_ip => '10.0.0.1',
|
||||
:api_server_port => '8082',
|
||||
:contrail_extensions => ['ipam:ipam','policy:policy','route-table'],
|
||||
:purge_config => false,
|
||||
}
|
||||
end
|
||||
|
||||
context 'with defaults' do
|
||||
it 'passes purge to resource' do
|
||||
should contain_resources('neutron_plugin_opencontrail').with({
|
||||
:purge => false
|
||||
@ -18,21 +11,52 @@ describe 'neutron::plugins::opencontrail' do
|
||||
end
|
||||
|
||||
it 'should perform default configuration of' do
|
||||
should contain_neutron_plugin_opencontrail('APISERVER/api_server_ip').with_value(params[:api_server_ip])
|
||||
should contain_neutron_plugin_opencontrail('APISERVER/api_server_port').with_value(params[:api_server_port])
|
||||
should contain_neutron_plugin_opencontrail('APISERVER/contrail_extensions').with_value(params[:contrail_extensions].join(','))
|
||||
should contain_neutron_plugin_opencontrail('APISERVER/api_server_ip').with_value('<SERVICE DEFAULT>')
|
||||
should contain_neutron_plugin_opencontrail('APISERVER/api_server_port').with_value('<SERVICE DEFAULT>')
|
||||
should contain_neutron_plugin_opencontrail('APISERVER/contrail_extensions').with_value('<SERVICE DEFAULT>')
|
||||
should contain_neutron_plugin_opencontrail('APISERVER/timeout').with_value('<SERVICE DEFAULT>')
|
||||
should contain_neutron_plugin_opencontrail('APISERVER/connection_timeout').with_value('<SERVICE DEFAULT>')
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'neutron::plugins::opencontrail on Debian' do
|
||||
context 'with parameters' do
|
||||
let :params do
|
||||
{
|
||||
:contrail_extensions => ['ipam:ipam','policy:policy','route-table']
|
||||
:api_server_ip => '10.0.0.1',
|
||||
:api_server_port => '8082',
|
||||
:contrail_extensions => ['ipam:ipam','policy:policy','route-table'],
|
||||
:timeout => 10,
|
||||
:connection_timeout => 5,
|
||||
}
|
||||
end
|
||||
|
||||
it 'should set the given values' do
|
||||
should contain_neutron_plugin_opencontrail('APISERVER/api_server_ip').with_value(params[:api_server_ip])
|
||||
should contain_neutron_plugin_opencontrail('APISERVER/api_server_port').with_value(params[:api_server_port])
|
||||
should contain_neutron_plugin_opencontrail('APISERVER/contrail_extensions').with_value(params[:contrail_extensions].join(','))
|
||||
should contain_neutron_plugin_opencontrail('APISERVER/timeout').with_value(params[:timeout])
|
||||
should contain_neutron_plugin_opencontrail('APISERVER/connection_timeout').with_value(params[:connection_timeout])
|
||||
end
|
||||
end
|
||||
|
||||
context 'contrail_extensions set by a dictionary' do
|
||||
let :params do
|
||||
{
|
||||
:contrail_extensions => {
|
||||
'ipam' => 'ipam',
|
||||
'policy' => 'policy',
|
||||
'route-table' => 'route-table',
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
it 'should configure the contrail_extensions' do
|
||||
should contain_neutron_plugin_opencontrail('APISERVER/contrail_extensions').with_value('ipam:ipam,policy:policy,route-table:route-table')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'neutron::plugins::opencontrail on Debian' do
|
||||
it 'configures /etc/default/neutron-server' do
|
||||
should contain_file_line('/etc/default/neutron-server:NEUTRON_PLUGIN_CONFIG').with(
|
||||
:path => '/etc/default/neutron-server',
|
||||
@ -46,12 +70,6 @@ describe 'neutron::plugins::opencontrail' do
|
||||
end
|
||||
|
||||
shared_examples 'neutron::plugins::opencontrail on RedHat' do
|
||||
let :params do
|
||||
{
|
||||
:contrail_extensions => ['ipam:ipam','policy:policy','route-table']
|
||||
}
|
||||
end
|
||||
|
||||
it 'should create plugin symbolic link' do
|
||||
should contain_file('/etc/neutron/plugin.ini').with(
|
||||
:ensure => 'link',
|
||||
|
Loading…
Reference in New Issue
Block a user