Configure Big Switch ML2 plugin

Adds a class to install the Big Switch ML2 plugin and another one to
configure the [restproxy] section of ml2_conf.ini. Currently, only
RedHat osfamily is supported.

Change-Id: If027762f70695c31dbca6151373a0ebe6e75d071
This commit is contained in:
Jiri Stransky
2015-08-19 14:52:21 +02:00
parent 6120731d80
commit f8ec8a20a0
4 changed files with 225 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
#
# Install the Big Switch ML2 plugin.
#
# === Parameters
#
# [*package_ensure*]
# (optional) The intended state of the Big Switch ML2 plugin package
# (python-bsnstacklib) package, i.e. any of the possible values of the
# 'ensure' property for a package resource type. Defaults to
# 'present'
#
class neutron::plugins::ml2::bigswitch (
$package_ensure = 'present',
) {
include ::neutron::params
require ::neutron::plugins::ml2
if($::osfamily != 'Redhat') {
# Drivers are only packaged for RedHat at this time
fail("Unsupported osfamily ${::osfamily}")
}
ensure_packages('python-networking-bigswitch',
{
ensure => $package_ensure,
tag => 'openstack',
}
)
}

View File

@@ -0,0 +1,58 @@
#
# Set config file parameters for connecting Neutron server to Big
# Switch controllers.
#
# === Parameters
#
# [*servers*]
# Comma-separated list of Big Switch controllers.
# The format is "IP:port,IP:port".
#
# [*server_auth*]
# Credentials for the Big Switch controllers.
# The format is "username:password".
#
# [*auto_sync_on_failure*]
# (optional) When a failover happens in active/passive Big Switch
# controllers, resynchronize with the new master server. Defaults to
# true.
#
# [*consistency_interval*]
# (optional) Interval of a keepalive message sent from Neutron server
# to a Big Switch controller. Defaults to 60.
#
# [*neutron_id*]
# (optional) Unique identifier of the Neutron instance for the Big
# Switch controller. Defaults to 'neutron'.
#
# [*server_ssl*]
# (optional) Whether Neutron should use SSL to talk to the Big Switch
# controllers. Defaults to true.
#
# [*ssl_cert_directory*]
# (optional) Directory where Big Switch controller certificate will be
# stored. Defaults to '/var/lib/neutron'.
#
class neutron::plugins::ml2::bigswitch::restproxy (
$servers,
$server_auth,
$auto_sync_on_failure = true,
$consistency_interval = 60,
$neutron_id = 'neutron',
$server_ssl = true,
$ssl_cert_directory = '/var/lib/neutron',
) {
require ::neutron::plugins::ml2::bigswitch
neutron_plugin_ml2 {
'restproxy/servers' : value => $servers;
'restproxy/server_auth' : value => $server_auth;
'restproxy/auto_sync_on_failure' : value => $auto_sync_on_failure;
'restproxy/consistency_interval' : value => $consistency_interval;
'restproxy/neutron_id' : value => $neutron_id;
'restproxy/server_ssl' : value => $server_ssl;
'restproxy/ssl_cert_directory' : value => $ssl_cert_directory;
}
}

View File

@@ -0,0 +1,78 @@
#
# Unit tests for neutron::plugins::ml2::cisco::nexus class
#
require 'spec_helper'
describe 'neutron::plugins::ml2::bigswitch::restproxy' do
let :pre_condition do
"class { 'neutron::server': auth_password => 'password'}
class { 'neutron':
rabbit_password => 'passw0rd',
core_plugin => 'neutron.plugins.ml2.plugin.Ml2Plugin' }"
end
let :required_params do
{
:servers => '192.168.0.10:8000,192.168.0.11:8000',
:server_auth => 'admin:password',
}
end
let :params do
required_params
end
let :default_facts do
{ :operatingsystem => 'default',
:operatingsystemrelease => 'default',
}
end
shared_examples_for 'neutron bigswitch ml2 restproxy' do
it { is_expected.to contain_class('neutron::params') }
it { is_expected.to contain_class('neutron::plugins::ml2::bigswitch') }
it do
is_expected.to contain_neutron_plugin_ml2('restproxy/servers').with_value(params[:servers])
is_expected.to contain_neutron_plugin_ml2('restproxy/server_auth').with_value(params[:server_auth])
is_expected.to contain_neutron_plugin_ml2('restproxy/auto_sync_on_failure').with_value(true)
is_expected.to contain_neutron_plugin_ml2('restproxy/consistency_interval').with_value(60)
is_expected.to contain_neutron_plugin_ml2('restproxy/neutron_id').with_value('neutron')
is_expected.to contain_neutron_plugin_ml2('restproxy/server_ssl').with_value(true)
is_expected.to contain_neutron_plugin_ml2('restproxy/ssl_cert_directory').with_value('/var/lib/neutron')
end
context 'with custom params' do
let :params do
required_params.merge({
:auto_sync_on_failure => false,
:consistency_interval => 10,
:neutron_id => 'openstack',
:server_ssl => false,
:ssl_cert_directory => '/var/lib/bigswitch',
})
end
it do
is_expected.to contain_neutron_plugin_ml2('restproxy/auto_sync_on_failure').with_value(false)
is_expected.to contain_neutron_plugin_ml2('restproxy/consistency_interval').with_value(10)
is_expected.to contain_neutron_plugin_ml2('restproxy/neutron_id').with_value('openstack')
is_expected.to contain_neutron_plugin_ml2('restproxy/server_ssl').with_value(false)
is_expected.to contain_neutron_plugin_ml2('restproxy/ssl_cert_directory').with_value('/var/lib/bigswitch')
end
end
end
context 'on RedHat platforms' do
let :facts do
default_facts.merge({:osfamily => 'RedHat'})
end
it_configures 'neutron bigswitch ml2 restproxy'
end
end

View File

@@ -0,0 +1,60 @@
require 'spec_helper'
describe 'neutron::plugins::ml2::bigswitch' do
let :pre_condition do
"class { 'neutron::server': auth_password => 'password'}
class { 'neutron':
rabbit_password => 'passw0rd',
core_plugin => 'neutron.plugins.ml2.plugin.Ml2Plugin' }"
end
let :default_params do
{
:package_ensure => 'present'
}
end
let :params do
{}
end
let :default_facts do
{
:operatingsystem => 'default',
:operatingsystemrelease => 'default',
}
end
shared_examples_for 'neutron plugin bigswitch ml2' do
before do
params.merge!(default_params)
end
it { is_expected.to contain_class('neutron::params') }
it 'should have' do
is_expected.to contain_package('python-networking-bigswitch').with(
:ensure => params[:package_ensure],
:tag => 'openstack'
)
end
end
context 'on RedHat platforms' do
let :facts do
default_facts.merge({:osfamily => 'RedHat'})
end
it_configures 'neutron plugin bigswitch ml2'
end
context 'on Debian platforms' do
let :facts do
default_facts.merge({:osfamily => 'Debian'})
end
it { is_expected.to raise_error(Puppet::Error, /Unsupported osfamily Debian/) }
end
end