blob: 80df9d58e200f0e80232a91ae5cddcf487bbae2a [file] [log] [blame]
Joey Armstrongbeef4cd2023-01-18 09:59:58 -05001// Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors
Hardik Windlass6d9a82e2021-07-08 16:23:21 +00002//
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
15// used to deploy VOLTHA and configure ONOS physical PODs
16
17// NOTE we are importing the library even if it's global so that it's
18// easier to change the keywords during a replay
19library identifier: 'cord-jenkins-libraries@master',
20 retriever: modernSCM([
21 $class: 'GitSCMSource',
22 remote: 'https://gerrit.opencord.org/ci-management.git'
23])
24
Joey Armstrong6c0b8552023-06-28 17:41:48 -040025// -----------------------------------------------------------------------
26// -----------------------------------------------------------------------
27def getIam(String func)
28{
29 // Cannot rely on a stack trace due to jenkins manipulation
30 String src = 'jjb/pipeline/voltha-2.8/physical-build.groovy'
31 String iam = [src, func].join('::')
32 return iam
33}
34
Hardik Windlass6d9a82e2021-07-08 16:23:21 +000035def infraNamespace = "infra"
36def volthaNamespace = "voltha"
37
Joey Armstrong6c0b8552023-06-28 17:41:48 -040038// -----------------------------------------------------------------------
39// -----------------------------------------------------------------------
Andrea Campanella20361592021-08-26 18:45:28 +020040def deploy_custom_oltAdapterChart(namespace, name, chart, extraHelmFlags) {
Joey Armstrong6c0b8552023-06-28 17:41:48 -040041 String iam = getIam('deploy_custom_oltAdapterChart')
42 println("** ${iam}: ENTER")
43
44 sh """
Andrea Campanella20361592021-08-26 18:45:28 +020045 helm install --create-namespace --set defaults.image_pullPolicy=Always --namespace ${namespace} ${extraHelmFlags} ${name} ${chart}
46 """
Joey Armstrong6c0b8552023-06-28 17:41:48 -040047
48 println("** ${iam}: LEAVE")
49 return
Andrea Campanella20361592021-08-26 18:45:28 +020050}
51
Hardik Windlass6d9a82e2021-07-08 16:23:21 +000052pipeline {
53
54 /* no label, executor is determined by JJB */
55 agent {
56 label "${params.buildNode}"
57 }
58 options {
59 timeout(time: 35, unit: 'MINUTES')
60 }
61 environment {
62 PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
63 KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf"
64 }
65
66 stages{
67 stage('Download Code') {
68 steps {
69 getVolthaCode([
70 branch: "${branch}",
71 volthaSystemTestsChange: "${volthaSystemTestsChange}",
72 volthaHelmChartsChange: "${volthaHelmChartsChange}",
73 ])
74 }
75 }
76 stage ("Parse deployment configuration file") {
77 steps {
78 sh returnStdout: true, script: "rm -rf ${configBaseDir}"
Hardik Windlass6f854a12021-07-12 13:20:21 +000079 sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
Hardik Windlass6d9a82e2021-07-08 16:23:21 +000080 script {
81 if ( params.workFlow == "DT" ) {
82 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
83 }
84 else if ( params.workFlow == "TT" )
85 {
86 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
87 }
88 else
89 {
90 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
91 }
92 }
93 }
94 }
95 stage('Clean up') {
96 steps {
97 timeout(15) {
98 script {
99 helmTeardown(["default", infraNamespace, volthaNamespace])
100 }
101 timeout(1) {
102 sh returnStdout: false, script: '''
103 # remove orphaned port-forward from different namespaces
104 ps aux | grep port-forw | grep -v grep | awk '{print $2}' | xargs --no-run-if-empty kill -9 || true
105 '''
106 }
107 }
108 }
109 }
110 stage('Install Voltha') {
111 steps {
112 timeout(20) {
Hardik Windlass9658cd22021-10-25 11:13:25 +0000113 installVoltctl("$branch")
Hardik Windlass6d9a82e2021-07-08 16:23:21 +0000114 script {
115 // if we're downloading a voltha-helm-charts patch, then install from a local copy of the charts
116 def localCharts = false
117 if (volthaHelmChartsChange != "" || branch != "master") {
118 localCharts = true
119 }
120
121 // should the config file be suffixed with the workflow? see "deployment_config"
122 def localHelmFlags = "-f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/voltha/${configFileName}.yml --set global.log_level=${logLevel} "
123
124 if (workFlow.toLowerCase() == "dt") {
125 localHelmFlags += " --set radius.enabled=false "
126 }
127 if (workFlow.toLowerCase() == "tt") {
128 localHelmFlags += " --set radius.enabled=false --set global.incremental_evto_update=true "
129 if (enableMultiUni.toBoolean()) {
130 localHelmFlags += " --set voltha-adapter-openonu.adapter_open_onu.uni_port_mask=${uniPortMask} "
131 }
132 }
133
134 // NOTE temporary workaround expose ONOS node ports (pod-config needs to be updated to contain these values)
135 // and to connect the ofagent to all instances of ONOS
136 localHelmFlags = localHelmFlags + " --set onos-classic.onosSshPort=30115 " +
137 "--set onos-classic.onosApiPort=30120 " +
138 "--set onos-classic.onosOfPort=31653 " +
139 "--set onos-classic.individualOpenFlowNodePorts=true " +
140 "--set voltha.onos_classic.replicas=${params.NumOfOnos}"
141
142 if (bbsimReplicas.toInteger() != 0) {
143 localHelmFlags = localHelmFlags + " --set onu=${onuNumber},pon=${ponNumber} "
144 }
145
146 // adding user specified helm flags at the end so they'll have priority over everything else
147 localHelmFlags = localHelmFlags + " ${extraHelmFlags}"
148
Matteo Scandolo1dd38322022-01-14 14:48:21 -0800149 // in VOLTHA-2.8 there is no need to wait for the adapters
150 def numberOfAdaptersToWait = 0
Andrea Campanella20361592021-08-26 18:45:28 +0200151
Hardik Windlass6d9a82e2021-07-08 16:23:21 +0000152 volthaDeploy([
153 workflow: workFlow.toLowerCase(),
154 extraHelmFlags: localHelmFlags,
155 localCharts: localCharts,
156 kubeconfig: "$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf",
157 onosReplica: params.NumOfOnos,
158 atomixReplica: params.NumOfAtomix,
159 kafkaReplica: params.NumOfKafka,
160 etcdReplica: params.NumOfEtcd,
161 bbsimReplica: bbsimReplicas.toInteger(),
Andrea Campanella365ea1e2021-09-28 10:50:01 +0200162 adaptersToWait: numberOfAdaptersToWait,
Hardik Windlass6d9a82e2021-07-08 16:23:21 +0000163 ])
Andrea Campanella20361592021-08-26 18:45:28 +0200164
Andrea Campanella365ea1e2021-09-28 10:50:01 +0200165 if(openoltAdapterChart != "onf/voltha-adapter-openolt"){
166 extraHelmFlags = extraHelmFlags + " --set global.log_level=${logLevel}"
167 deploy_custom_oltAdapterChart(volthaNamespace, oltAdapterReleaseName, openoltAdapterChart, extraHelmFlags)
168 waitForAdapters([
Matteo Scandolo1dd38322022-01-14 14:48:21 -0800169 adaptersToWait: 0 // in VOLTHA-2.8 there is no need to wait for the adapters
Andrea Campanella365ea1e2021-09-28 10:50:01 +0200170 ])
171 }
Hardik Windlass6d9a82e2021-07-08 16:23:21 +0000172 }
173 sh """
174 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"&
175 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"&
176 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"&
177 ps aux | grep port-forward
178 """
179 getPodsInfo("$WORKSPACE")
180 }
181 }
182 }
183 stage('Push Tech-Profile') {
184 steps {
185 script {
186 if ( params.configurePod && params.profile != "Default" ) {
187 for(int i=0; i < deployment_config.olts.size(); i++) {
188 def tech_prof_directory = "XGS-PON"
Girish Gowdraa0618412021-07-14 20:10:39 -0700189 if (deployment_config.olts[i].containsKey("board_technology")){
190 tech_prof_directory = deployment_config.olts[i]["board_technology"]
Hardik Windlass6d9a82e2021-07-08 16:23:21 +0000191 }
192 timeout(1) {
193 sh returnStatus: true, script: """
194 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
195 etcd_container=\$(kubectl get pods -n ${infraNamespace} | grep etcd | awk 'NR==1{print \$1}')
196 if [[ "${workFlow}" == "TT" ]]; then
197 if [[ "${params.enableMultiUni}" == "true" ]]; then
198 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-multi-uni-HSIA.json \$etcd_container:/tmp/hsia.json
199 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'
200 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-multi-uni-VoIP.json \$etcd_container:/tmp/voip.json
201 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'
202 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
203 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'
204 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
205 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'
206 else
207 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-HSIA.json \$etcd_container:/tmp/hsia.json
208 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'
209 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-VoIP.json \$etcd_container:/tmp/voip.json
210 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'
211 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-MCAST-AdditionalBW-None.json \$etcd_container:/tmp/mcast_additionalBW_none.json
212 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'
213 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-MCAST-AdditionalBW-NA.json \$etcd_container:/tmp/mcast_additionalBW_na.json
214 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'
215 fi
216 else
217 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-${profile}.json \$etcd_container:/tmp/flexpod.json
218 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'
219 fi
220 """
221 }
222 timeout(1) {
223 sh returnStatus: true, script: """
224 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
225 etcd_container=\$(kubectl get pods -n ${infraNamespace} | grep etcd | awk 'NR==1{print \$1}')
226 kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/${tech_prof_directory}/64'
227 """
228 }
229 }
230 }
231 }
232 }
233 }
234 stage('Push MIB templates') {
235 steps {
236 sh """
237 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
238 etcd_container=\$(kubectl get pods -n ${infraNamespace} | grep etcd | awk 'NR==1{print \$1}')
239 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/MIB_Alpha.json \$etcd_container:/tmp/MIB_Alpha.json
240 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'
241 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'
242 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/MIB_Scom.json \$etcd_container:/tmp/MIB_Scom.json
243 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'
244 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'
245 """
246 }
247 }
248 stage('Push Sadis-config') {
249 steps {
250 timeout(1) {
251 sh returnStatus: true, script: """
252 if [[ "${workFlow}" == "DT" ]]; then
253 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
254 elif [[ "${workFlow}" == "TT" ]]; then
255 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
256 else
257 # this is the ATT case, rename the file in *-sadis-ATT.json so that we can avoid special cases and just load the file
258 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
259 fi
260 """
261 }
262 }
263 }
264 stage('Switch Configurations in ONOS') {
265 steps {
266 script {
267 if ( deployment_config.fabric_switches.size() > 0 ) {
268 timeout(1) {
269 def netcfg = "$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch.json"
270 if (params.inBandManagement){
271 netcfg = "$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch-inband.json"
272 }
273 sh """
274 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}
275 curl -sSL --user karaf:karaf -X POST http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting/active
276 """
277 }
278 timeout(1) {
279 waitUntil {
280 sr_active_out = sh returnStatus: true, script: """
281 sshpass -p karaf ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.dhcpl2relay"
282 sshpass -p karaf ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.aaa"
283 sshpass -p karaf ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.olt"
Andrea Campanella39b9b3d2021-09-09 16:54:20 +0200284 #TRACE in the pipeliner is too chatty, moving to DEBUG
285 sshpass -p karaf ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set DEBUG org.opencord.olt.driver"
Hardik Windlass6d9a82e2021-07-08 16:23:21 +0000286 sshpass -p karaf ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set DEBUG org.onosproject.net.flowobjective.impl.FlowObjectiveManager"
287 sshpass -p karaf ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set DEBUG org.onosproject.net.flowobjective.impl.InOrderFlowObjectiveManager"
288 curl -sSL --user karaf:karaf -X GET http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting | jq '.state' | grep ACTIVE
289 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"
290 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"
291 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"
292 """
293 return sr_active_out == 0
294 }
295 }
296 timeout(7) {
297 for(int i=0; i < deployment_config.hosts.src.size(); i++) {
298 for(int j=0; j < deployment_config.olts.size(); j++) {
299 def aggPort = -1
300 if(deployment_config.olts[j].serial == deployment_config.hosts.src[i].olt){
301 aggPort = deployment_config.olts[j].aggPort
302 if(aggPort == -1){
303 throw new Exception("Upstream port for the olt is not configured, field aggPort is empty")
304 }
305 sh """
306 sleep 30 # NOTE why are we sleeping?
307 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'
308 """
309 }
310 }
311 }
312 }
313 }
314 }
315 }
316 }
317 stage('Reinstall OLT software') {
318 steps {
319 script {
320 if ( params.reinstallOlt ) {
321 for(int i=0; i < deployment_config.olts.size(); i++) {
322 // NOTE what is oltDebVersion23? is that for VOLTHA-2.3? do we still need this differentiation?
323 sh returnStdout: true, script: """
Hardik Windlass6cdbfa22021-07-13 06:21:35 +0000324 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
325 if [ "${params.inBandManagement}" == "true" ]; then
Hardik Windlass6d9a82e2021-07-08 16:23:21 +0000326 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'
Hardik Windlass6d9a82e2021-07-08 16:23:21 +0000327 fi
Hardik Windlass6cdbfa22021-07-13 06:21:35 +0000328 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}"
Hardik Windlass6d9a82e2021-07-08 16:23:21 +0000329 sleep 10
330 """
331 timeout(5) {
332 waitUntil {
333 olt_sw_present = sh returnStdout: true, script: """
Andrea Campanella842cb5d2021-12-17 18:33:05 +0100334 if [[ "${deployment_config.olts[i].oltDebVersion}" == *"asfvolt16"* ]]; then
Hardik Windlass6d9a82e2021-07-08 16:23:21 +0000335 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'
Andrea Campanella842cb5d2021-12-17 18:33:05 +0100336 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"asgvolt64"* ]]; then
Hardik Windlass6d9a82e2021-07-08 16:23:21 +0000337 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'
Andrea Campanella842cb5d2021-12-17 18:33:05 +0100338 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-1600x-w"* ]]; then
339 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'
340 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-1600g-w"* ]]; then
341 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'
342 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-3200g-w"* ]]; then
343 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'
Girish Gowdraabc5dcf2022-05-18 12:40:07 -0700344 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"sda3016ss"* ]]; then
345 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'
Andrea Campanella842cb5d2021-12-17 18:33:05 +0100346 else
347 echo Unknown Debian package for openolt
Hardik Windlass6d9a82e2021-07-08 16:23:21 +0000348 fi
349 if (${deployment_config.olts[i].fortygig}); then
350 if [[ "${params.inBandManagement}" == "true" ]]; then
351 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
352 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'mkdir -p /opt/openolt/'
353 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/'
354 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'
355 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/'
356 fi
357 fi
358 """
359 return olt_sw_present.toInteger() > 0
360 }
361 }
362 }
363 }
364 }
365 }
366 }
367 stage('Restart OLT processes') {
368 steps {
369 script {
Andrea Campanellaecefbc82021-08-27 11:06:31 +0200370 //rebooting OLTs
Hardik Windlass6d9a82e2021-07-08 16:23:21 +0000371 for(int i=0; i < deployment_config.olts.size(); i++) {
Girish Gowdrac5a3ef82021-10-06 12:58:49 -0700372 timeout(15) {
Hardik Windlass6d9a82e2021-07-08 16:23:21 +0000373 sh returnStdout: true, script: """
374 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
Girish Gowdrac5a3ef82021-10-06 12:58:49 -0700375 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
Hardik Windlass6d9a82e2021-07-08 16:23:21 +0000376 """
377 }
Andrea Campanellaecefbc82021-08-27 11:06:31 +0200378 }
379 sh returnStdout: true, script: """
380 sleep ${params.waitTimerForOltUp}
381 """
382 //Checking dev_management_deamon and openoltprocesses
383 for(int i=0; i < deployment_config.olts.size(); i++) {
384 if ( params.oltAdapterReleaseName != "open-olt" ) {
385 timeout(15) {
386 waitUntil {
387 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'"
388 return devprocess.toInteger() > 0
389 }
Hardik Windlass6d9a82e2021-07-08 16:23:21 +0000390 }
Andrea Campanellaecefbc82021-08-27 11:06:31 +0200391 timeout(15) {
392 waitUntil {
393 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'"
394 return openoltprocess.toInteger() > 0
395 }
Hardik Windlass6d9a82e2021-07-08 16:23:21 +0000396 }
397 }
398 }
399 }
400 }
401 }
402 }
403
404 post {
405 aborted {
406 getPodsInfo("$WORKSPACE/failed")
407 sh """
408 kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/failed/voltha.log || true
409 """
410 archiveArtifacts artifacts: '**/*.log,**/*.txt'
411 }
412 failure {
413 getPodsInfo("$WORKSPACE/failed")
414 sh """
415 kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/failed/voltha.logs || true
416 """
417 archiveArtifacts artifacts: '**/*.log,**/*.txt'
418 }
419 always {
420 archiveArtifacts artifacts: '*.txt'
421 }
422 }
423}