blob: bd73f1afa3cead9fcfdd5cc719c35d1c57d0d9e6 [file] [log] [blame]
Luca Pretee2d51fd2017-08-31 16:19:21 -07001// Copyright 2017-present Open Networking Foundation
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
Kailash Khalasiea9bea12018-05-08 12:01:11 -070015import groovy.json.JsonSlurper
You Wang1abf2bf2017-12-12 15:21:07 -080016
Luca Pretee2d51fd2017-08-31 16:19:21 -070017def filename = 'manifest-${branch}.xml'
18def manifestUrl = 'https://gerrit.opencord.org/manifest'
You Wang1abf2bf2017-12-12 15:21:07 -080019deployment_config = null;
20pod_config = null;
Luca Pretee2d51fd2017-08-31 16:19:21 -070021
Kailash Khalasi1af05162018-04-23 10:54:28 -070022node ("${devNodeName}") {
Luca Pretee2d51fd2017-08-31 16:19:21 -070023 timeout (time: 240) {
Kailash Khalasi1af05162018-04-23 10:54:28 -070024 stage ("Parse deployment configuration file") {
25 sh returnStdout: true, script: 'rm -rf ${configRepoBaseDir}'
26 sh returnStdout: true, script: 'git clone -b ${branch} ${configRepoUrl}'
27 deployment_config = readYaml file: "${configRepoBaseDir}${configRepoFile}"
28 pod_config = readYaml file: "${configRepoBaseDir}${deployment_config.pod_config.file_name}"
29 }
Luca Prete225d9652017-09-12 10:44:48 -070030 stage ('Remove old head node from known hosts') {
You Wang1abf2bf2017-12-12 15:21:07 -080031 sh "ssh-keygen -R ${deployment_config.head.ip}"
You Wangf9cb2f32017-09-11 13:26:42 -070032 }
Luca Pretee2d51fd2017-08-31 16:19:21 -070033 stage ('Checkout cord repo') {
34 checkout changelog: false, poll: false, scm: [$class: 'RepoScm', currentBranch: true, manifestBranch: params.branch, manifestRepositoryUrl: "${manifestUrl}", quiet: true]
35 }
36
Luca Pretefcbc54b2017-09-12 14:37:33 -070037 try {
38 dir('build') {
Luca Pretee2d51fd2017-08-31 16:19:21 -070039 stage ("Re-deploy head node") {
40 maasOps: {
You Wang1abf2bf2017-12-12 15:21:07 -080041 sh "maas login maas http://${deployment_config.maas.ip}/MAAS/api/2.0 ${deployment_config.maas.api_key}"
42 sh "maas maas machine release ${deployment_config.maas.head_system_id}"
Luca Pretee2d51fd2017-08-31 16:19:21 -070043
44 timeout(time: 15) {
45 waitUntil {
46 try {
You Wang1abf2bf2017-12-12 15:21:07 -080047 sh "maas maas machine read ${deployment_config.maas.head_system_id} | grep Ready"
Luca Pretee2d51fd2017-08-31 16:19:21 -070048 return true
49 } catch (exception) {
50 return false
51 }
52 }
53 }
54
55 sh 'maas maas machines allocate'
You Wang1abf2bf2017-12-12 15:21:07 -080056 sh "maas maas machine deploy ${deployment_config.maas.head_system_id}"
Luca Pretee2d51fd2017-08-31 16:19:21 -070057
58 timeout(time: 30) {
59 waitUntil {
60 try {
You Wang1abf2bf2017-12-12 15:21:07 -080061 sh "maas maas machine read ${deployment_config.maas.head_system_id} | grep Deployed"
Luca Pretee2d51fd2017-08-31 16:19:21 -070062 return true
63 } catch (exception) {
64 return false
65 }
66 }
67 }
68 }
69 }
70
71 stage ("Download CORD POD configuration") {
You Wange6fbdae2018-01-02 11:35:10 -080072 sh "cd ../orchestration/profiles; git clone -b ${branch} ${deployment_config.pod_config.repo_url} automation"
Luca Pretee2d51fd2017-08-31 16:19:21 -070073 }
74
75 stage ("Generate CORD configuration") {
Andy Bavier4775df22018-01-05 10:52:30 -070076 sh "make PODCONFIG_PATH=../orchestration/profiles/automation/${deployment_config.pod_config.file_name} config"
Luca Pretee2d51fd2017-08-31 16:19:21 -070077 }
78
You Wang1abf2bf2017-12-12 15:21:07 -080079 if (deployment_config.fabric_switches != null) {
Andy Bavier700f2662017-09-19 13:52:30 -070080 stage("Reserve IPs for fabric switches") {
You Wang1abf2bf2017-12-12 15:21:07 -080081 for(int i=0; i < deployment_config.fabric_switches.size(); i++) {
82 def str = createMACIPbindingStr("fabric", i+1,
83 "${deployment_config.fabric_switches[i].mac}",
84 "${deployment_config.fabric_switches[i].ip}")
Andy Bavier700f2662017-09-19 13:52:30 -070085 sh "echo $str >> maas/roles/maas/files/dhcpd.reservations"
86 }
87 }
88 }
89
Luca Pretee2d51fd2017-08-31 16:19:21 -070090 stage ("Deploy") {
Luca Prete614d6702017-10-18 11:52:55 -070091 sh "make build"
Luca Pretee2d51fd2017-08-31 16:19:21 -070092 }
93
You Wang1abf2bf2017-12-12 15:21:07 -080094 if (deployment_config.compute_nodes != null) {
Luca Pretee2095272017-10-17 11:47:26 -070095 stage ("Power cycle compute nodes") {
You Wang1abf2bf2017-12-12 15:21:07 -080096 for(int i=0; i < deployment_config.compute_nodes.size(); i++) {
97 sh "ipmitool -U ${deployment_config.compute_nodes[i].ipmi.user} -P ${deployment_config.compute_nodes[i].ipmi.pass} -H ${deployment_config.compute_nodes[i].ipmi.ip} power cycle"
Luca Pretee2095272017-10-17 11:47:26 -070098 }
99 }
100
101 stage ("Wait for compute nodes to get deployed") {
You Wang1abf2bf2017-12-12 15:21:07 -0800102 sh "ssh-keygen -f /home/${deployment_config.dev_node.user}/.ssh/known_hosts -R ${deployment_config.head.ip}"
103 def cordApiKey = runHeadNodeCmd("sudo maas-region-admin apikey --username ${deployment_config.head.user}")
104 runHeadNodeCmd("maas login pod-maas http://${deployment_config.head.ip}/MAAS/api/1.0 ${cordApiKey}")
Luca Prete49c818c2017-10-24 17:22:09 -0700105 timeout(time: 90) {
Luca Pretee2095272017-10-17 11:47:26 -0700106 waitUntil {
107 try {
You Wang1abf2bf2017-12-12 15:21:07 -0800108 num = runHeadNodeCmd("maas pod-maas nodes list | grep substatus_name | grep -i deployed | wc -l").trim()
109 return num.toInteger() == deployment_config.compute_nodes.size()
Luca Pretee2095272017-10-17 11:47:26 -0700110 } catch (exception) {
111 return false
112 }
Luca Pretee2d51fd2017-08-31 16:19:21 -0700113 }
114 }
115 }
Luca Pretee2d51fd2017-08-31 16:19:21 -0700116
Luca Pretee2095272017-10-17 11:47:26 -0700117 stage ("Wait for compute nodes to be provisioned") {
118 timeout(time:45) {
119 waitUntil {
120 try {
You Wang1abf2bf2017-12-12 15:21:07 -0800121 num = runHeadNodeCmd("cord prov list | grep -i node | grep -i complete | wc -l").trim()
122 return num.toInteger() == deployment_config.compute_nodes.size()
Luca Pretee2095272017-10-17 11:47:26 -0700123 } catch (exception) {
124 return false
125 }
Luca Pretee2d51fd2017-08-31 16:19:21 -0700126 }
127 }
128 }
Luca Pretee2095272017-10-17 11:47:26 -0700129 }
Luca Pretee2d51fd2017-08-31 16:19:21 -0700130
You Wang1abf2bf2017-12-12 15:21:07 -0800131 if (deployment_config.fabric_switches != null) {
Luca Pretee2d51fd2017-08-31 16:19:21 -0700132 stage ("Wait for fabric switches to get deployed") {
You Wang1abf2bf2017-12-12 15:21:07 -0800133 runFabricSwitchCmdAll("sudo onl-onie-boot-mode install")
134 runFabricSwitchCmdAll("sudo reboot")
Andy Bavier700f2662017-09-19 13:52:30 -0700135 // Ensure that switches get provisioned after ONIE reinstall.
136 // Delete them if they were provisioned earlier. If the switches are not
137 // present in 'cord prov list', this command has no effect.
You Wang1abf2bf2017-12-12 15:21:07 -0800138 for(int i=0; i < deployment_config.fabric_switches.size(); i++) {
139 runHeadNodeCmd("cord prov delete ${deployment_config.fabric_switches[i].mac}")
Luca Pretee2d51fd2017-08-31 16:19:21 -0700140 }
141 timeout(time: 45) {
142 waitUntil {
143 try {
You Wang1abf2bf2017-12-12 15:21:07 -0800144 def harvestCompleted = runHeadNodeCmd("cord harvest list | grep -i fabric | wc -l").trim()
145 return harvestCompleted.toInteger() == deployment_config.fabric_switches.size()
Luca Pretee2d51fd2017-08-31 16:19:21 -0700146 } catch (exception) {
147 return false
148 }
149 }
150 }
151 }
152
153 stage ("Wait for fabric switches to be provisioned") {
154 timeout(time:45) {
155 waitUntil {
156 try {
157 def provCompleted = 0
You Wang1abf2bf2017-12-12 15:21:07 -0800158 for(int i=0; i < deployment_config.fabric_switches.size(); i++) {
159 def count = runHeadNodeCmd("cord prov list | grep -i ${deployment_config.fabric_switches[i].ip} | grep -i complete | wc -l").trim()
Luca Pretee2d51fd2017-08-31 16:19:21 -0700160 provCompleted = provCompleted + count.toInteger()
161 }
You Wang1abf2bf2017-12-12 15:21:07 -0800162 return provCompleted == deployment_config.fabric_switches.size()
Luca Pretee2d51fd2017-08-31 16:19:21 -0700163 } catch (exception) {
164 return false
165 }
166 }
167 }
168 }
Marc De Leenheer672afa82017-11-27 17:25:09 -0800169
You Wang1abf2bf2017-12-12 15:21:07 -0800170 // Post installation configuration starts here
171 fabricIpPrefix = pod_config.fabric_ip.split(/\.\d+\.\d+\/24/)[0]
172 xosUser = "xosadmin@opencord.org"
173 xosPass = runHeadNodeCmd("cat /opt/credentials/xosadmin@opencord.org").trim()
174 stage ("Connect fabric switches and compute nodes to ONOS") {
175 // Configure breakout ports
176 for(int i=0; i < deployment_config.fabric_switches.size(); i++) {
177 if (deployment_config.fabric_switches[i].breakout_ports != null) {
178 for(int j=0; j < deployment_config.fabric_switches[i].breakout_ports.size(); j++) {
179 runFabricSwitchCmd("${deployment_config.fabric_switches[i].ip}",
180 "${deployment_config.fabric_switches[i].user}",
181 "${deployment_config.fabric_switches[i].pass}",
You Wangd1d67aa2017-12-13 11:18:54 -0800182 "sed -i -e 's/#port_mode_${deployment_config.fabric_switches[i].breakout_ports[j]}=/port_mode_${deployment_config.fabric_switches[i].breakout_ports[j]}=/g' /etc/accton/ofdpa.conf")
Marc De Leenheer672afa82017-11-27 17:25:09 -0800183 }
You Wang1abf2bf2017-12-12 15:21:07 -0800184 }
185 }
186 connectFabricAndComputeToOnos()
187 }
188 stage ("Configure the compute nodes") {
189 leafSwitchNum = 0
190 for(int i=0; i < deployment_config.fabric_switches.size(); i++) {
You Wangd37a1732017-12-14 15:29:11 -0800191 if(deployment_config.fabric_switches[i].containsKey("role")) {
You Wangdd8793e2017-12-14 15:03:36 -0800192 if(deployment_config.fabric_switches[i].role.toLowerCase().contains("leaf")) {
193 leafSwitchNum += 1
194 }
You Wang1abf2bf2017-12-12 15:21:07 -0800195 }
196 }
You Wang1abf2bf2017-12-12 15:21:07 -0800197 for(int i=1; i<=leafSwitchNum; i++) {
198 // Figure out which compute node connects to which switch
199 leafName = "leaf-" + i.toString()
200 computeNames = getComputeNames(leafName)
201 echo "Compute nodes connnected to " + leafName + " switch:"
202 for(name in computeNames) { echo "${name}" }
203 index = 1
204 for(name in computeNames) {
205 if(i>1) {
206 //Update fabric IP of compute nodes
207 index += 1
208 fabricIp = runComputeNodeCmd("${name}", "ip a | grep -o '${fabricIpPrefix}.[1-9][0-9]*.[0-9]*/24'").trim()
209 if (fabricIp != "") {
210 nodeId = sh(returnStdout: true, script: "curl -u ${xosUser}:${xosPass} -X GET http://${deployment_config.head.ip}/xosapi/v1/core/nodes | jq '.[\"items\"][] | select(.dataPlaneIp==\"${fabricIp}\") | .id'").trim()
211 newFabricIp = "${fabricIpPrefix}." + i.toString() + "." + index.toString() + "/24"
212 out = sh(returnStdout: true, script: "curl -u ${xosUser}:${xosPass} -X PUT -d '{\"dataPlaneIp\":\"${newFabricIp}\"}' http://${deployment_config.head.ip}/xosapi/v1/core/nodes/${nodeId}").trim()
213 // Wait until the new fabric IP gets configured
214 timeout(time: 5) {
215 waitUntil {
216 try {
217 num = runComputeNodeCmd("${name}", "ip a | grep " + newFabricIp + " | wc -l").trim()
218 return num.toInteger() == 1
219 } catch (exception) {
220 return false
221 }
222 }
223 }
224 }
225 else echo "Cannot find fabric IP matching pattern ${fabricIpPrefix}.[1-9][0-9]*.[0-9]*"
226 }
227 //Add routes to fabric subnets
228 for(int j=1; j<=leafSwitchNum; j++) {
229 if(j!=i) {
230 runComputeNodeCmd("${name}", "sudo ip route add ${fabricIpPrefix}." + j.toString() + ".0/24 via ${fabricIpPrefix}." + i.toString() + ".254 || echo route already exists")
231 }
232 }
233 }
234 }
235 }
236 stage ("Generate and load network configuration") {
237 // Reconnect compute nodes to update the fabric IP in ONOS
238 connectFabricAndComputeToOnos()
You Wang3771c7f2018-02-06 15:52:36 -0800239 // Refresh fabric configurations
240 sh "make fabric-refresh"
Marc De Leenheer672afa82017-11-27 17:25:09 -0800241 }
Luca Pretee2d51fd2017-08-31 16:19:21 -0700242 }
Luca Pretee2d51fd2017-08-31 16:19:21 -0700243 }
Luca Pretefcbc54b2017-09-12 14:37:33 -0700244
You Wang1abf2bf2017-12-12 15:21:07 -0800245 if (deployment_config.make_release == true) {
Luca Pretefcbc54b2017-09-12 14:37:33 -0700246 stage ("Trigger Build") {
247 url = 'https://jenkins.opencord.org/job/release-build/job/' + params.branch + '/build'
248 httpRequest authentication: 'auto-release', httpMode: 'POST', url: url, validResponseCodes: '201'
249 }
250 }
251
252 currentBuild.result = 'SUCCESS'
253 } catch (err) {
254 currentBuild.result = 'FAILURE'
255 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
256 } finally {
257 sh "make -C build clean-all || true"
258 sh "rm -rf *"
259 }
260 echo "RESULT: ${currentBuild.result}"
Luca Pretee2d51fd2017-08-31 16:19:21 -0700261 }
262}
263
264/**
265 * Returns a string used to bind IPs and MAC addresses, substituting the values
266 * given.
267 *
You Wang1abf2bf2017-12-12 15:21:07 -0800268 * @param word the word used to generate the host name
Luca Pretee2d51fd2017-08-31 16:19:21 -0700269 * @param counter the counter used to generate the host name
270 * @param mac the MAC address to substitute
271 * @param ip the IP address to substitute
272 */
You Wang1abf2bf2017-12-12 15:21:07 -0800273def createMACIPbindingStr(word, counter, mac, ip) {
274 return """host ${word}-${counter} {'\n'hardware ethernet ${mac}';''\n'fixed-address ${ip}';''\n'}"""
Luca Pretee2d51fd2017-08-31 16:19:21 -0700275}
276
277/**
278 * Runs a command on a remote host using sshpass.
279 *
280 * @param ip the node IP address
281 * @param user the node user name
282 * @param pass the node password
283 * @param command the command to run
You Wang1abf2bf2017-12-12 15:21:07 -0800284 * @param sshArgs arguments for the ssh command
Luca Pretee2d51fd2017-08-31 16:19:21 -0700285 * @return the output of the command
286 */
You Wang1abf2bf2017-12-12 15:21:07 -0800287def runCmd(ip, user, pass, command, sshArgs="") {
288 return sh(returnStdout: true, script: "sshpass -p ${pass} ssh ${sshArgs} -oStrictHostKeyChecking=no -l ${user} ${ip} \"${command}\"")
289}
290
291/**
292 * Runs a command on the head node.
293 *
294 * @param command the command to run
295 * @param sshArgs arguments for the ssh command
296 * @return the output of the command
297 */
298def runHeadNodeCmd(command, sshArgs="") {
299 return sh(returnStdout: true, script: "sshpass -p ${deployment_config.head.pass} ssh ${sshArgs} -oStrictHostKeyChecking=no -l ${deployment_config.head.user} ${deployment_config.head.ip} \"${command}\"")
Luca Pretee2d51fd2017-08-31 16:19:21 -0700300}
301
302/**
303 * Runs a command on a fabric switch.
304 *
You Wang1abf2bf2017-12-12 15:21:07 -0800305 * @param ip the mgmt IP of the fabric switch, reachable from the head node
306 * @param user the mgmt user name of the fabric switch
307 * @param pass the mgmt password of the fabric switch
308 * @param command the command to run on the fabric switch
309 * @param ssgArgs arguments for the ssh command
Luca Pretee2d51fd2017-08-31 16:19:21 -0700310 * @return the output of the command
311 */
You Wang1abf2bf2017-12-12 15:21:07 -0800312def runFabricSwitchCmd(ip, user, pass, command, sshArgs="") {
313 return sh(returnStdout: true, script: "sshpass -p ${deployment_config.head.pass} ssh ${sshArgs} -oStrictHostKeyChecking=no -l ${deployment_config.head.user} ${deployment_config.head.ip} \"sshpass -p ${pass} ssh ${sshArgs} -oStrictHostKeyChecking=no -l ${user} ${ip} ${command}\"")
314}
315
316/**
317 * Runs a command on all fabric switches
318 *
319 * @param command the command to run on the fabric switches
320 * @param ssgArgs arguments for the ssh command
321 */
322def runFabricSwitchCmdAll(command, sshArgs="") {
323 for(int i=0; i < deployment_config.fabric_switches.size(); i++) {
324 runFabricSwitchCmd("${deployment_config.fabric_switches[i].ip}",
325 "${deployment_config.fabric_switches[i].user}",
326 "${deployment_config.fabric_switches[i].pass}",
327 "${command}",
328 "${sshArgs}")
329 }
330}
331
332/**
333 * Runs a command on a compute node.
334 *
335 * @param name the name of the compute node
336 * @param command the command to run on the compute node
337 * @param ssgArgs arguments for the ssh command
338 * @return the output of the command
339 */
340def runComputeNodeCmd(name, command, sshArgs="") {
341 return sh(returnStdout: true, script: "sshpass -p ${deployment_config.head.pass} ssh ${sshArgs} -oStrictHostKeyChecking=no -l ${deployment_config.head.user} ${deployment_config.head.ip} \"ssh ${sshArgs} ubuntu@${name} ${command}\"")
342}
343
344/**
345 * Runs a command on all compute nodes
346 *
347 * @param command the command to run on the compute nodes
348 * @param ssgArgs arguments for the ssh command
349 */
350def runComputeNodeCmdAll(command, sshArgs="") {
351 computeNamesAll = getComputeNames()
352 for (name in computeNamesAll) {
353 runComputeNodeCmd("${name}", "${command}", "${sshArgs}")
354 }
355}
356
357/**
358 * Runs an ONOS CLI command
359 *
360 * @param name the onos node name, reachable from the head node
361 * @param port the port used to login to ONOS CLI
362 * @param user the user name to login to ONOS CLI
363 * @param pass the password to login to ONOS CLI
364 * @param command the command to run in ONOS CLI
365 * @return the output of the command
366 */
367def runOnosCliCmd(name, port, user, pass, command) {
368 return sh(returnStdout: true, script: "sshpass -p ${deployment_config.head.pass} ssh -oStrictHostKeyChecking=no -l ${deployment_config.head.user} ${deployment_config.head.ip} \"sshpass -p ${pass} ssh -oStrictHostKeyChecking=no -l ${user} -p ${port} ${name} ${command}\"")
369}
370
371/**
372 * Returns a list of compute node names. When "role" is specified, returns only
373 * names of compute nodes connected to the switch
374 *
375 * @param role the switch role, i.e. "leaf-1"
376 */
377def getComputeNames(role="") {
378 computeNamesAll = runHeadNodeCmd("cord prov list | grep node | awk '{print \\\$2}' | sed -e \\\"s/.*/'&'/\\\"").trim()
379 computeNamesAll = "${computeNamesAll}".split()
380 computeNamesAll = "${computeNamesAll}".replaceAll("'", "\"")
Kailash Khalasiea9bea12018-05-08 12:01:11 -0700381 computeNamesAll = new JsonSlurper().parseText("${computeNamesAll}")
You Wang1abf2bf2017-12-12 15:21:07 -0800382 if ("${role}" == "") return computeNamesAll
383 computeNames = []
384 switchMac = ""
385 for(int i=0; i < deployment_config.fabric_switches.size(); i++) {
You Wangd37a1732017-12-14 15:29:11 -0800386 if(deployment_config.fabric_switches[i].containsKey("role")) {
387 if ("${deployment_config.fabric_switches[i].role}" == "${role}")
388 switchMac = "${deployment_config.fabric_switches[i].mac}"
389 }
You Wang1abf2bf2017-12-12 15:21:07 -0800390 }
391 if ("${switchMac}" != "") {
392 switchMac = switchMac.toLowerCase().replaceAll(':','')
393 // Get fabric IPs of compute nodes connected to the switch
You Wang22e48862017-12-22 11:04:29 -0800394 try {
You Wang2e11a4b2018-02-01 13:10:37 -0800395 computeFabricIps = runHeadNodeCmd("sshpass -p rocks ssh -q -oStrictHostKeyChecking=no -l onos -p 8101 onos-fabric hosts -j | jq '.[] | select(.locations[].elementId | contains(\\\"${switchMac}\\\")) | .ipAddresses' | grep -o '\\\"${fabricIpPrefix}.[1-9][0-9]*.[0-9]*\\\"'",
You Wang22e48862017-12-22 11:04:29 -0800396 "-q").trim()
397 }catch (exception) {
398 return computeNames
399 }
You Wang1abf2bf2017-12-12 15:21:07 -0800400 computeFabricIps = "${computeFabricIps}".split()
Kailash Khalasiea9bea12018-05-08 12:01:11 -0700401 computeFabricIps = new JsonSlurper().parseText("${computeFabricIps}")
You Wang1abf2bf2017-12-12 15:21:07 -0800402 // Figure out which compute node connects to the switch
403 for (name in computeNamesAll) {
404 fabricIp = runComputeNodeCmd("${name}", "ip a | grep -o '${fabricIpPrefix}.[1-9][0-9]*.[0-9]*'").trim()
405 if (fabricIp in computeFabricIps) {
406 computeNames.add("${name}")
407 }
408 }
409 }
410 return computeNames
411}
412
413/**
414 * Connects all fabric switches and compute nodes to ONOS
415 */
416def connectFabricAndComputeToOnos() {
417 // Kill existing switch connections
418 runFabricSwitchCmdAll("./killit || echo no ofagentapp running")
419 // Clean stale ONOS data
420 runOnosCliCmd("onos-fabric", "8101", "onos", "rocks", "wipe-out -r -j please")
421 // Connect switches to ONOS
422 for(int i=0; i < deployment_config.fabric_switches.size(); i++) {
423 runFabricSwitchCmd("${deployment_config.fabric_switches[i].ip}",
424 "${deployment_config.fabric_switches[i].user}",
425 "${deployment_config.fabric_switches[i].pass}",
426 "./connect -bg 2>&1 > ${deployment_config.fabric_switches[i].ip}.log",
427 "-qftn")
428 }
429 // Verify ONOS has recognized the switches
430 timeout(time: 5) {
431 waitUntil {
432 try {
433 num = runHeadNodeCmd("\"sshpass -p rocks ssh -q -oStrictHostKeyChecking=no -l onos -p 8101 onos-fabric devices | grep available=true | wc -l\"").trim()
434 return num.toInteger() == deployment_config.fabric_switches.size()
435 } catch (exception) {
436 return false
437 }
438 }
439 }
440 // Connect compute nodes to ONOS
You Wang1abf2bf2017-12-12 15:21:07 -0800441 runComputeNodeCmdAll("ping -c 1 ${fabricIpPrefix}.1.254", "-qftn")
442 // Verify ONOS has recognized the hosts
443 timeout(time: 5) {
444 waitUntil {
445 try {
446 num = runHeadNodeCmd("\"sshpass -p rocks ssh -q -oStrictHostKeyChecking=no -l onos -p 8101 onos-fabric hosts | grep id= | wc -l\"").trim()
You Wang97bf12e2018-01-24 12:05:39 -0800447 return num.toInteger() >= deployment_config.compute_nodes.size()
You Wang1abf2bf2017-12-12 15:21:07 -0800448 } catch (exception) {
449 return false
450 }
451 }
452 }
Luca Pretee2d51fd2017-08-31 16:19:21 -0700453}
Kailash Khalasiea9bea12018-05-08 12:01:11 -0700454