blob: 856006e7301292b7249f082655e9cd6c9f1ba59c [file] [log] [blame]
Joey Armstrongdf24f602023-03-02 18:18:21 -05001// -*- groovy -*-
Joey Armstrong1fa8cb82023-03-03 14:05:51 -05002// -----------------------------------------------------------------------
Joey Armstrong980e37f2023-02-28 18:57:41 -05003// Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
Joey Armstrongdf24f602023-03-02 18:18:21 -050016// -----------------------------------------------------------------------
17// Intent: used to deploy VOLTHA and configure ONOS physical PODs
18// -----------------------------------------------------------------------
Joey Armstrong980e37f2023-02-28 18:57:41 -050019
20// NOTE we are importing the library even if it's global so that it's
21// easier to change the keywords during a replay
22library identifier: 'cord-jenkins-libraries@master',
23 retriever: modernSCM([
24 $class: 'GitSCMSource',
25 remote: 'https://gerrit.opencord.org/ci-management.git'
26])
27
28def infraNamespace = "infra"
29def volthaNamespace = "voltha"
30
Joey Armstrongdf24f602023-03-02 18:18:21 -050031// -----------------------------------------------------------------------
Joey Armstrong1fa8cb82023-03-03 14:05:51 -050032// Intent: Visible in jenkins UI, job configure screen
Joey Armstrongdf24f602023-03-02 18:18:21 -050033// -----------------------------------------------------------------------
34def getIam(String func)
35{
Joey Armstrong0c689df2023-03-03 16:03:50 -050036 /*
37 [TODO]
38 -----------------------------------------------------------------------
39 java stack trace is hosed due to jenkins internal meddeling to support
40 serializable. Lets see if groovy Throwable wrapper can produce a
41 better answer.
42 -----------------------------------------------------------------------
43
44 try
45 {
46 throw new Exception('Generating a stacktrace')
47 }
48 catch (Throwable err)
49 {
50 // https://docs.groovy-lang.org/2.4.7/html/api/org/codehaus/groovy/GroovyException.html
51 err.printStackTrace()
52 stack = err.getStackTrace()
53 }
54
Joey Armstrongdf24f602023-03-02 18:18:21 -050055 // Cannot rely on a stack trace due to jenkins manipulation
56 String src = [
Joey Armstrong1fa8cb82023-03-03 14:05:51 -050057 'jjb',
58 'pipeline',
59 'voltha',
60 'playground',
Joey Armstrong0c689df2023-03-03 16:03:50 -050061 'physical-build.groovy'
Joey Armstrongdf24f602023-03-02 18:18:21 -050062 ].join('/')
Joey Armstrong1fa8cb82023-03-03 14:05:51 -050063
Joey Armstrongdf24f602023-03-02 18:18:21 -050064 String iam = [src, func].join('::')
Joey Armstrong1fa8cb82023-03-03 14:05:51 -050065 iam += sprintf('[ver:1.0]')
Joey Armstrongdf24f602023-03-02 18:18:21 -050066 return iam
67}
68
69// -----------------------------------------------------------------------
70// -----------------------------------------------------------------------
Joey Armstrong980e37f2023-02-28 18:57:41 -050071def deploy_custom_oltAdapterChart(namespace, name, chart, extraHelmFlags) {
72 sh """
73 helm install --create-namespace --set defaults.image_pullPolicy=Always --namespace ${namespace} ${extraHelmFlags} ${name} ${chart}
74 """
75}
76
Joey Armstrongdf24f602023-03-02 18:18:21 -050077pipeline
78{
79 /* no label, executor is determined by JJB */
80 agent
81 {
Joey Armstrong1fa8cb82023-03-03 14:05:51 -050082 label "${params.buildNode}"
Joey Armstrong980e37f2023-02-28 18:57:41 -050083 }
Joey Armstrongdf24f602023-03-02 18:18:21 -050084
85 options
86 {
Joey Armstrong1fa8cb82023-03-03 14:05:51 -050087 timeout(time: 35, unit: 'MINUTES')
Joey Armstrongdf24f602023-03-02 18:18:21 -050088 }
89
90 environment
91 {
Joey Armstrong1fa8cb82023-03-03 14:05:51 -050092 PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
93 KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf"
Joey Armstrongdf24f602023-03-02 18:18:21 -050094 }
95
96 stages
97 {
Joey Armstrong1fa8cb82023-03-03 14:05:51 -050098 stage('Download Code')
99 {
Joey Armstrong0c689df2023-03-03 16:03:50 -0500100 steps
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500101 {
Joey Armstrong0c689df2023-03-03 16:03:50 -0500102 iam(this)
103 {
104 enter = true
105 label = getIam()
106 }
Joey Armstrongdf24f602023-03-02 18:18:21 -0500107
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500108 getVolthaCode([
109 branch: "${branch}",
110 volthaSystemTestsChange: "${volthaSystemTestsChange}",
111 volthaHelmChartsChange: "${volthaHelmChartsChange}",
112 ])
Joey Armstrongdf24f602023-03-02 18:18:21 -0500113
Joey Armstrong0c689df2023-03-03 16:03:50 -0500114 iam(this)
115 {
116 leave = true
117 label = getIam()
118 }
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500119 }
120 }
Joey Armstrongdf24f602023-03-02 18:18:21 -0500121
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500122 stage ("Parse deployment configuration file") {
123 steps {
124 sh returnStdout: true, script: "rm -rf ${configBaseDir}"
125 sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
126 script {
127 String conf = "${configBaseDir}/${configDeploymentDir}/${configFileName}"
128 String flow = params.workFlow
Joey Armstrongdf24f602023-03-02 18:18:21 -0500129
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500130 conf += (flow == 'DT') ? '-DT.yaml'
131 : (flow == 'TT') ? '-TT.yaml'
132 : '.yaml'
133
134 deployment_config = readYaml file: conf
135
136 /*
137 if ( params.workFlow == "DT" )
138 {
139 conf += '-DT.yaml'
Joey Armstrongdf24f602023-03-02 18:18:21 -0500140// deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
Joey Armstrong980e37f2023-02-28 18:57:41 -0500141 }
142 else if ( params.workFlow == "TT" )
143 {
144 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
145 }
146 else
147 {
148 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
149 }
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500150 */
Joey Armstrong980e37f2023-02-28 18:57:41 -0500151 }
152 }
153 }
Joey Armstrongdf24f602023-03-02 18:18:21 -0500154
Joey Armstrong980e37f2023-02-28 18:57:41 -0500155 stage('Clean up') {
156 steps {
157 timeout(15) {
158 script {
159 helmTeardown(["default", infraNamespace, volthaNamespace])
160 }
161 timeout(1) {
162 sh returnStdout: false, script: '''
163 # remove orphaned port-forward from different namespaces
164 ps aux | grep port-forw | grep -v grep | awk '{print $2}' | xargs --no-run-if-empty kill -9 || true
165 '''
166 }
167 }
168 }
169 }
170 stage('Install Voltha') {
171 steps {
172 timeout(20) {
173 installVoltctl("${branch}")
174 script {
175 // if we're downloading a voltha-helm-charts patch, then install from a local copy of the charts
176 def localCharts = false
177 if (volthaHelmChartsChange != "") {
178 localCharts = true
179 }
180
181 // should the config file be suffixed with the workflow? see "deployment_config"
182 def localHelmFlags = "-f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/voltha/${configFileName}.yml --set global.log_level=${logLevel} "
183
184 if (workFlow.toLowerCase() == "dt") {
185 localHelmFlags += " --set radius.enabled=false "
186 }
187 if (workFlow.toLowerCase() == "tt") {
188 localHelmFlags += " --set radius.enabled=false --set global.incremental_evto_update=true "
189 if (enableMultiUni.toBoolean()) {
190 localHelmFlags += " --set voltha-adapter-openonu.adapter_open_onu.uni_port_mask=${uniPortMask} "
191 }
192 }
193
194 // NOTE temporary workaround expose ONOS node ports (pod-config needs to be updated to contain these values)
195 // and to connect the ofagent to all instances of ONOS
196 localHelmFlags = localHelmFlags + " --set onos-classic.onosSshPort=30115 " +
197 "--set onos-classic.onosApiPort=30120 " +
198 "--set onos-classic.onosOfPort=31653 " +
199 "--set onos-classic.individualOpenFlowNodePorts=true " +
200 "--set voltha.onos_classic.replicas=${params.NumOfOnos}"
201
202 if (bbsimReplicas.toInteger() != 0) {
203 localHelmFlags = localHelmFlags + " --set onu=${onuNumber},pon=${ponNumber} "
204 }
205
206 // adding user specified helm flags at the end so they'll have priority over everything else
207 localHelmFlags = localHelmFlags + " ${extraHelmFlags}"
208
209 def numberOfAdaptersToWait = 2
210
211 if(openoltAdapterChart != "onf/voltha-adapter-openolt") {
212 localHelmFlags = localHelmFlags + " --set voltha-adapter-openolt.enabled=false"
213 // We skip waiting for adapters in the volthaDeploy step because it's already waiting for
214 // both of them after the deployment of the custom olt adapter. See line 156.
215 numberOfAdaptersToWait = 0
216 }
217
218 volthaDeploy([
219 workflow: workFlow.toLowerCase(),
220 extraHelmFlags: localHelmFlags,
221 localCharts: localCharts,
222 kubeconfig: "$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf",
223 onosReplica: params.NumOfOnos,
224 atomixReplica: params.NumOfAtomix,
225 kafkaReplica: params.NumOfKafka,
226 etcdReplica: params.NumOfEtcd,
227 bbsimReplica: bbsimReplicas.toInteger(),
228 withFttb: withFttb.toBoolean(),
229 adaptersToWait: numberOfAdaptersToWait,
230 ])
231
232 if(openoltAdapterChart != "onf/voltha-adapter-openolt"){
233 extraHelmFlags = extraHelmFlags + " --set global.log_level=${logLevel}"
234 deploy_custom_oltAdapterChart(volthaNamespace, oltAdapterReleaseName, openoltAdapterChart, extraHelmFlags)
235 waitForAdapters([
236 adaptersToWait: 2
237 ])
238 }
239 }
240 sh """
241 JENKINS_NODE_COOKIE="dontKillMe" _TAG="voltha-api" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n ${volthaNamespace} svc/voltha-voltha-api 55555:55555; done"&
242 JENKINS_NODE_COOKIE="dontKillMe" _TAG="etcd" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n ${infraNamespace} svc/voltha-infra-etcd ${params.VolthaEtcdPort}:2379; done"&
243 JENKINS_NODE_COOKIE="dontKillMe" _TAG="kafka" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n ${infraNamespace} svc/voltha-infra-kafka 9092:9092; done"&
244 ps aux | grep port-forward
245 """
246 getPodsInfo("$WORKSPACE")
247 }
248 }
249 }
250 stage('Push Tech-Profile') {
251 steps {
252 script {
253 if ( params.configurePod && params.profile != "Default" ) {
254 for(int i=0; i < deployment_config.olts.size(); i++) {
255 def tech_prof_directory = "XGS-PON"
256 if (deployment_config.olts[i].containsKey("board_technology")){
257 tech_prof_directory = deployment_config.olts[i]["board_technology"]
258 }
259 timeout(1) {
260 sh returnStatus: true, script: """
261 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
262 etcd_container=\$(kubectl get pods -n ${infraNamespace} -l app.kubernetes.io/name=etcd --no-headers | awk 'NR==1{print \$1}')
263 if [[ "${workFlow}" == "TT" ]]; then
264 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-HSIA.json \$etcd_container:/tmp/hsia.json
265 kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'cat /tmp/hsia.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/64'
266 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-VoIP.json \$etcd_container:/tmp/voip.json
267 kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'cat /tmp/voip.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/65'
268 if [[ "${params.enableMultiUni}" == "true" ]]; then
269 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-multi-uni-MCAST-AdditionalBW-None.json \$etcd_container:/tmp/mcast_additionalBW_none.json
270 kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'cat /tmp/mcast_additionalBW_none.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/66'
271 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-multi-uni-MCAST-AdditionalBW-NA.json \$etcd_container:/tmp/mcast_additionalBW_na.json
272 kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'cat /tmp/mcast_additionalBW_na.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/67'
273 else
274 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-MCAST-AdditionalBW-None.json \$etcd_container:/tmp/mcast_additionalBW_none.json
275 kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'cat /tmp/mcast_additionalBW_none.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/66'
276 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-MCAST-AdditionalBW-NA.json \$etcd_container:/tmp/mcast_additionalBW_na.json
277 kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'cat /tmp/mcast_additionalBW_na.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/67'
278 fi
279 else
280 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-${profile}.json \$etcd_container:/tmp/flexpod.json
281 kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'cat /tmp/flexpod.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/64'
282 fi
283 """
284 }
285 timeout(1) {
286 sh returnStatus: true, script: """
287 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
288 etcd_container=\$(kubectl get pods -n ${infraNamespace} -l app.kubernetes.io/name=etcd --no-headers | awk 'NR==1{print \$1}')
289 kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/${tech_prof_directory}/64'
290 """
291 }
292 }
293 }
294 }
295 }
296 }
297 stage('Push MIB templates') {
298 steps {
299 sh """
300 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
301 etcd_container=\$(kubectl get pods -n ${infraNamespace} -l app.kubernetes.io/name=etcd --no-headers | awk 'NR==1{print \$1}')
302 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/MIB_Alpha.json \$etcd_container:/tmp/MIB_Alpha.json
303 kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'cat /tmp/MIB_Alpha.json | ETCDCTL_API=3 etcdctl put service/voltha/omci_mibs/go_templates/BRCM/BVM4K00BRA0915-0083/5023_020O02414'
304 kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'cat /tmp/MIB_Alpha.json | ETCDCTL_API=3 etcdctl put service/voltha/omci_mibs/templates/BRCM/BVM4K00BRA0915-0083/5023_020O02414'
305 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/MIB_Scom.json \$etcd_container:/tmp/MIB_Scom.json
306 kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'cat /tmp/MIB_Scom.json | ETCDCTL_API=3 etcdctl put service/voltha/omci_mibs/go_templates/SCOM/Glasfaser-Modem/090140.1.0.304'
307 kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'cat /tmp/MIB_Scom.json | ETCDCTL_API=3 etcdctl put service/voltha/omci_mibs/templates/SCOM/Glasfaser-Modem/090140.1.0.304'
308 """
309 }
310 }
311 stage('Push Sadis-config') {
312 steps {
313 timeout(1) {
314 sh returnStatus: true, script: """
315 if [[ "${workFlow}" == "DT" ]]; then
316 curl -sSL --user karaf:karaf -X POST -H Content-Type:application/json http://${deployment_config.nodes[0].ip}:30120/onos/v1/network/configuration --data @$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-sadis-DT.json
317 elif [[ "${workFlow}" == "TT" ]]; then
318 curl -sSL --user karaf:karaf -X POST -H Content-Type:application/json http://${deployment_config.nodes[0].ip}:30120/onos/v1/network/configuration --data @$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-sadis-TT.json
319 else
320 # this is the ATT case, rename the file in *-sadis-ATT.json so that we can avoid special cases and just load the file
321 curl -sSL --user karaf:karaf -X POST -H Content-Type:application/json http://${deployment_config.nodes[0].ip}:30120/onos/v1/network/configuration --data @$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-sadis.json
322 fi
323 """
324 }
325 }
326 }
327 stage('Switch Configurations in ONOS') {
328 steps {
329 script {
330 if ( deployment_config.fabric_switches.size() > 0 ) {
331 timeout(1) {
332 def netcfg = "$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch.json"
333 if (params.inBandManagement){
334 netcfg = "$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch-inband.json"
335 }
336 sh """
337 curl -sSL --user karaf:karaf -X POST -H Content-Type:application/json http://${deployment_config.nodes[0].ip}:30120/onos/v1/network/configuration --data @${netcfg}
338 curl -sSL --user karaf:karaf -X POST http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting/active
339 """
340 }
341 timeout(3) {
342 setOnosLogLevels([
343 onosNamespace: infraNamespace,
344 apps: [
345 'org.opencord.dhcpl2relay',
346 'org.opencord.olt',
347 'org.opencord.aaa',
348 'org.opencord.maclearner',
349 'org.onosproject.net.flowobjective.impl.FlowObjectiveManager',
350 'org.onosproject.net.flowobjective.impl.InOrderFlowObjectiveManager'
351 ]
352 ])
353 waitUntil {
354 sr_active_out = sh returnStatus: true, script: """
355 curl -sSL --user karaf:karaf -X GET http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting | jq '.state' | grep ACTIVE
356 sshpass -p karaf ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@${deployment_config.nodes[0].ip} "cfg set org.onosproject.provider.lldp.impl.LldpLinkProvider enabled false"
357 sshpass -p karaf ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@${deployment_config.nodes[0].ip} "cfg set org.onosproject.net.flow.impl.FlowRuleManager purgeOnDisconnection false"
358 sshpass -p karaf ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@${deployment_config.nodes[0].ip} "cfg set org.onosproject.net.meter.impl.MeterManager purgeOnDisconnection false"
359 """
360 return sr_active_out == 0
361 }
362 }
363 timeout(8) {
364 for(int i=0; i < deployment_config.hosts.src.size(); i++) {
365 for(int j=0; j < deployment_config.olts.size(); j++) {
366 def aggPort = -1
367 if(deployment_config.olts[j].serial == deployment_config.hosts.src[i].olt){
368 aggPort = deployment_config.olts[j].aggPort
369 if(aggPort == -1){
370 throw new Exception("Upstream port for the olt is not configured, field aggPort is empty")
371 }
372 sh """
373 sleep 10 # NOTE why are we sleeping?
374 curl -X POST --user karaf:karaf --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"deviceId": "${deployment_config.fabric_switches[0].device_id}", "vlanId": "${deployment_config.hosts.src[i].s_tag}", "endpoints": [${deployment_config.fabric_switches[0].bngPort},${aggPort}]}' 'http://${deployment_config.nodes[0].ip}:30120/onos/segmentrouting/xconnect'
375 """
376 }
377 }
378 }
379 }
380 }
381 }
382 }
383 }
384 stage('Reinstall OLT software') {
385 steps {
386 script {
387 if ( params.reinstallOlt ) {
388 for(int i=0; i < deployment_config.olts.size(); i++) {
389 // NOTE what is oltDebVersion23? is that for VOLTHA-2.3? do we still need this differentiation?
390 sh returnStdout: true, script: """
391 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
392 if [ "${params.inBandManagement}" == "true" ]; then
393 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'kill -9 `pgrep -f "[b]ash /opt/openolt/openolt_dev_mgmt_daemon_process_watchdog"` || true'
394 fi
395 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} "dpkg --install ${deployment_config.olts[i].oltDebVersion}"
396 sleep 10
397 """
398 timeout(5) {
399 waitUntil {
400 olt_sw_present = sh returnStdout: true, script: """
401 if [[ "${deployment_config.olts[i].oltDebVersion}" == *"asfvolt16"* ]]; then
402 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'dpkg --list | grep asfvolt16 | wc -l'
403 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"asgvolt64"* ]]; then
404 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'dpkg --list | grep asgvolt64 | wc -l'
405 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-1600x-w"* ]]; then
406 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'dpkg --list | grep rlt-1600x-w | wc -l'
407 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-1600g-w"* ]]; then
408 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'dpkg --list | grep rlt-1600g-w | wc -l'
409 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-3200g-w"* ]]; then
410 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'dpkg --list | grep rlt-3200g-w | wc -l'
411 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"sda3016ss"* ]]; then
412 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'dpkg --list | grep sda3016ss | wc -l'
413 else
414 echo Unknown Debian package for openolt
415 fi
416 if (${deployment_config.olts[i].fortygig}); then
417 if [[ "${params.inBandManagement}" == "true" ]]; then
418 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
419 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'mkdir -p /opt/openolt/'
420 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'cp /root/watchdog-script/* /opt/openolt/'
421 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'cp /root/bal_cli_appl/example_user_appl /broadcom'
422 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'cp in-band-startup-script/* /etc/init.d/'
423 fi
424 fi
425 """
426 return olt_sw_present.toInteger() > 0
427 }
428 }
429 }
430 }
431 }
432 }
433 }
434 stage('Restart OLT processes') {
435 steps {
436 script {
437 //rebooting OLTs
438 for(int i=0; i < deployment_config.olts.size(); i++) {
439 timeout(15) {
440 sh returnStdout: true, script: """
441 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
442 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'rm -f /var/log/openolt.log; rm -f /var/log/dev_mgmt_daemon.log; rm -f /var/log/openolt_process_watchdog.log; reboot > /dev/null &' || true
443 """
444 }
445 }
446 sh returnStdout: true, script: """
447 sleep ${params.waitTimerForOltUp}
448 """
449 //Checking dev_management_deamon and openoltprocesses
450 for(int i=0; i < deployment_config.olts.size(); i++) {
451 if ( params.oltAdapterReleaseName != "open-olt" ) {
452 timeout(15) {
453 waitUntil {
454 devprocess = sh returnStdout: true, script: "sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'ps -ef | grep dev_mgmt_daemon | wc -l'"
455 return devprocess.toInteger() > 0
456 }
457 }
458 timeout(15) {
459 waitUntil {
460 openoltprocess = sh returnStdout: true, script: "sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'ps -ef | grep openolt | wc -l'"
461 return openoltprocess.toInteger() > 0
462 }
463 }
464 }
465 }
466 }
467 }
468 }
469 }
470
471 post {
472 aborted {
473 getPodsInfo("$WORKSPACE/failed")
474 sh """
475 kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/failed/voltha.log || true
476 """
477 archiveArtifacts artifacts: '**/*.log,**/*.txt'
478 }
479 failure {
480 getPodsInfo("$WORKSPACE/failed")
481 sh """
482 kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/failed/voltha.logs || true
483 """
484 archiveArtifacts artifacts: '**/*.log,**/*.txt'
485 }
486 always {
487 archiveArtifacts artifacts: '*.txt'
488 }
489 }
490}