1 From 8f1ca7078619b8ab67de2580522f7174bed40774 Mon Sep 17 00:00:00 2001
2 From: Tim Rozet <trozet@redhat.com>
3 Date: Tue, 24 Nov 2015 14:39:12 -0500
4 Subject: [PATCH] Adds configuration support for OpenDaylight SDN Controller
6 In order to use OpenDaylight with Neutron, ML2 must be configured to
7 point to the OpenDaylight controller instance. It also requires the
8 networking-odl python library to drive communication with ODL.
9 Additionally each Open vSwitch instance must be configured to set the ODL
10 Controller as it's manager.
12 Change-Id: If067e1057bec2d48f700838d86077a550bd27bd2
13 Signed-off-by: Tim Rozet <trozet@redhat.com>
15 manifests/plugins/ml2/opendaylight.pp | 51 +++++++++++++++++
16 manifests/plugins/ovs/opendaylight.pp | 63 +++++++++++++++++++++
17 .../neutron_plugins_ml2_opendaylight_spec.rb | 65 ++++++++++++++++++++++
18 .../neutron_plugins_ovs_opendaylight_spec.rb | 60 ++++++++++++++++++++
19 4 files changed, 239 insertions(+)
20 create mode 100644 manifests/plugins/ml2/opendaylight.pp
21 create mode 100644 manifests/plugins/ovs/opendaylight.pp
22 create mode 100644 spec/classes/neutron_plugins_ml2_opendaylight_spec.rb
23 create mode 100644 spec/classes/neutron_plugins_ovs_opendaylight_spec.rb
25 diff --git a/manifests/plugins/ml2/opendaylight.pp b/manifests/plugins/ml2/opendaylight.pp
27 index 0000000..7dc7937
29 +++ b/manifests/plugins/ml2/opendaylight.pp
32 +# Install the OpenDaylight and generate config file
33 +# from parameters in the other classes.
37 +# [*odl_controller_ip*]
38 +# (required) The OpenDaylight controller IP
41 +# (optional) The intended state of the python-networking-odl
42 +# package, i.e. any of the possible values of the 'ensure'
43 +# property for a package resource type.
44 +# Defaults to 'present'
47 +# (optional) The opendaylight controller username
48 +# Defaults to 'admin'
51 +# (optional) The opendaylight controller password
52 +# Defaults to 'admin'
55 +# (optional) The opendaylight controller port
58 +class neutron::plugins::ml2::opendaylight (
60 + $package_ensure = 'present',
61 + $odl_username = 'admin',
62 + $odl_password = 'admin',
65 + include ::neutron::params
66 + require ::neutron::plugins::ml2
68 + ensure_resource('package', 'python-networking-odl',
70 + ensure => $package_ensure,
75 + neutron_plugin_ml2 {
76 + 'ml2_odl/username': value => $odl_username;
77 + 'ml2_odl/password': value => $odl_password;
78 + 'ml2_odl/url': value => "http://${odl_controller_ip}:${odl_port}/controller/nb/v2/neutron";
82 diff --git a/manifests/plugins/ovs/opendaylight.pp b/manifests/plugins/ovs/opendaylight.pp
84 index 0000000..3ebdb0e
86 +++ b/manifests/plugins/ovs/opendaylight.pp
89 +# Configure OVS to use OpenDaylight
93 +# [*odl_controller_ip*]
94 +# (required) The OpenDaylight controller IP
97 +# (required) The IP of the host to use for tunneling
98 +# tenant VXLAN/GRE over
101 +# (optional) The opendaylight controller port
102 +# Defaults to '8080'
104 +# [*provider_mappings*]
105 +# (optional) bridge mappings required if using VLAN
106 +# tenant type. Example: provider_mappings=br-ex:eth0
110 +# (optional) The opendaylight controller username
111 +# Defaults to 'admin'
114 +# (optional) The opendaylight controller password
115 +# Defaults to 'admin'
117 +class neutron::plugins::ovs::opendaylight (
118 + $odl_controller_ip,
120 + $odl_port = '8080',
121 + $provider_mappings = false,
122 + $odl_username = 'admin',
123 + $odl_password = 'admin',
126 + exec { 'Wait for NetVirt OVSDB to come up':
127 + command => "/bin/curl -o /dev/null --fail --silent --head -u ${odl_username}:${odl_password} \
128 + http://${odl_controller_ip}:${odl_port}/restconf/operational/network-topology:network-topology/topology/netvirt:1",
133 + exec { 'Set OVS Manager to OpenDaylight':
134 + command => "/usr/bin/ovs-vsctl set-manager tcp:${odl_controller_ip}:6640",
135 + unless => "/usr/bin/ovs-vsctl show | /usr/bin/grep 'Manager \"tcp:${odl_controller_ip}:6640\"'",
138 + exec { 'Set local_ip Other Option':
139 + command => "/usr/bin/ovs-vsctl set Open_vSwitch $(ovs-vsctl get Open_vSwitch . _uuid) other_config:local_ip=${tunnel_ip}",
140 + unless => "/usr/bin/ovs-vsctl list Open_vSwitch | /usr/bin/grep 'local_ip=\"${tunnel_ip}\"'",
143 + # set mappings for VLAN
144 + if $provider_mappings {
145 + exec { 'Set provider_mappings Other Option':
146 + command => "/usr/bin/ovs-vsctl set Open_vSwitch $(ovs-vsctl get Open_vSwitch . _uuid) other_config:provider_mappings=${provider_mappings}",
147 + unless => "/usr/bin/ovs-vsctl list Open_vSwitch | /usr/bin/grep 'provider_mappings' | /usr/bin/grep ${provider_mappings}",
151 diff --git a/spec/classes/neutron_plugins_ml2_opendaylight_spec.rb b/spec/classes/neutron_plugins_ml2_opendaylight_spec.rb
153 index 0000000..5772b3b
155 +++ b/spec/classes/neutron_plugins_ml2_opendaylight_spec.rb
157 +require 'spec_helper'
159 +describe 'neutron::plugins::ml2::opendaylight' do
161 + let :pre_condition do
162 + "class { 'neutron::server': auth_password => 'password'}
164 + rabbit_password => 'passw0rd',
165 + core_plugin => 'neutron.plugins.ml2.plugin.Ml2Plugin' }"
168 + let :default_params do
170 + :package_ensure => 'present',
171 + :odl_username => 'admin',
172 + :odl_password => 'admin',
173 + :odl_port => '8080',
179 + :odl_controller_ip => '127.0.0.1',
185 + :operatingsystem => 'default',
186 + :operatingsystemrelease => 'default',
191 + shared_examples_for 'neutron plugin opendaylight ml2' do
193 + params.merge!(default_params)
196 + it { is_expected.to contain_class('neutron::params') }
198 + it 'should have' do
199 + is_expected.to contain_package('python-networking-odl').with(
200 + :ensure => params[:package_ensure],
201 + :tag => 'openstack'
206 + context 'on RedHat platforms' do
208 + test_facts.merge({:osfamily => 'RedHat'})
211 + it_configures 'neutron plugin opendaylight ml2'
214 + context 'on Debian platforms' do
216 + test_facts.merge({:osfamily => 'Debian'})
219 + it_configures 'neutron plugin opendaylight ml2'
222 diff --git a/spec/classes/neutron_plugins_ovs_opendaylight_spec.rb b/spec/classes/neutron_plugins_ovs_opendaylight_spec.rb
224 index 0000000..d6b93df
226 +++ b/spec/classes/neutron_plugins_ovs_opendaylight_spec.rb
228 +require 'spec_helper'
230 +describe 'neutron::plugins::ovs::opendaylight' do
232 + let :pre_condition do
233 + "class { 'neutron::server': auth_password => 'password'}
235 + rabbit_password => 'passw0rd',
236 + core_plugin => 'neutron.plugins.ml2.plugin.Ml2Plugin' }"
239 + let :default_params do
241 + :provider_mappings => false,
242 + :odl_username => 'admin',
243 + :odl_password => 'admin',
244 + :odl_port => '8080',
250 + :odl_controller_ip => '127.0.0.1',
251 + :tunnel_ip => '127.0.0.1',
257 + :operatingsystem => 'default',
258 + :operatingsystemrelease => 'default',
263 + shared_examples_for 'neutron plugin opendaylight ovs' do
265 + params.merge!(default_params)
268 + it { is_expected.to contain_class('neutron::params') }
272 + context 'on RedHat platforms' do
274 + test_facts.merge({:osfamily => 'RedHat'})
277 + it_configures 'neutron plugin opendaylight ovs'
280 + context 'on Debian platforms' do
282 + test_facts.merge({:osfamily => 'Debian'})
285 + it_configures 'neutron plugin opendaylight ovs'