blob: 51313a6b371d990486512b249bd284003cd882ca [file] [log] [blame]
Matteo Scandolod82d1de2021-04-06 14:55:58 -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
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
25def infraNamespace = "infra"
26def volthaNamespace = "voltha"
27
Andrea Campanella20361592021-08-26 18:45:28 +020028def deploy_custom_oltAdapterChart(namespace, name, chart, extraHelmFlags) {
29 sh """
30 helm install --create-namespace --set defaults.image_pullPolicy=Always --namespace ${namespace} ${extraHelmFlags} ${name} ${chart}
31 """
32}
33
Matteo Scandolod82d1de2021-04-06 14:55:58 -070034pipeline {
35
36 /* no label, executor is determined by JJB */
37 agent {
38 label "${params.buildNode}"
39 }
40 options {
41 timeout(time: 35, unit: 'MINUTES')
42 }
43 environment {
44 PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
Matteo Scandolod43bb302021-04-20 10:19:29 -070045 KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf"
Matteo Scandolod82d1de2021-04-06 14:55:58 -070046 }
47
48 stages{
49 stage('Download Code') {
Matteo Scandolod43bb302021-04-20 10:19:29 -070050 steps {
51 getVolthaCode([
52 branch: "${branch}",
Hardik Windlass791917b2021-05-28 04:55:37 +000053 volthaSystemTestsChange: "${volthaSystemTestsChange}",
Matteo Scandolod43bb302021-04-20 10:19:29 -070054 volthaHelmChartsChange: "${volthaHelmChartsChange}",
55 ])
56 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -070057 }
58 stage ("Parse deployment configuration file") {
Matteo Scandolod43bb302021-04-20 10:19:29 -070059 steps {
60 sh returnStdout: true, script: "rm -rf ${configBaseDir}"
Hardik Windlass6f854a12021-07-12 13:20:21 +000061 sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
Matteo Scandolod43bb302021-04-20 10:19:29 -070062 script {
63 if ( params.workFlow == "DT" ) {
64 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
65 }
66 else if ( params.workFlow == "TT" )
67 {
68 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
69 }
70 else
71 {
72 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
73 }
74 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -070075 }
76 }
77 stage('Clean up') {
Matteo Scandolod43bb302021-04-20 10:19:29 -070078 steps {
79 timeout(15) {
80 script {
81 helmTeardown(["default", infraNamespace, volthaNamespace])
82 }
83 timeout(1) {
84 sh returnStdout: false, script: '''
Matteo Scandolo16bb6fe2021-04-26 13:15:39 -070085 # remove orphaned port-forward from different namespaces
Andrea Campanella4c8af942021-05-12 10:12:13 +020086 ps aux | grep port-forw | grep -v grep | awk '{print $2}' | xargs --no-run-if-empty kill -9 || true
Matteo Scandolod43bb302021-04-20 10:19:29 -070087 '''
88 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -070089 }
90 }
91 }
92 stage('Install Voltha') {
Matteo Scandolod43bb302021-04-20 10:19:29 -070093 steps {
94 timeout(20) {
Hardik Windlass9658cd22021-10-25 11:13:25 +000095 installVoltctl("${branch}")
Matteo Scandolod43bb302021-04-20 10:19:29 -070096 script {
97 // if we're downloading a voltha-helm-charts patch, then install from a local copy of the charts
98 def localCharts = false
99 if (volthaHelmChartsChange != "") {
100 localCharts = true
101 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700102
Matteo Scandolo16bb6fe2021-04-26 13:15:39 -0700103 // should the config file be suffixed with the workflow? see "deployment_config"
Matteo Scandolod47bfb22021-05-24 09:40:05 -0700104 def localHelmFlags = "-f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/voltha/${configFileName}.yml --set global.log_level=${logLevel} "
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700105
Matteo Scandolo16bb6fe2021-04-26 13:15:39 -0700106 if (workFlow.toLowerCase() == "dt") {
Matteo Scandolod47bfb22021-05-24 09:40:05 -0700107 localHelmFlags += " --set radius.enabled=false "
Matteo Scandolo16bb6fe2021-04-26 13:15:39 -0700108 }
109 if (workFlow.toLowerCase() == "tt") {
Matteo Scandolod47bfb22021-05-24 09:40:05 -0700110 localHelmFlags += " --set radius.enabled=false --set global.incremental_evto_update=true "
Hardik Windlassb6e6a3a2021-07-02 17:22:01 +0000111 if (enableMultiUni.toBoolean()) {
Hardik Windlass6598b032021-07-02 10:12:01 +0000112 localHelmFlags += " --set voltha-adapter-openonu.adapter_open_onu.uni_port_mask=${uniPortMask} "
113 }
Matteo Scandolo16bb6fe2021-04-26 13:15:39 -0700114 }
115
Matteo Scandolod43bb302021-04-20 10:19:29 -0700116 // NOTE temporary workaround expose ONOS node ports (pod-config needs to be updated to contain these values)
Andrea Campanella07ec1e22021-06-04 16:18:41 +0200117 // and to connect the ofagent to all instances of ONOS
Matteo Scandolod47bfb22021-05-24 09:40:05 -0700118 localHelmFlags = localHelmFlags + " --set onos-classic.onosSshPort=30115 " +
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700119 "--set onos-classic.onosApiPort=30120 " +
120 "--set onos-classic.onosOfPort=31653 " +
Andrea Campanella07ec1e22021-06-04 16:18:41 +0200121 "--set onos-classic.individualOpenFlowNodePorts=true " +
122 "--set voltha.onos_classic.replicas=${params.NumOfOnos}"
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700123
Hardik Windlass908533a2021-05-24 16:35:58 +0000124 if (bbsimReplicas.toInteger() != 0) {
Matteo Scandolod47bfb22021-05-24 09:40:05 -0700125 localHelmFlags = localHelmFlags + " --set onu=${onuNumber},pon=${ponNumber} "
Hardik Windlassc7379022021-05-12 13:52:24 +0530126 }
127
Matteo Scandolod47bfb22021-05-24 09:40:05 -0700128 // adding user specified helm flags at the end so they'll have priority over everything else
Andrea Campanellad4ab9502021-05-25 10:53:58 +0200129 localHelmFlags = localHelmFlags + " ${extraHelmFlags}"
Matteo Scandolod47bfb22021-05-24 09:40:05 -0700130
Andrea Campanella365ea1e2021-09-28 10:50:01 +0200131 def numberOfAdaptersToWait = 2
132
Andrea Campanellace8aa762021-08-27 09:32:22 +0200133 if(openoltAdapterChart != "onf/voltha-adapter-openolt") {
Andrea Campanella20361592021-08-26 18:45:28 +0200134 localHelmFlags = localHelmFlags + " --set voltha-adapter-openolt.enabled=false"
Andrea Campanella365ea1e2021-09-28 10:50:01 +0200135 // We skip waiting for adapters in the volthaDeploy step because it's already waiting for
136 // both of them after the deployment of the custom olt adapter. See line 156.
137 numberOfAdaptersToWait = 0
Andrea Campanella20361592021-08-26 18:45:28 +0200138 }
139
Matteo Scandolod43bb302021-04-20 10:19:29 -0700140 volthaDeploy([
141 workflow: workFlow.toLowerCase(),
Matteo Scandolod47bfb22021-05-24 09:40:05 -0700142 extraHelmFlags: localHelmFlags,
Matteo Scandolod43bb302021-04-20 10:19:29 -0700143 localCharts: localCharts,
144 kubeconfig: "$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf",
145 onosReplica: params.NumOfOnos,
146 atomixReplica: params.NumOfAtomix,
Hardik Windlassc7379022021-05-12 13:52:24 +0530147 kafkaReplica: params.NumOfKafka,
Hardik Windlass1685e5b2021-05-13 14:07:44 +0530148 etcdReplica: params.NumOfEtcd,
Hardik Windlass908533a2021-05-24 16:35:58 +0000149 bbsimReplica: bbsimReplicas.toInteger(),
Andrea Campanella365ea1e2021-09-28 10:50:01 +0200150 adaptersToWait: numberOfAdaptersToWait,
Matteo Scandolod43bb302021-04-20 10:19:29 -0700151 ])
Andrea Campanella20361592021-08-26 18:45:28 +0200152
Andrea Campanella365ea1e2021-09-28 10:50:01 +0200153 if(openoltAdapterChart != "onf/voltha-adapter-openolt"){
154 extraHelmFlags = extraHelmFlags + " --set global.log_level=${logLevel}"
155 deploy_custom_oltAdapterChart(volthaNamespace, oltAdapterReleaseName, openoltAdapterChart, extraHelmFlags)
156 waitForAdapters([
157 adaptersToWait: 2
158 ])
159 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700160 }
161 sh """
Matteo Scandolo79f133f2021-04-27 13:53:21 -0700162 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"&
163 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"&
164 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"&
Matteo Scandolod43bb302021-04-20 10:19:29 -0700165 ps aux | grep port-forward
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700166 """
Matteo Scandolod43bb302021-04-20 10:19:29 -0700167 getPodsInfo("$WORKSPACE")
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700168 }
Matteo Scandolod43bb302021-04-20 10:19:29 -0700169 }
170 }
171 stage('Push Tech-Profile') {
172 steps {
173 script {
174 if ( params.configurePod && params.profile != "Default" ) {
175 for(int i=0; i < deployment_config.olts.size(); i++) {
176 def tech_prof_directory = "XGS-PON"
Girish Gowdrab8e98862021-07-07 14:09:13 -0700177 if (deployment_config.olts[i].containsKey("board_technology")){
Girish Gowdra28af4562021-07-07 11:52:13 -0700178 tech_prof_directory = deployment_config.olts[i]["board_technology"]
Matteo Scandolod43bb302021-04-20 10:19:29 -0700179 }
180 timeout(1) {
181 sh returnStatus: true, script: """
182 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Andrea Campanella04b393a2021-07-22 10:48:33 +0200183 etcd_container=\$(kubectl get pods -n ${infraNamespace} -l app.kubernetes.io/name=etcd --no-headers | awk 'NR==1{print \$1}')
Matteo Scandolod43bb302021-04-20 10:19:29 -0700184 if [[ "${workFlow}" == "TT" ]]; then
Hardik Windlassb6e6a3a2021-07-02 17:22:01 +0000185 if [[ "${params.enableMultiUni}" == "true" ]]; then
Hardik Windlass6598b032021-07-02 10:12:01 +0000186 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-multi-uni-HSIA.json \$etcd_container:/tmp/hsia.json
187 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'
188 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-multi-uni-VoIP.json \$etcd_container:/tmp/voip.json
189 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'
190 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
191 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'
192 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
193 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'
194 else
195 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-HSIA.json \$etcd_container:/tmp/hsia.json
196 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'
197 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-VoIP.json \$etcd_container:/tmp/voip.json
198 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'
199 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-MCAST-AdditionalBW-None.json \$etcd_container:/tmp/mcast_additionalBW_none.json
200 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'
201 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-MCAST-AdditionalBW-NA.json \$etcd_container:/tmp/mcast_additionalBW_na.json
202 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'
203 fi
Matteo Scandolod43bb302021-04-20 10:19:29 -0700204 else
205 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-${profile}.json \$etcd_container:/tmp/flexpod.json
206 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'
207 fi
208 """
209 }
210 timeout(1) {
211 sh returnStatus: true, script: """
212 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Andrea Campanella04b393a2021-07-22 10:48:33 +0200213 etcd_container=\$(kubectl get pods -n ${infraNamespace} -l app.kubernetes.io/name=etcd --no-headers | awk 'NR==1{print \$1}')
Matteo Scandolod43bb302021-04-20 10:19:29 -0700214 kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/${tech_prof_directory}/64'
215 """
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700216 }
217 }
218 }
219 }
220 }
221 }
Matteo Scandolod43bb302021-04-20 10:19:29 -0700222 stage('Push MIB templates') {
223 steps {
224 sh """
225 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Andrea Campanella04b393a2021-07-22 10:48:33 +0200226 etcd_container=\$(kubectl get pods -n ${infraNamespace} -l app.kubernetes.io/name=etcd --no-headers | awk 'NR==1{print \$1}')
Matteo Scandolod43bb302021-04-20 10:19:29 -0700227 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/MIB_Alpha.json \$etcd_container:/tmp/MIB_Alpha.json
228 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'
229 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'
230 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/MIB_Scom.json \$etcd_container:/tmp/MIB_Scom.json
231 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'
232 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'
233 """
234 }
235 }
236 stage('Push Sadis-config') {
237 steps {
238 timeout(1) {
239 sh returnStatus: true, script: """
240 if [[ "${workFlow}" == "DT" ]]; then
241 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
242 elif [[ "${workFlow}" == "TT" ]]; then
243 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
244 else
245 # this is the ATT case, rename the file in *-sadis-ATT.json so that we can avoid special cases and just load the file
246 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
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700247 fi
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700248 """
Matteo Scandolod43bb302021-04-20 10:19:29 -0700249 }
250 }
251 }
252 stage('Switch Configurations in ONOS') {
253 steps {
254 script {
255 if ( deployment_config.fabric_switches.size() > 0 ) {
256 timeout(1) {
257 def netcfg = "$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch.json"
258 if (params.inBandManagement){
259 netcfg = "$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch-inband.json"
260 }
261 sh """
262 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}
263 curl -sSL --user karaf:karaf -X POST http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting/active
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700264 """
Matteo Scandolod43bb302021-04-20 10:19:29 -0700265 }
266 timeout(1) {
Matteo Scandolo857376b2021-11-05 14:53:22 -0700267 setOnosLogLevels([
268 onosNamespace: infraNamespace,
269 apps: [
270 'org.opencord.dhcpl2relay',
271 'org.opencord.olt',
272 'org.opencord.aaa',
273 'org.onosproject.net.flowobjective.impl.FlowObjectiveManager',
274 'org.onosproject.net.flowobjective.impl.InOrderFlowObjectiveManager'
275 ]
276 ])
Matteo Scandolod43bb302021-04-20 10:19:29 -0700277 waitUntil {
278 sr_active_out = sh returnStatus: true, script: """
Matteo Scandolod43bb302021-04-20 10:19:29 -0700279 curl -sSL --user karaf:karaf -X GET http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting | jq '.state' | grep ACTIVE
280 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"
281 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"
282 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"
283 """
284 return sr_active_out == 0
285 }
286 }
Hardik Windlass728a86c2021-10-01 17:58:12 +0530287 timeout(5) {
Matteo Scandolod43bb302021-04-20 10:19:29 -0700288 for(int i=0; i < deployment_config.hosts.src.size(); i++) {
289 for(int j=0; j < deployment_config.olts.size(); j++) {
290 def aggPort = -1
291 if(deployment_config.olts[j].serial == deployment_config.hosts.src[i].olt){
292 aggPort = deployment_config.olts[j].aggPort
293 if(aggPort == -1){
294 throw new Exception("Upstream port for the olt is not configured, field aggPort is empty")
295 }
296 sh """
Hardik Windlass728a86c2021-10-01 17:58:12 +0530297 sleep 10 # NOTE why are we sleeping?
Matteo Scandolod43bb302021-04-20 10:19:29 -0700298 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'
299 """
300 }
301 }
302 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700303 }
304 }
305 }
306 }
Matteo Scandolod43bb302021-04-20 10:19:29 -0700307 }
308 stage('Reinstall OLT software') {
309 steps {
310 script {
311 if ( params.reinstallOlt ) {
312 for(int i=0; i < deployment_config.olts.size(); i++) {
313 // NOTE what is oltDebVersion23? is that for VOLTHA-2.3? do we still need this differentiation?
314 sh returnStdout: true, script: """
Hardik Windlass6cdbfa22021-07-13 06:21:35 +0000315 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
316 if [ "${params.inBandManagement}" == "true" ]; then
Matteo Scandolod43bb302021-04-20 10:19:29 -0700317 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'
Matteo Scandolod43bb302021-04-20 10:19:29 -0700318 fi
Hardik Windlass6cdbfa22021-07-13 06:21:35 +0000319 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}"
Matteo Scandolod43bb302021-04-20 10:19:29 -0700320 sleep 10
321 """
322 timeout(5) {
323 waitUntil {
324 olt_sw_present = sh returnStdout: true, script: """
Andrea Campanella272bd202021-12-17 09:46:26 +0100325 if [[ "${deployment_config.olts[i].oltDebVersion}" == *"asfvolt16"* ]]; then
Matteo Scandolod43bb302021-04-20 10:19:29 -0700326 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 Campanella272bd202021-12-17 09:46:26 +0100327 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"asgvolt64"* ]]; then
Matteo Scandolod43bb302021-04-20 10:19:29 -0700328 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 Campanella272bd202021-12-17 09:46:26 +0100329 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-1600x-w"* ]]; then
330 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'
331 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-1600g-w"* ]]; then
332 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'
333 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-3200g-w"* ]]; then
334 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'
335 else
336 echo Unknown Debian package for openolt
Matteo Scandolod43bb302021-04-20 10:19:29 -0700337 fi
338 if (${deployment_config.olts[i].fortygig}); then
339 if [[ "${params.inBandManagement}" == "true" ]]; then
340 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
341 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'mkdir -p /opt/openolt/'
342 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/'
343 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'
344 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/'
345 fi
346 fi
347 """
348 return olt_sw_present.toInteger() > 0
349 }
350 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700351 }
352 }
Matteo Scandolod43bb302021-04-20 10:19:29 -0700353 }
354 }
355 }
356 stage('Restart OLT processes') {
357 steps {
358 script {
Andrea Campanellaecefbc82021-08-27 11:06:31 +0200359 //rebooting OLTs
Matteo Scandolod43bb302021-04-20 10:19:29 -0700360 for(int i=0; i < deployment_config.olts.size(); i++) {
Girish Gowdrac5a3ef82021-10-06 12:58:49 -0700361 timeout(15) {
Matteo Scandolod43bb302021-04-20 10:19:29 -0700362 sh returnStdout: true, script: """
363 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
Girish Gowdrac5a3ef82021-10-06 12:58:49 -0700364 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
Matteo Scandolod43bb302021-04-20 10:19:29 -0700365 """
366 }
Andrea Campanellaecefbc82021-08-27 11:06:31 +0200367 }
368 sh returnStdout: true, script: """
369 sleep ${params.waitTimerForOltUp}
370 """
371 //Checking dev_management_deamon and openoltprocesses
372 for(int i=0; i < deployment_config.olts.size(); i++) {
373 if ( params.oltAdapterReleaseName != "open-olt" ) {
374 timeout(15) {
375 waitUntil {
376 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'"
377 return devprocess.toInteger() > 0
378 }
Matteo Scandolod43bb302021-04-20 10:19:29 -0700379 }
Andrea Campanellaecefbc82021-08-27 11:06:31 +0200380 timeout(15) {
381 waitUntil {
382 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'"
383 return openoltprocess.toInteger() > 0
384 }
Matteo Scandolod43bb302021-04-20 10:19:29 -0700385 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700386 }
387 }
388 }
389 }
390 }
391 }
392
393 post {
Matteo Scandolo0da60532021-05-06 08:59:42 -0700394 aborted {
395 getPodsInfo("$WORKSPACE/failed")
396 sh """
397 kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/failed/voltha.log || true
398 """
399 archiveArtifacts artifacts: '**/*.log,**/*.txt'
400 }
401 failure {
402 getPodsInfo("$WORKSPACE/failed")
403 sh """
404 kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/failed/voltha.logs || true
405 """
406 archiveArtifacts artifacts: '**/*.log,**/*.txt'
407 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700408 always {
409 archiveArtifacts artifacts: '*.txt'
410 }
411 }
412}