Merge "Adds configuration support for OpenDaylight SDN Controller"
This commit is contained in:
commit
4eeba83541
48
manifests/plugins/ml2/opendaylight.pp
Normal file
48
manifests/plugins/ml2/opendaylight.pp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#
|
||||||
|
# Install the OpenDaylight and generate config file
|
||||||
|
# from parameters in the other classes.
|
||||||
|
#
|
||||||
|
# === Parameters
|
||||||
|
#
|
||||||
|
# [*package_ensure*]
|
||||||
|
# (optional) The intended state of the python-networking-odl
|
||||||
|
# package, i.e. any of the possible values of the 'ensure'
|
||||||
|
# property for a package resource type.
|
||||||
|
# Defaults to 'present'
|
||||||
|
#
|
||||||
|
# [*odl_username*]
|
||||||
|
# (optional) The opendaylight controller username
|
||||||
|
# Defaults to $::os_service_default
|
||||||
|
# Example: 'admin'
|
||||||
|
#
|
||||||
|
# [*odl_password*]
|
||||||
|
# (optional) The opendaylight controller password
|
||||||
|
# Defaults to $::os_service_default
|
||||||
|
# Example: 'admin'
|
||||||
|
#
|
||||||
|
# [*odl_url*]
|
||||||
|
# (optional) The opendaylight controller neutron URL
|
||||||
|
# Defaults to $::os_service_default
|
||||||
|
# Example: 'http://127.0.0.1:8080/controller/nb/v2/neutron'
|
||||||
|
#
|
||||||
|
class neutron::plugins::ml2::opendaylight (
|
||||||
|
$package_ensure = 'present',
|
||||||
|
$odl_username = $::os_service_default,
|
||||||
|
$odl_password = $::os_service_default,
|
||||||
|
$odl_url = $::os_service_default,
|
||||||
|
) {
|
||||||
|
require ::neutron::plugins::ml2
|
||||||
|
|
||||||
|
ensure_resource('package', 'python-networking-odl',
|
||||||
|
{
|
||||||
|
ensure => $package_ensure,
|
||||||
|
tag => 'openstack',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
neutron_plugin_ml2 {
|
||||||
|
'ml2_odl/username': value => $odl_username;
|
||||||
|
'ml2_odl/password': value => $odl_password;
|
||||||
|
'ml2_odl/url': value => $odl_url;
|
||||||
|
}
|
||||||
|
}
|
75
manifests/plugins/ovs/opendaylight.pp
Normal file
75
manifests/plugins/ovs/opendaylight.pp
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
#
|
||||||
|
# Configure OVS to use OpenDaylight
|
||||||
|
#
|
||||||
|
# === Parameters
|
||||||
|
#
|
||||||
|
# [*tunnel_ip*]
|
||||||
|
# (required) The IP of the host to use for tunneling
|
||||||
|
# tenant VXLAN/GRE over
|
||||||
|
#
|
||||||
|
# [*odl_username*]
|
||||||
|
# (optional) The opendaylight controller username
|
||||||
|
# Defaults to 'admin'
|
||||||
|
#
|
||||||
|
# [*odl_password*]
|
||||||
|
# (optional) The opendaylight controller password
|
||||||
|
# Defaults to 'admin'
|
||||||
|
#
|
||||||
|
# [*odl_check_url*]
|
||||||
|
# (optional) The URL used to check ODL is available and ready
|
||||||
|
# Defaults to 'http://127.0.0.1:8080/restconf/operational/network-topology:network-topology/topology/netvirt:1'
|
||||||
|
#
|
||||||
|
# [*odl_ovsdb_iface*]
|
||||||
|
# (optional) The ODL southbound interface for OVSDB
|
||||||
|
# Defaults to 'tcp:127.0.0.1:6640'
|
||||||
|
#
|
||||||
|
# [*provider_mappings*]
|
||||||
|
# (optional) bridge mappings required if using VLAN
|
||||||
|
# tenant type. Example: provider_mappings=br-ex:eth0
|
||||||
|
# Defaults to false
|
||||||
|
#
|
||||||
|
# [*retry_interval*]
|
||||||
|
# (optional) The time (in seconds) to wait between ODL availability checks
|
||||||
|
# Defaults to 60
|
||||||
|
#
|
||||||
|
# [*retry_count*]
|
||||||
|
# (optional) The number of ODL availability checks to run before failing
|
||||||
|
# Defaults to 20
|
||||||
|
#
|
||||||
|
class neutron::plugins::ovs::opendaylight (
|
||||||
|
$tunnel_ip,
|
||||||
|
$odl_username = 'admin',
|
||||||
|
$odl_password = 'admin',
|
||||||
|
$odl_check_url = 'http://127.0.0.1:8080/restconf/operational/network-topology:network-topology/topology/netvirt:1',
|
||||||
|
$odl_ovsdb_iface = 'tcp:127.0.0.1:6640',
|
||||||
|
$provider_mappings = false,
|
||||||
|
$retry_interval = 60,
|
||||||
|
$retry_count = 20,
|
||||||
|
) {
|
||||||
|
# Handle the case where ODL controller is also on this host
|
||||||
|
Service<| title == 'opendaylight' |> -> Exec <| title == 'Wait for NetVirt OVSDB to come up' |>
|
||||||
|
|
||||||
|
exec { 'Wait for NetVirt OVSDB to come up':
|
||||||
|
command => "/bin/curl -o /dev/null --fail --silent --head -u ${odl_username}:${odl_password} ${odl_check_url}",
|
||||||
|
tries => $retry_count,
|
||||||
|
try_sleep => $retry_interval,
|
||||||
|
} ->
|
||||||
|
# OVS manager
|
||||||
|
exec { 'Set OVS Manager to OpenDaylight':
|
||||||
|
command => "/usr/bin/ovs-vsctl set-manager ${odl_ovsdb_iface}",
|
||||||
|
unless => "/usr/bin/ovs-vsctl show | /usr/bin/grep 'Manager \"${odl_ovsdb_iface}\"'",
|
||||||
|
} ->
|
||||||
|
# local ip
|
||||||
|
exec { 'Set local_ip Other Option':
|
||||||
|
command => "/usr/bin/ovs-vsctl set Open_vSwitch $(ovs-vsctl get Open_vSwitch . _uuid) other_config:local_ip=${tunnel_ip}",
|
||||||
|
unless => "/usr/bin/ovs-vsctl list Open_vSwitch | /usr/bin/grep 'local_ip=\"${tunnel_ip}\"'",
|
||||||
|
}
|
||||||
|
|
||||||
|
# set mappings for VLAN
|
||||||
|
if $provider_mappings {
|
||||||
|
exec { 'Set provider_mappings Other Option':
|
||||||
|
command => "/usr/bin/ovs-vsctl set Open_vSwitch $(ovs-vsctl get Open_vSwitch . _uuid) other_config:provider_mappings=${provider_mappings}",
|
||||||
|
unless => "/usr/bin/ovs-vsctl list Open_vSwitch | /usr/bin/grep 'provider_mappings' | /usr/bin/grep ${provider_mappings}",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
74
spec/classes/neutron_plugins_ml2_opendaylight_spec.rb
Normal file
74
spec/classes/neutron_plugins_ml2_opendaylight_spec.rb
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'neutron::plugins::ml2::opendaylight' 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',
|
||||||
|
:odl_username => '<SERVICE DEFAULT>',
|
||||||
|
:odl_password => '<SERVICE DEFAULT>',
|
||||||
|
:odl_url => '<SERVICE DEFAULT>',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
let :params do
|
||||||
|
{
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
let :test_facts do
|
||||||
|
{
|
||||||
|
:operatingsystem => 'default',
|
||||||
|
:operatingsystemrelease => 'default',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
shared_examples_for 'neutron plugin opendaylight ml2' do
|
||||||
|
before do
|
||||||
|
params.merge!(default_params)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should have' do
|
||||||
|
is_expected.to contain_package('python-networking-odl').with(
|
||||||
|
:ensure => params[:package_ensure],
|
||||||
|
:tag => 'openstack'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'configures ml2_odl settings' do
|
||||||
|
is_expected.to contain_neutron_plugin_ml2('ml2_odl/password').with_value(params[:odl_password])
|
||||||
|
is_expected.to contain_neutron_plugin_ml2('ml2_odl/username').with_value(params[:odl_username])
|
||||||
|
is_expected.to contain_neutron_plugin_ml2('ml2_odl/url').with_value(params[:odl_url])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
context 'on RedHat platforms' do
|
||||||
|
let :facts do
|
||||||
|
@default_facts.merge(test_facts.merge({
|
||||||
|
:osfamily => 'RedHat',
|
||||||
|
:operatingsystemrelease => '7'
|
||||||
|
}))
|
||||||
|
end
|
||||||
|
|
||||||
|
it_configures 'neutron plugin opendaylight ml2'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'on Debian platforms' do
|
||||||
|
let :facts do
|
||||||
|
@default_facts.merge(test_facts.merge({
|
||||||
|
:osfamily => 'Debian',
|
||||||
|
}))
|
||||||
|
end
|
||||||
|
|
||||||
|
it_configures 'neutron plugin opendaylight ml2'
|
||||||
|
end
|
||||||
|
end
|
90
spec/classes/neutron_plugins_ovs_opendaylight_spec.rb
Normal file
90
spec/classes/neutron_plugins_ovs_opendaylight_spec.rb
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'neutron::plugins::ovs::opendaylight' 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
|
||||||
|
{
|
||||||
|
:odl_username => 'admin',
|
||||||
|
:odl_password => 'admin',
|
||||||
|
:odl_check_url => 'http://127.0.0.1:8080/restconf/operational/network-topology:network-topology/topology/netvirt:1',
|
||||||
|
:odl_ovsdb_iface => 'tcp:127.0.0.1:6640',
|
||||||
|
:provider_mappings => false,
|
||||||
|
:retry_interval => 60,
|
||||||
|
:retry_count => 20,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
let :params do
|
||||||
|
{
|
||||||
|
:tunnel_ip => '127.0.0.1',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
let :test_facts do
|
||||||
|
{
|
||||||
|
:operatingsystem => 'default',
|
||||||
|
:operatingsystemrelease => 'default',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
shared_examples_for 'neutron plugin opendaylight ovs' do
|
||||||
|
before do
|
||||||
|
params.merge!(default_params)
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with provider mappings' do
|
||||||
|
before do
|
||||||
|
params.merge!({ :provider_mappings => true })
|
||||||
|
end
|
||||||
|
it_configures 'with provider mappings'
|
||||||
|
end
|
||||||
|
it_configures 'with default parameters'
|
||||||
|
end
|
||||||
|
|
||||||
|
shared_examples_for 'with default parameters' do
|
||||||
|
it 'configures OVS for ODL' do
|
||||||
|
is_expected.to contain_exec('Wait for NetVirt OVSDB to come up')
|
||||||
|
is_expected.to contain_exec('Set OVS Manager to OpenDaylight')
|
||||||
|
is_expected.to contain_exec('Set local_ip Other Option')
|
||||||
|
is_expected.not_to contain_exec('Set provider_mappings Other Option')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
shared_examples_for 'with provider mappings' do
|
||||||
|
it 'configures OVS for ODL' do
|
||||||
|
is_expected.to contain_exec('Wait for NetVirt OVSDB to come up')
|
||||||
|
is_expected.to contain_exec('Set OVS Manager to OpenDaylight')
|
||||||
|
is_expected.to contain_exec('Set local_ip Other Option')
|
||||||
|
is_expected.to contain_exec('Set provider_mappings Other Option')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'on RedHat platforms' do
|
||||||
|
let :facts do
|
||||||
|
@default_facts.merge(test_facts.merge({
|
||||||
|
:osfamily => 'RedHat',
|
||||||
|
:operatingsystemrelease => '7'
|
||||||
|
}))
|
||||||
|
end
|
||||||
|
|
||||||
|
it_configures 'neutron plugin opendaylight ovs'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'on Debian platforms' do
|
||||||
|
let :facts do
|
||||||
|
@default_facts.merge(test_facts.merge({
|
||||||
|
:osfamily => 'Debian'
|
||||||
|
}))
|
||||||
|
end
|
||||||
|
|
||||||
|
it_configures 'neutron plugin opendaylight ovs'
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user