9e0d713e66a767a0839c764e0891c4ac3a66bf63
[apex.git] / build / opendaylight-puppet-neutron.patch
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
5
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.
11
12 Change-Id: If067e1057bec2d48f700838d86077a550bd27bd2
13 Signed-off-by: Tim Rozet <trozet@redhat.com>
14 ---
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
24
25 diff --git a/manifests/plugins/ml2/opendaylight.pp b/manifests/plugins/ml2/opendaylight.pp
26 new file mode 100644
27 index 0000000..7dc7937
28 --- /dev/null
29 +++ b/manifests/plugins/ml2/opendaylight.pp
30 @@ -0,0 +1,51 @@
31 +#
32 +# Install the OpenDaylight and generate config file
33 +# from parameters in the other classes.
34 +#
35 +# === Parameters
36 +#
37 +# [*odl_controller_ip*]
38 +# (required) The OpenDaylight controller IP
39 +#
40 +# [*package_ensure*]
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'
45 +#
46 +# [*odl_username*]
47 +# (optional) The opendaylight controller username
48 +# Defaults to 'admin'
49 +#
50 +# [*odl_password*]
51 +# (optional) The opendaylight controller password
52 +# Defaults to 'admin'
53 +#
54 +# [*odl_port*]
55 +# (optional) The opendaylight controller port
56 +# Defaults to '8080'
57 +#
58 +class neutron::plugins::ml2::opendaylight (
59 +  $odl_controller_ip,
60 +  $package_ensure    = 'present',
61 +  $odl_username      = 'admin',
62 +  $odl_password      = 'admin',
63 +  $odl_port          = '8080',
64 +) {
65 +  include ::neutron::params
66 +  require ::neutron::plugins::ml2
67 +
68 +  ensure_resource('package', 'python-networking-odl',
69 +    {
70 +      ensure => $package_ensure,
71 +      tag    => 'openstack',
72 +    }
73 +  )
74 +
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";
79 +  }
80 +
81 +}
82 diff --git a/manifests/plugins/ovs/opendaylight.pp b/manifests/plugins/ovs/opendaylight.pp
83 new file mode 100644
84 index 0000000..3ebdb0e
85 --- /dev/null
86 +++ b/manifests/plugins/ovs/opendaylight.pp
87 @@ -0,0 +1,63 @@
88 +#
89 +# Configure OVS to use OpenDaylight
90 +#
91 +# === Parameters
92 +#
93 +# [*odl_controller_ip*]
94 +# (required) The OpenDaylight controller IP
95 +#
96 +# [*tunnel_ip*]
97 +# (required) The IP of the host to use for tunneling
98 +# tenant VXLAN/GRE over
99 +#
100 +# [*odl_port*]
101 +# (optional) The opendaylight controller port
102 +# Defaults to '8080'
103 +#
104 +# [*provider_mappings*]
105 +# (optional) bridge mappings required if using VLAN
106 +# tenant type.  Example: provider_mappings=br-ex:eth0
107 +# Defaults to false
108 +#
109 +# [*odl_username*]
110 +# (optional) The opendaylight controller username
111 +# Defaults to 'admin'
112 +#
113 +# [*odl_password*]
114 +# (optional) The opendaylight controller password
115 +# Defaults to 'admin'
116 +#
117 +class neutron::plugins::ovs::opendaylight (
118 +  $odl_controller_ip,
119 +  $tunnel_ip,
120 +  $odl_port          = '8080',
121 +  $provider_mappings = false,
122 +  $odl_username      = 'admin',
123 +  $odl_password      = 'admin',
124 +) {
125 +
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",
129 +    tries     => 20,
130 +    try_sleep => 60,
131 +  } ->
132 +  # OVS manager
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\"'",
136 +  } ->
137 +  # local ip
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}\"'",
141 +  }
142 +
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}",
148 +    }
149 +  }
150 +}
151 diff --git a/spec/classes/neutron_plugins_ml2_opendaylight_spec.rb b/spec/classes/neutron_plugins_ml2_opendaylight_spec.rb
152 new file mode 100644
153 index 0000000..5772b3b
154 --- /dev/null
155 +++ b/spec/classes/neutron_plugins_ml2_opendaylight_spec.rb
156 @@ -0,0 +1,65 @@
157 +require 'spec_helper'
158 +
159 +describe 'neutron::plugins::ml2::opendaylight' do
160 +
161 +  let :pre_condition do
162 +    "class { 'neutron::server': auth_password => 'password'}
163 +     class { 'neutron':
164 +      rabbit_password => 'passw0rd',
165 +      core_plugin     => 'neutron.plugins.ml2.plugin.Ml2Plugin' }"
166 +  end
167 +
168 +  let :default_params do
169 +    {
170 +      :package_ensure => 'present',
171 +      :odl_username   => 'admin',
172 +      :odl_password   => 'admin',
173 +      :odl_port       => '8080',
174 +    }
175 +  end
176 +
177 +  let :params do
178 +    {
179 +      :odl_controller_ip => '127.0.0.1',
180 +    }
181 +  end
182 +
183 +  let :test_facts do
184 +    {
185 +      :operatingsystem        => 'default',
186 +      :operatingsystemrelease => 'default',
187 +    }
188 +  end
189 +
190 +
191 +  shared_examples_for 'neutron plugin opendaylight ml2' do
192 +    before do
193 +      params.merge!(default_params)
194 +    end
195 +
196 +    it { is_expected.to contain_class('neutron::params') }
197 +
198 +    it 'should have' do
199 +      is_expected.to contain_package('python-networking-odl').with(
200 +        :ensure => params[:package_ensure],
201 +        :tag    => 'openstack'
202 +        )
203 +    end
204 +  end
205 +
206 +  context 'on RedHat platforms' do
207 +    let :facts do
208 +      test_facts.merge({:osfamily => 'RedHat'})
209 +    end
210 +
211 +    it_configures 'neutron plugin opendaylight ml2'
212 +  end
213 +
214 +  context 'on Debian platforms' do
215 +    let :facts do
216 +      test_facts.merge({:osfamily => 'Debian'})
217 +    end
218 +
219 +    it_configures 'neutron plugin opendaylight ml2'
220 +  end
221 +end
222 diff --git a/spec/classes/neutron_plugins_ovs_opendaylight_spec.rb b/spec/classes/neutron_plugins_ovs_opendaylight_spec.rb
223 new file mode 100644
224 index 0000000..d6b93df
225 --- /dev/null
226 +++ b/spec/classes/neutron_plugins_ovs_opendaylight_spec.rb
227 @@ -0,0 +1,60 @@
228 +require 'spec_helper'
229 +
230 +describe 'neutron::plugins::ovs::opendaylight' do
231 +
232 +  let :pre_condition do
233 +    "class { 'neutron::server': auth_password => 'password'}
234 +     class { 'neutron':
235 +      rabbit_password => 'passw0rd',
236 +      core_plugin     => 'neutron.plugins.ml2.plugin.Ml2Plugin' }"
237 +  end
238 +
239 +  let :default_params do
240 +    {
241 +      :provider_mappings => false,
242 +      :odl_username      => 'admin',
243 +      :odl_password      => 'admin',
244 +      :odl_port          => '8080',
245 +    }
246 +  end
247 +
248 +  let :params do
249 +    {
250 +      :odl_controller_ip => '127.0.0.1',
251 +      :tunnel_ip         => '127.0.0.1',
252 +    }
253 +  end
254 +
255 +  let :test_facts do
256 +    {
257 +      :operatingsystem        => 'default',
258 +      :operatingsystemrelease => 'default',
259 +    }
260 +  end
261 +
262 +
263 +  shared_examples_for 'neutron plugin opendaylight ovs' do
264 +    before do
265 +      params.merge!(default_params)
266 +    end
267 +
268 +    it { is_expected.to contain_class('neutron::params') }
269 +
270 +  end
271 +
272 +  context 'on RedHat platforms' do
273 +    let :facts do
274 +      test_facts.merge({:osfamily => 'RedHat'})
275 +    end
276 +
277 +    it_configures 'neutron plugin opendaylight ovs'
278 +  end
279 +
280 +  context 'on Debian platforms' do
281 +    let :facts do
282 +      test_facts.merge({:osfamily => 'Debian'})
283 +    end
284 +
285 +    it_configures 'neutron plugin opendaylight ovs'
286 +  end
287 +end
288 -- 
289 2.5.0
290