summaryrefslogtreecommitdiffstats
path: root/build/opendaylight-puppet-neutron.patch
blob: 9e0d713e66a767a0839c764e0891c4ac3a66bf63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
From 8f1ca7078619b8ab67de2580522f7174bed40774 Mon Sep 17 00:00:00 2001
From: Tim Rozet <trozet@redhat.com>
Date: Tue, 24 Nov 2015 14:39:12 -0500
Subject: [PATCH] Adds configuration support for OpenDaylight SDN Controller

In order to use OpenDaylight with Neutron, ML2 must be configured to
point to the OpenDaylight controller instance.  It also requires the
networking-odl python library to drive communication with ODL.
Additionally each Open vSwitch instance must be configured to set the ODL
Controller as it's manager.

Change-Id: If067e1057bec2d48f700838d86077a550bd27bd2
Signed-off-by: Tim Rozet <trozet@redhat.com>
---
 manifests/plugins/ml2/opendaylight.pp              | 51 +++++++++++++++++
 manifests/plugins/ovs/opendaylight.pp              | 63 +++++++++++++++++++++
 .../neutron_plugins_ml2_opendaylight_spec.rb       | 65 ++++++++++++++++++++++
 .../neutron_plugins_ovs_opendaylight_spec.rb       | 60 ++++++++++++++++++++
 4 files changed, 239 insertions(+)
 create mode 100644 manifests/plugins/ml2/opendaylight.pp
 create mode 100644 manifests/plugins/ovs/opendaylight.pp
 create mode 100644 spec/classes/neutron_plugins_ml2_opendaylight_spec.rb
 create mode 100644 spec/classes/neutron_plugins_ovs_opendaylight_spec.rb

diff --git a/manifests/plugins/ml2/opendaylight.pp b/manifests/plugins/ml2/opendaylight.pp
new file mode 100644
index 0000000..7dc7937
--- /dev/null
+++ b/manifests/plugins/ml2/opendaylight.pp
@@ -0,0 +1,51 @@
+#
+# Install the OpenDaylight and generate config file
+# from parameters in the other classes.
+#
+# === Parameters
+#
+# [*odl_controller_ip*]
+# (required) The OpenDaylight controller IP
+#
+# [*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 'admin'
+#
+# [*odl_password*]
+# (optional) The opendaylight controller password
+# Defaults to 'admin'
+#
+# [*odl_port*]
+# (optional) The opendaylight controller port
+# Defaults to '8080'
+#
+class neutron::plugins::ml2::opendaylight (
+  $odl_controller_ip,
+  $package_ensure    = 'present',
+  $odl_username      = 'admin',
+  $odl_password      = 'admin',
+  $odl_port          = '8080',
+) {
+  include ::neutron::params
+  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 => "http://${odl_controller_ip}:${odl_port}/controller/nb/v2/neutron";
+  }
+
+}
diff --git a/manifests/plugins/ovs/opendaylight.pp b/manifests/plugins/ovs/opendaylight.pp
new file mode 100644
index 0000000..3ebdb0e
--- /dev/null
+++ b/manifests/plugins/ovs/opendaylight.pp
@@ -0,0 +1,63 @@
+#
+# Configure OVS to use OpenDaylight
+#
+# === Parameters
+#
+# [*odl_controller_ip*]
+# (required) The OpenDaylight controller IP
+#
+# [*tunnel_ip*]
+# (required) The IP of the host to use for tunneling
+# tenant VXLAN/GRE over
+#
+# [*odl_port*]
+# (optional) The opendaylight controller port
+# Defaults to '8080'
+#
+# [*provider_mappings*]
+# (optional) bridge mappings required if using VLAN
+# tenant type.  Example: provider_mappings=br-ex:eth0
+# Defaults to false
+#
+# [*odl_username*]
+# (optional) The opendaylight controller username
+# Defaults to 'admin'
+#
+# [*odl_password*]
+# (optional) The opendaylight controller password
+# Defaults to 'admin'
+#
+class neutron::plugins::ovs::opendaylight (
+  $odl_controller_ip,
+  $tunnel_ip,
+  $odl_port          = '8080',
+  $provider_mappings = false,
+  $odl_username      = 'admin',
+  $odl_password      = 'admin',
+) {
+
+  exec { 'Wait for NetVirt OVSDB to come up':
+    command   => "/bin/curl -o /dev/null --fail --silent --head -u ${odl_username}:${odl_password} \
+                    http://${odl_controller_ip}:${odl_port}/restconf/operational/network-topology:network-topology/topology/netvirt:1",
+    tries     => 20,
+    try_sleep => 60,
+  } ->
+  # OVS manager
+  exec { 'Set OVS Manager to OpenDaylight':
+    command => "/usr/bin/ovs-vsctl set-manager tcp:${odl_controller_ip}:6640",
+    unless  => "/usr/bin/ovs-vsctl show | /usr/bin/grep 'Manager \"tcp:${odl_controller_ip}:6640\"'",
+  } ->
+  # 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}",
+    }
+  }
+}
diff --git a/spec/classes/neutron_plugins_ml2_opendaylight_spec.rb b/spec/classes/neutron_plugins_ml2_opendaylight_spec.rb
new file mode 100644
index 0000000..5772b3b
--- /dev/null
+++ b/spec/classes/neutron_plugins_ml2_opendaylight_spec.rb
@@ -0,0 +1,65 @@
+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   => 'admin',
+      :odl_password   => 'admin',
+      :odl_port       => '8080',
+    }
+  end
+
+  let :params do
+    {
+      :odl_controller_ip => '127.0.0.1',
+    }
+  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 { is_expected.to contain_class('neutron::params') }
+
+    it 'should have' do
+      is_expected.to contain_package('python-networking-odl').with(
+        :ensure => params[:package_ensure],
+        :tag    => 'openstack'
+        )
+    end
+  end
+
+  context 'on RedHat platforms' do
+    let :facts do
+      test_facts.merge({:osfamily => 'RedHat'})
+    end
+
+    it_configures 'neutron plugin opendaylight ml2'
+  end
+
+  context 'on Debian platforms' do
+    let :facts do
+      test_facts.merge({:osfamily => 'Debian'})
+    end
+
+    it_configures 'neutron plugin opendaylight ml2'
+  end
+end
diff --git a/spec/classes/neutron_plugins_ovs_opendaylight_spec.rb b/spec/classes/neutron_plugins_ovs_opendaylight_spec.rb
new file mode 100644
index 0000000..d6b93df
--- /dev/null
+++ b/spec/classes/neutron_plugins_ovs_opendaylight_spec.rb
@@ -0,0 +1,60 @@
+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
+    {
+      :provider_mappings => false,
+      :odl_username      => 'admin',
+      :odl_password      => 'admin',
+      :odl_port          => '8080',
+    }
+  end
+
+  let :params do
+    {
+      :odl_controller_ip => '127.0.0.1',
+      :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
+
+    it { is_expected.to contain_class('neutron::params') }
+
+  end
+
+  context 'on RedHat platforms' do
+    let :facts do
+      test_facts.merge({:osfamily => 'RedHat'})
+    end
+
+    it_configures 'neutron plugin opendaylight ovs'
+  end
+
+  context 'on Debian platforms' do
+    let :facts do
+      test_facts.merge({:osfamily => 'Debian'})
+    end
+
+    it_configures 'neutron plugin opendaylight ovs'
+  end
+end
-- 
2.5.0
an class="cp">}} </div>--> </div> </div> </div> </div> </div> <div ng-if="showImage==1&&showPod==null"> <div style="display:flex;flex-direction:row;"> <div style="width:750px;"> <h3>{{name}} -- Image <button class="btn btn-default" ng-click="goToPod()" ng-disabled="showNextPod==null" style="float:right"> Next </button> <button class="btn btn-default" ng-click="goToPodPrev()" style="margin-right:5px;float:right"> Back </button> </h3> <!--<p>In this process, you can input your define openrc config or upload a openrc file</p>--> <hr/> <button class="btn btn-default" ng-click="uploadImage()"> <div ng-if="!showloading">Load Image</div> <img src="images/loading2.gif" width="25" height="25" ng-if="showloading" /> </button> <i class="fa fa-check" aria-hidden="true" style="margin-top:34px;margin-left:5px;color: #2ecc71;" ng-show="imageStatus==1&&showImageStatus==1">done</i> <i class="fa fa-spinner" aria-hidden="true" style="margin-top:34px;margin-left:5px;color: #2ecc71;" ng-show="imageStatus==0&&showImageStatus==1">loading</i> <i class="fa fa-exclamation-triangle" aria-hidden="true" style="margin-top:34px;margin-left:5px;color: red;" ng-show="imageStatus==2&&showImageStatus==1">error</i> <!--<button class="btn btn-default" ng-click="goToPod()" ng-disabled="showNextPod==null"> Next </button>--> <hr> <h4>Current Images</h4> <div> <table class="table table-striped"> <tr> <th>choose</th> <th>name</th> <th>description</th> <th>status</th> </tr> <tr ng-repeat="(name, value) in yardstickImage"> <td ng-if="selectImageList.indexOf(name) > -1"><img src="images/checkyes.png" style="height:12px;cursor:pointer" ng-click="unselectImage(name)" /></td> <td ng-if="selectImageList.indexOf(name) == -1"><img src="images/checkno.png" style="height:12px;cursor:pointer" ng-click="selectImage(name)" /></td> <td>{{name}}</td> <td>{{value.description}}</td> <td>{{value.status}}</td> </tr> </table> </div> </div> </div> </div> <div ng-if="showPod==1&&showContainer==null"> <div style="display:flex;flex-direction:row;"> <div style="width:750px;"> <h3>{{name}} -- Pod File <div style="float:right"> <button class="btn btn-default" ng-click="skipPodPrev()">Back</button> <button class="btn btn-default" ng-click="skipPod()" ng-show="podData==null">Skip</button> <button class="btn btn-default" ng-click="skipPod()" ng-show="podData!=null">Next</button> </div> </h3> <hr/> <button class="btn btn-default" ngf-select="uploadFilesPod($file, $invalidFiles)" ngf-max-size="5MB"> <div ng-show="!loadingOPENrc">Upload</div> <img src="images/loading2.gif" width="25" height="25" ng-if="loadingOPENrc" /> </button> <hr/> <div> <h4>Current Pod Configuration</h4> <table class="table table-striped"> <tr> <th>ip</th> <th>name</th> <th>password</th> <th>role</th> <th>user</th> </tr> <tr ng-repeat="pod in podData.pod.nodes"> <td>{{pod.ip}}</td> <td>{{pod.name}}</td> <td>{{pod.password}}</td> <td>{{pod.role}}</td> <td>{{pod.user}}</td> </tr> <tr ng-show="podData.length==0"> <td>no data</td> </tr> </table> </div> </div> </div> </div> <div ng-if="showContainer!=null"> <div style="display:flex;flex-direction:row;"> <div style="width:750px;"> <h3>{{name}} -- Container <div style="float:right"> <button class="btn btn-default" ng-click="skipContainerPrev()">Back</button> <button class="btn btn-default" ng-click="skipContainer()" ng-show="ifskipOrClose!=1"> Skip </button> <button class="btn btn-default" ng-click="closeThisDialog(); getEnvironmentList();" ng-show="ifskipOrClose==1"> Close </button> </div> <!--<button class="btn btn-default" style="float:right">Go Next</button>--> </h3> <!--<p>In this process, you can input your define openrc config or upload a openrc file</p>--> <hr/> <select ng-model="selectContainer" data-ng-options="container as container.name for container in containerList"> <option value="">Choose...</option> </select> <button class="btn btn-default" ng-click="createContainer(selectContainer)" ng-disabled="selectContainer==null"> <div ng-show="!showloading">Create</div> <img src="images/loading2.gif" width="25" height="25" ng-if="showloading" /> </button> <!--<button class="btn btn-default" ng-click="skipContainer()" ng-show="ifskipOrClose!=1"> Skip </button> <button class="btn btn-default" ng-click="closeThisDialog(); getEnvironmentList();" ng-show="ifskipOrClose==1"> Close </button>--> <hr/> <div> <h4>Current Contain</h4> <table class="table table-striped"> <tr> <th>name</th> <th>status</th> <th>time</th> </tr> <tr ng-repeat="con in displayContainerInfo"> <td>{{con.name}}</td> <td>{{con.status}}</td> <td>{{con.time}}</td> </tr> </table> </div> </div> </div> </div> </div> <style> input { border-radius: 10px; border: 1px solid #eeeeee; width: 100%; } select { height: 30px; border-radius: 5px; border: 1px solid #e8e8e8; width: 135px; margin-top: 20px; margin-left: 20px; } </style>