blob: 701be97034ea200047dd56b3c5b4cebf1c2defb3 [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
Joey Armstrong6c0b8552023-06-28 17:41:48 -040028// -----------------------------------------------------------------------
29// -----------------------------------------------------------------------
30def getIam(String func)
31{
32 // Cannot rely on a stack trace due to jenkins manipulation
33 String src = 'jjb/pipeline/playground/physical-build.groovy'
34 String iam = [src, func].join('::')
35 return iam
36}
37
Joey Armstrong980e37f2023-02-28 18:57:41 -050038def infraNamespace = "infra"
39def volthaNamespace = "voltha"
40
Joey Armstrongdf24f602023-03-02 18:18:21 -050041// -----------------------------------------------------------------------
Joey Armstrongdf24f602023-03-02 18:18:21 -050042// -----------------------------------------------------------------------
Joey Armstrong980e37f2023-02-28 18:57:41 -050043def deploy_custom_oltAdapterChart(namespace, name, chart, extraHelmFlags) {
Joey Armstrong6c0b8552023-06-28 17:41:48 -040044 String iam = getIam('deploy_custom_oltAdapterChart')
45 println("** ${iam}: ENTER")
46
47 sh """
Joey Armstrong980e37f2023-02-28 18:57:41 -050048 helm install --create-namespace --set defaults.image_pullPolicy=Always --namespace ${namespace} ${extraHelmFlags} ${name} ${chart}
49 """
Joey Armstrong6c0b8552023-06-28 17:41:48 -040050
51 println("** ${iam}: LEAVE")
52 return
Joey Armstrong980e37f2023-02-28 18:57:41 -050053}
54
Joey Armstrongdf24f602023-03-02 18:18:21 -050055pipeline
56{
57 /* no label, executor is determined by JJB */
58 agent
59 {
Joey Armstrong1fa8cb82023-03-03 14:05:51 -050060 label "${params.buildNode}"
Joey Armstrong980e37f2023-02-28 18:57:41 -050061 }
Joey Armstrongdf24f602023-03-02 18:18:21 -050062
63 options
64 {
Joey Armstrong1fa8cb82023-03-03 14:05:51 -050065 timeout(time: 35, unit: 'MINUTES')
Joey Armstrongdf24f602023-03-02 18:18:21 -050066 }
67
68 environment
69 {
Joey Armstrong1fa8cb82023-03-03 14:05:51 -050070 PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
71 KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf"
Joey Armstrongdf24f602023-03-02 18:18:21 -050072 }
73
74 stages
75 {
Joey Armstrong1fa8cb82023-03-03 14:05:51 -050076 stage('Download Code')
77 {
Joey Armstrong0c689df2023-03-03 16:03:50 -050078 steps
Joey Armstrong1fa8cb82023-03-03 14:05:51 -050079 {
Joey Armstrong9ed18e12023-03-07 10:40:14 -050080 iam
Joey Armstrong0c689df2023-03-03 16:03:50 -050081 {
82 enter = true
83 label = getIam()
84 }
Joey Armstrongdf24f602023-03-02 18:18:21 -050085
Joey Armstrong1fa8cb82023-03-03 14:05:51 -050086 getVolthaCode([
87 branch: "${branch}",
88 volthaSystemTestsChange: "${volthaSystemTestsChange}",
89 volthaHelmChartsChange: "${volthaHelmChartsChange}",
90 ])
Joey Armstrongdf24f602023-03-02 18:18:21 -050091
Joey Armstrong9ed18e12023-03-07 10:40:14 -050092 iam
Joey Armstrong0c689df2023-03-03 16:03:50 -050093 {
94 leave = true
95 label = getIam()
96 }
Joey Armstrong1fa8cb82023-03-03 14:05:51 -050097 }
98 }
Joey Armstrongdf24f602023-03-02 18:18:21 -050099
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500100 stage ("Parse deployment configuration file") {
101 steps {
102 sh returnStdout: true, script: "rm -rf ${configBaseDir}"
103 sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
104 script {
105 String conf = "${configBaseDir}/${configDeploymentDir}/${configFileName}"
106 String flow = params.workFlow
Joey Armstrongdf24f602023-03-02 18:18:21 -0500107
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500108 conf += (flow == 'DT') ? '-DT.yaml'
109 : (flow == 'TT') ? '-TT.yaml'
110 : '.yaml'
111
112 deployment_config = readYaml file: conf
113
114 /*
115 if ( params.workFlow == "DT" )
116 {
117 conf += '-DT.yaml'
Joey Armstrongdf24f602023-03-02 18:18:21 -0500118// deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
Joey Armstrong980e37f2023-02-28 18:57:41 -0500119 }
120 else if ( params.workFlow == "TT" )
121 {
122 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
123 }
124 else
125 {
126 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
127 }
Joey Armstrong1fa8cb82023-03-03 14:05:51 -0500128 */
Joey Armstrong980e37f2023-02-28 18:57:41 -0500129 }
130 }
131 }
Joey Armstrongdf24f602023-03-02 18:18:21 -0500132
Joey Armstrong980e37f2023-02-28 18:57:41 -0500133 stage('Clean up') {
134 steps {
135 timeout(15) {
136 script {
137 helmTeardown(["default", infraNamespace, volthaNamespace])
138 }
139 timeout(1) {
140 sh returnStdout: false, script: '''
141 # remove orphaned port-forward from different namespaces
142 ps aux | grep port-forw | grep -v grep | awk '{print $2}' | xargs --no-run-if-empty kill -9 || true
143 '''
144 }
145 }
146 }
147 }
148 stage('Install Voltha') {
149 steps {
150 timeout(20) {
151 installVoltctl("${branch}")
152 script {
153 // if we're downloading a voltha-helm-charts patch, then install from a local copy of the charts
154 def localCharts = false
155 if (volthaHelmChartsChange != "") {
156 localCharts = true
157 }
158
159 // should the config file be suffixed with the workflow? see "deployment_config"
160 def localHelmFlags = "-f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/voltha/${configFileName}.yml --set global.log_level=${logLevel} "
161
162 if (workFlow.toLowerCase() == "dt") {
163 localHelmFlags += " --set radius.enabled=false "
164 }
165 if (workFlow.toLowerCase() == "tt") {
166 localHelmFlags += " --set radius.enabled=false --set global.incremental_evto_update=true "
167 if (enableMultiUni.toBoolean()) {
168 localHelmFlags += " --set voltha-adapter-openonu.adapter_open_onu.uni_port_mask=${uniPortMask} "
169 }
170 }
171
172 // NOTE temporary workaround expose ONOS node ports (pod-config needs to be updated to contain these values)
173 // and to connect the ofagent to all instances of ONOS
174 localHelmFlags = localHelmFlags + " --set onos-classic.onosSshPort=30115 " +
175 "--set onos-classic.onosApiPort=30120 " +
176 "--set onos-classic.onosOfPort=31653 " +
177 "--set onos-classic.individualOpenFlowNodePorts=true " +
178 "--set voltha.onos_classic.replicas=${params.NumOfOnos}"
179
180 if (bbsimReplicas.toInteger() != 0) {
181 localHelmFlags = localHelmFlags + " --set onu=${onuNumber},pon=${ponNumber} "
182 }
183
184 // adding user specified helm flags at the end so they'll have priority over everything else
185 localHelmFlags = localHelmFlags + " ${extraHelmFlags}"
186
187 def numberOfAdaptersToWait = 2
188
189 if(openoltAdapterChart != "onf/voltha-adapter-openolt") {
190 localHelmFlags = localHelmFlags + " --set voltha-adapter-openolt.enabled=false"
191 // We skip waiting for adapters in the volthaDeploy step because it's already waiting for
192 // both of them after the deployment of the custom olt adapter. See line 156.
193 numberOfAdaptersToWait = 0
194 }
195
196 volthaDeploy([
197 workflow: workFlow.toLowerCase(),
198 extraHelmFlags: localHelmFlags,
199 localCharts: localCharts,
200 kubeconfig: "$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf",
201 onosReplica: params.NumOfOnos,
202 atomixReplica: params.NumOfAtomix,
203 kafkaReplica: params.NumOfKafka,
204 etcdReplica: params.NumOfEtcd,
205 bbsimReplica: bbsimReplicas.toInteger(),
206 withFttb: withFttb.toBoolean(),
207 adaptersToWait: numberOfAdaptersToWait,
208 ])
209
210 if(openoltAdapterChart != "onf/voltha-adapter-openolt"){
211 extraHelmFlags = extraHelmFlags + " --set global.log_level=${logLevel}"
212 deploy_custom_oltAdapterChart(volthaNamespace, oltAdapterReleaseName, openoltAdapterChart, extraHelmFlags)
213 waitForAdapters([
214 adaptersToWait: 2
215 ])
216 }
217 }
218 sh """
219 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"&
220 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"&
221 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"&
222 ps aux | grep port-forward
223 """
224 getPodsInfo("$WORKSPACE")
225 }
226 }
227 }
228 stage('Push Tech-Profile') {
229 steps {
230 script {
231 if ( params.configurePod && params.profile != "Default" ) {
232 for(int i=0; i < deployment_config.olts.size(); i++) {
233 def tech_prof_directory = "XGS-PON"
234 if (deployment_config.olts[i].containsKey("board_technology")){
235 tech_prof_directory = deployment_config.olts[i]["board_technology"]
236 }
237 timeout(1) {
238 sh returnStatus: true, script: """
239 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
240 etcd_container=\$(kubectl get pods -n ${infraNamespace} -l app.kubernetes.io/name=etcd --no-headers | awk 'NR==1{print \$1}')
241 if [[ "${workFlow}" == "TT" ]]; then
242 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-HSIA.json \$etcd_container:/tmp/hsia.json
243 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'
244 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-VoIP.json \$etcd_container:/tmp/voip.json
245 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'
246 if [[ "${params.enableMultiUni}" == "true" ]]; then
247 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
248 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'
249 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
250 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'
251 else
252 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-MCAST-AdditionalBW-None.json \$etcd_container:/tmp/mcast_additionalBW_none.json
253 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'
254 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-MCAST-AdditionalBW-NA.json \$etcd_container:/tmp/mcast_additionalBW_na.json
255 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'
256 fi
257 else
258 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-${profile}.json \$etcd_container:/tmp/flexpod.json
259 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'
260 fi
261 """
262 }
263 timeout(1) {
264 sh returnStatus: true, script: """
265 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
266 etcd_container=\$(kubectl get pods -n ${infraNamespace} -l app.kubernetes.io/name=etcd --no-headers | awk 'NR==1{print \$1}')
267 kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/${tech_prof_directory}/64'
268 """
269 }
270 }
271 }
272 }
273 }
274 }
275 stage('Push MIB templates') {
276 steps {
277 sh """
278 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
279 etcd_container=\$(kubectl get pods -n ${infraNamespace} -l app.kubernetes.io/name=etcd --no-headers | awk 'NR==1{print \$1}')
280 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/MIB_Alpha.json \$etcd_container:/tmp/MIB_Alpha.json
281 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'
282 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'
283 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/MIB_Scom.json \$etcd_container:/tmp/MIB_Scom.json
284 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'
285 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'
286 """
287 }
288 }
289 stage('Push Sadis-config') {
290 steps {
291 timeout(1) {
292 sh returnStatus: true, script: """
293 if [[ "${workFlow}" == "DT" ]]; then
294 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
295 elif [[ "${workFlow}" == "TT" ]]; then
296 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
297 else
298 # this is the ATT case, rename the file in *-sadis-ATT.json so that we can avoid special cases and just load the file
299 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
300 fi
301 """
302 }
303 }
304 }
305 stage('Switch Configurations in ONOS') {
306 steps {
307 script {
308 if ( deployment_config.fabric_switches.size() > 0 ) {
309 timeout(1) {
310 def netcfg = "$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch.json"
311 if (params.inBandManagement){
312 netcfg = "$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch-inband.json"
313 }
314 sh """
315 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}
316 curl -sSL --user karaf:karaf -X POST http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting/active
317 """
318 }
319 timeout(3) {
320 setOnosLogLevels([
321 onosNamespace: infraNamespace,
322 apps: [
323 'org.opencord.dhcpl2relay',
324 'org.opencord.olt',
325 'org.opencord.aaa',
326 'org.opencord.maclearner',
327 'org.onosproject.net.flowobjective.impl.FlowObjectiveManager',
328 'org.onosproject.net.flowobjective.impl.InOrderFlowObjectiveManager'
329 ]
330 ])
331 waitUntil {
332 sr_active_out = sh returnStatus: true, script: """
333 curl -sSL --user karaf:karaf -X GET http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting | jq '.state' | grep ACTIVE
334 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"
335 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"
336 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"
337 """
338 return sr_active_out == 0
339 }
340 }
341 timeout(8) {
342 for(int i=0; i < deployment_config.hosts.src.size(); i++) {
343 for(int j=0; j < deployment_config.olts.size(); j++) {
344 def aggPort = -1
345 if(deployment_config.olts[j].serial == deployment_config.hosts.src[i].olt){
346 aggPort = deployment_config.olts[j].aggPort
347 if(aggPort == -1){
348 throw new Exception("Upstream port for the olt is not configured, field aggPort is empty")
349 }
350 sh """
351 sleep 10 # NOTE why are we sleeping?
352 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'
353 """
354 }
355 }
356 }
357 }
358 }
359 }
360 }
361 }
362 stage('Reinstall OLT software') {
363 steps {
364 script {
365 if ( params.reinstallOlt ) {
366 for(int i=0; i < deployment_config.olts.size(); i++) {
367 // NOTE what is oltDebVersion23? is that for VOLTHA-2.3? do we still need this differentiation?
368 sh returnStdout: true, script: """
369 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
370 if [ "${params.inBandManagement}" == "true" ]; then
371 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'
372 fi
373 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}"
374 sleep 10
375 """
376 timeout(5) {
377 waitUntil {
378 olt_sw_present = sh returnStdout: true, script: """
379 if [[ "${deployment_config.olts[i].oltDebVersion}" == *"asfvolt16"* ]]; then
380 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'
381 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"asgvolt64"* ]]; then
382 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'
383 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-1600x-w"* ]]; then
384 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'
385 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-1600g-w"* ]]; then
386 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'
387 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-3200g-w"* ]]; then
388 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'
389 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"sda3016ss"* ]]; then
390 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'
391 else
392 echo Unknown Debian package for openolt
393 fi
394 if (${deployment_config.olts[i].fortygig}); then
395 if [[ "${params.inBandManagement}" == "true" ]]; then
396 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
397 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'mkdir -p /opt/openolt/'
398 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/'
399 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'
400 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/'
401 fi
402 fi
403 """
404 return olt_sw_present.toInteger() > 0
405 }
406 }
407 }
408 }
409 }
410 }
411 }
412 stage('Restart OLT processes') {
413 steps {
414 script {
415 //rebooting OLTs
416 for(int i=0; i < deployment_config.olts.size(); i++) {
417 timeout(15) {
418 sh returnStdout: true, script: """
419 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
420 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
421 """
422 }
423 }
424 sh returnStdout: true, script: """
425 sleep ${params.waitTimerForOltUp}
426 """
427 //Checking dev_management_deamon and openoltprocesses
428 for(int i=0; i < deployment_config.olts.size(); i++) {
429 if ( params.oltAdapterReleaseName != "open-olt" ) {
430 timeout(15) {
431 waitUntil {
432 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'"
433 return devprocess.toInteger() > 0
434 }
435 }
436 timeout(15) {
437 waitUntil {
438 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'"
439 return openoltprocess.toInteger() > 0
440 }
441 }
442 }
443 }
444 }
445 }
446 }
447 }
448
449 post {
450 aborted {
451 getPodsInfo("$WORKSPACE/failed")
452 sh """
453 kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/failed/voltha.log || true
454 """
455 archiveArtifacts artifacts: '**/*.log,**/*.txt'
456 }
457 failure {
458 getPodsInfo("$WORKSPACE/failed")
459 sh """
460 kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/failed/voltha.logs || true
461 """
462 archiveArtifacts artifacts: '**/*.log,**/*.txt'
463 }
464 always {
465 archiveArtifacts artifacts: '*.txt'
466 }
467 }
468}