blob: 8745ef5732350770a019db611f5f89c4cc608073 [file] [log] [blame]
Joey Armstrongbeef4cd2023-01-18 09:59:58 -05001// Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors
Matteo Scandolod82d1de2021-04-06 14:55:58 -07002//
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/master/physical-build.groovy'
31 String iam = [src, func].join('::')
32 return iam
33}
34
Matteo Scandolod82d1de2021-04-06 14:55:58 -070035def 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
Matteo Scandolod82d1de2021-04-06 14:55:58 -070052pipeline {
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"
Matteo Scandolod43bb302021-04-20 10:19:29 -070063 KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf"
Matteo Scandolod82d1de2021-04-06 14:55:58 -070064 }
65
66 stages{
67 stage('Download Code') {
Matteo Scandolod43bb302021-04-20 10:19:29 -070068 steps {
69 getVolthaCode([
70 branch: "${branch}",
Hardik Windlass791917b2021-05-28 04:55:37 +000071 volthaSystemTestsChange: "${volthaSystemTestsChange}",
Matteo Scandolod43bb302021-04-20 10:19:29 -070072 volthaHelmChartsChange: "${volthaHelmChartsChange}",
73 ])
74 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -070075 }
76 stage ("Parse deployment configuration file") {
Matteo Scandolod43bb302021-04-20 10:19:29 -070077 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}"
Matteo Scandolod43bb302021-04-20 10:19:29 -070080 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 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -070093 }
94 }
95 stage('Clean up') {
Matteo Scandolod43bb302021-04-20 10:19:29 -070096 steps {
97 timeout(15) {
98 script {
99 helmTeardown(["default", infraNamespace, volthaNamespace])
100 }
101 timeout(1) {
102 sh returnStdout: false, script: '''
Matteo Scandolo16bb6fe2021-04-26 13:15:39 -0700103 # remove orphaned port-forward from different namespaces
Andrea Campanella4c8af942021-05-12 10:12:13 +0200104 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 -0700105 '''
106 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700107 }
108 }
109 }
110 stage('Install Voltha') {
Matteo Scandolod43bb302021-04-20 10:19:29 -0700111 steps {
112 timeout(20) {
Hardik Windlass9658cd22021-10-25 11:13:25 +0000113 installVoltctl("${branch}")
Matteo Scandolod43bb302021-04-20 10:19:29 -0700114 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 != "") {
118 localCharts = true
119 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700120
Matteo Scandolo16bb6fe2021-04-26 13:15:39 -0700121 // should the config file be suffixed with the workflow? see "deployment_config"
Matteo Scandolod47bfb22021-05-24 09:40:05 -0700122 def localHelmFlags = "-f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/voltha/${configFileName}.yml --set global.log_level=${logLevel} "
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700123
Matteo Scandolo16bb6fe2021-04-26 13:15:39 -0700124 if (workFlow.toLowerCase() == "dt") {
Matteo Scandolod47bfb22021-05-24 09:40:05 -0700125 localHelmFlags += " --set radius.enabled=false "
Matteo Scandolo16bb6fe2021-04-26 13:15:39 -0700126 }
127 if (workFlow.toLowerCase() == "tt") {
Matteo Scandolod47bfb22021-05-24 09:40:05 -0700128 localHelmFlags += " --set radius.enabled=false --set global.incremental_evto_update=true "
Hardik Windlassb6e6a3a2021-07-02 17:22:01 +0000129 if (enableMultiUni.toBoolean()) {
Hardik Windlass6598b032021-07-02 10:12:01 +0000130 localHelmFlags += " --set voltha-adapter-openonu.adapter_open_onu.uni_port_mask=${uniPortMask} "
131 }
Matteo Scandolo16bb6fe2021-04-26 13:15:39 -0700132 }
133
Matteo Scandolod43bb302021-04-20 10:19:29 -0700134 // NOTE temporary workaround expose ONOS node ports (pod-config needs to be updated to contain these values)
Andrea Campanella07ec1e22021-06-04 16:18:41 +0200135 // and to connect the ofagent to all instances of ONOS
Matteo Scandolod47bfb22021-05-24 09:40:05 -0700136 localHelmFlags = localHelmFlags + " --set onos-classic.onosSshPort=30115 " +
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700137 "--set onos-classic.onosApiPort=30120 " +
138 "--set onos-classic.onosOfPort=31653 " +
Andrea Campanella07ec1e22021-06-04 16:18:41 +0200139 "--set onos-classic.individualOpenFlowNodePorts=true " +
140 "--set voltha.onos_classic.replicas=${params.NumOfOnos}"
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700141
Hardik Windlass908533a2021-05-24 16:35:58 +0000142 if (bbsimReplicas.toInteger() != 0) {
Matteo Scandolod47bfb22021-05-24 09:40:05 -0700143 localHelmFlags = localHelmFlags + " --set onu=${onuNumber},pon=${ponNumber} "
Hardik Windlassc7379022021-05-12 13:52:24 +0530144 }
145
Matteo Scandolod47bfb22021-05-24 09:40:05 -0700146 // adding user specified helm flags at the end so they'll have priority over everything else
Andrea Campanellad4ab9502021-05-25 10:53:58 +0200147 localHelmFlags = localHelmFlags + " ${extraHelmFlags}"
Matteo Scandolod47bfb22021-05-24 09:40:05 -0700148
Andrea Campanella365ea1e2021-09-28 10:50:01 +0200149 def numberOfAdaptersToWait = 2
150
Andrea Campanellace8aa762021-08-27 09:32:22 +0200151 if(openoltAdapterChart != "onf/voltha-adapter-openolt") {
Andrea Campanella20361592021-08-26 18:45:28 +0200152 localHelmFlags = localHelmFlags + " --set voltha-adapter-openolt.enabled=false"
Andrea Campanella365ea1e2021-09-28 10:50:01 +0200153 // We skip waiting for adapters in the volthaDeploy step because it's already waiting for
154 // both of them after the deployment of the custom olt adapter. See line 156.
155 numberOfAdaptersToWait = 0
Andrea Campanella20361592021-08-26 18:45:28 +0200156 }
157
Matteo Scandolod43bb302021-04-20 10:19:29 -0700158 volthaDeploy([
159 workflow: workFlow.toLowerCase(),
Matteo Scandolod47bfb22021-05-24 09:40:05 -0700160 extraHelmFlags: localHelmFlags,
Matteo Scandolod43bb302021-04-20 10:19:29 -0700161 localCharts: localCharts,
162 kubeconfig: "$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf",
163 onosReplica: params.NumOfOnos,
164 atomixReplica: params.NumOfAtomix,
Hardik Windlassc7379022021-05-12 13:52:24 +0530165 kafkaReplica: params.NumOfKafka,
Hardik Windlass1685e5b2021-05-13 14:07:44 +0530166 etcdReplica: params.NumOfEtcd,
Hardik Windlass908533a2021-05-24 16:35:58 +0000167 bbsimReplica: bbsimReplicas.toInteger(),
Hardik Windlassc97ceae2022-05-13 10:12:55 +0530168 withFttb: withFttb.toBoolean(),
Andrea Campanella365ea1e2021-09-28 10:50:01 +0200169 adaptersToWait: numberOfAdaptersToWait,
Matteo Scandolod43bb302021-04-20 10:19:29 -0700170 ])
Andrea Campanella20361592021-08-26 18:45:28 +0200171
Andrea Campanella365ea1e2021-09-28 10:50:01 +0200172 if(openoltAdapterChart != "onf/voltha-adapter-openolt"){
173 extraHelmFlags = extraHelmFlags + " --set global.log_level=${logLevel}"
174 deploy_custom_oltAdapterChart(volthaNamespace, oltAdapterReleaseName, openoltAdapterChart, extraHelmFlags)
175 waitForAdapters([
176 adaptersToWait: 2
177 ])
178 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700179 }
180 sh """
Matteo Scandolo79f133f2021-04-27 13:53:21 -0700181 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 -0700182 ps aux | grep port-forward
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700183 """
Matteo Scandolod43bb302021-04-20 10:19:29 -0700184 getPodsInfo("$WORKSPACE")
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700185 }
Matteo Scandolod43bb302021-04-20 10:19:29 -0700186 }
187 }
188 stage('Push Tech-Profile') {
189 steps {
190 script {
191 if ( params.configurePod && params.profile != "Default" ) {
192 for(int i=0; i < deployment_config.olts.size(); i++) {
193 def tech_prof_directory = "XGS-PON"
Girish Gowdrab8e98862021-07-07 14:09:13 -0700194 if (deployment_config.olts[i].containsKey("board_technology")){
Girish Gowdra28af4562021-07-07 11:52:13 -0700195 tech_prof_directory = deployment_config.olts[i]["board_technology"]
Matteo Scandolod43bb302021-04-20 10:19:29 -0700196 }
197 timeout(1) {
198 sh returnStatus: true, script: """
199 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Andrea Campanella04b393a2021-07-22 10:48:33 +0200200 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 -0700201 if [[ "${workFlow}" == "TT" ]]; then
TorstenThieme1befe442022-01-25 10:35:10 +0000202 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-HSIA.json \$etcd_container:/tmp/hsia.json
203 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'
204 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-VoIP.json \$etcd_container:/tmp/voip.json
205 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'
Hardik Windlassb6e6a3a2021-07-02 17:22:01 +0000206 if [[ "${params.enableMultiUni}" == "true" ]]; then
Hardik Windlass6598b032021-07-02 10:12:01 +0000207 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
208 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'
209 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
210 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'
211 else
Hardik Windlass6598b032021-07-02 10:12:01 +0000212 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-MCAST-AdditionalBW-None.json \$etcd_container:/tmp/mcast_additionalBW_none.json
213 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'
214 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-MCAST-AdditionalBW-NA.json \$etcd_container:/tmp/mcast_additionalBW_na.json
215 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'
216 fi
Matteo Scandolod43bb302021-04-20 10:19:29 -0700217 else
218 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-${profile}.json \$etcd_container:/tmp/flexpod.json
219 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'
220 fi
221 """
222 }
223 timeout(1) {
224 sh returnStatus: true, script: """
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 exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/${tech_prof_directory}/64'
228 """
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700229 }
230 }
231 }
232 }
233 }
234 }
Matteo Scandolod43bb302021-04-20 10:19:29 -0700235 stage('Push MIB templates') {
236 steps {
237 sh """
238 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Andrea Campanella04b393a2021-07-22 10:48:33 +0200239 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 -0700240 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/MIB_Alpha.json \$etcd_container:/tmp/MIB_Alpha.json
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/go_templates/BRCM/BVM4K00BRA0915-0083/5023_020O02414'
242 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'
243 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/MIB_Scom.json \$etcd_container:/tmp/MIB_Scom.json
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/go_templates/SCOM/Glasfaser-Modem/090140.1.0.304'
245 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'
246 """
247 }
248 }
249 stage('Push Sadis-config') {
250 steps {
251 timeout(1) {
252 sh returnStatus: true, script: """
253 if [[ "${workFlow}" == "DT" ]]; then
254 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
255 elif [[ "${workFlow}" == "TT" ]]; then
256 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
257 else
258 # this is the ATT case, rename the file in *-sadis-ATT.json so that we can avoid special cases and just load the file
259 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 -0700260 fi
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700261 """
Matteo Scandolod43bb302021-04-20 10:19:29 -0700262 }
263 }
264 }
265 stage('Switch Configurations in ONOS') {
266 steps {
267 script {
268 if ( deployment_config.fabric_switches.size() > 0 ) {
269 timeout(1) {
270 def netcfg = "$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch.json"
271 if (params.inBandManagement){
272 netcfg = "$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch-inband.json"
273 }
274 sh """
275 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}
276 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 -0700277 """
Matteo Scandolod43bb302021-04-20 10:19:29 -0700278 }
Hardik Windlassc97ceae2022-05-13 10:12:55 +0530279 timeout(3) {
Matteo Scandolo857376b2021-11-05 14:53:22 -0700280 setOnosLogLevels([
281 onosNamespace: infraNamespace,
282 apps: [
283 'org.opencord.dhcpl2relay',
284 'org.opencord.olt',
285 'org.opencord.aaa',
Andrea Campanellac0762392022-03-11 15:01:13 +0100286 'org.opencord.maclearner',
Matteo Scandolo857376b2021-11-05 14:53:22 -0700287 'org.onosproject.net.flowobjective.impl.FlowObjectiveManager',
288 'org.onosproject.net.flowobjective.impl.InOrderFlowObjectiveManager'
289 ]
290 ])
Matteo Scandolod43bb302021-04-20 10:19:29 -0700291 waitUntil {
292 sr_active_out = sh returnStatus: true, script: """
Matteo Scandolod43bb302021-04-20 10:19:29 -0700293 curl -sSL --user karaf:karaf -X GET http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting | jq '.state' | grep ACTIVE
294 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"
295 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"
296 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"
297 """
298 return sr_active_out == 0
299 }
300 }
Hardik Windlassc97ceae2022-05-13 10:12:55 +0530301 timeout(8) {
Matteo Scandolod43bb302021-04-20 10:19:29 -0700302 for(int i=0; i < deployment_config.hosts.src.size(); i++) {
303 for(int j=0; j < deployment_config.olts.size(); j++) {
304 def aggPort = -1
305 if(deployment_config.olts[j].serial == deployment_config.hosts.src[i].olt){
306 aggPort = deployment_config.olts[j].aggPort
307 if(aggPort == -1){
308 throw new Exception("Upstream port for the olt is not configured, field aggPort is empty")
309 }
310 sh """
Hardik Windlass728a86c2021-10-01 17:58:12 +0530311 sleep 10 # NOTE why are we sleeping?
Matteo Scandolod43bb302021-04-20 10:19:29 -0700312 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'
313 """
314 }
315 }
316 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700317 }
318 }
319 }
320 }
Matteo Scandolod43bb302021-04-20 10:19:29 -0700321 }
322 stage('Reinstall OLT software') {
323 steps {
324 script {
325 if ( params.reinstallOlt ) {
326 for(int i=0; i < deployment_config.olts.size(); i++) {
327 // NOTE what is oltDebVersion23? is that for VOLTHA-2.3? do we still need this differentiation?
328 sh returnStdout: true, script: """
Hardik Windlass6cdbfa22021-07-13 06:21:35 +0000329 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
330 if [ "${params.inBandManagement}" == "true" ]; then
Matteo Scandolod43bb302021-04-20 10:19:29 -0700331 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 -0700332 fi
Hardik Windlass6cdbfa22021-07-13 06:21:35 +0000333 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 -0700334 sleep 10
335 """
336 timeout(5) {
337 waitUntil {
338 olt_sw_present = sh returnStdout: true, script: """
Andrea Campanella272bd202021-12-17 09:46:26 +0100339 if [[ "${deployment_config.olts[i].oltDebVersion}" == *"asfvolt16"* ]]; then
Matteo Scandolod43bb302021-04-20 10:19:29 -0700340 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 +0100341 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"asgvolt64"* ]]; then
Matteo Scandolod43bb302021-04-20 10:19:29 -0700342 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 +0100343 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-1600x-w"* ]]; then
344 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'
345 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-1600g-w"* ]]; then
346 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'
347 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-3200g-w"* ]]; then
348 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 -0700349 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"sda3016ss"* ]]; then
350 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 Campanella272bd202021-12-17 09:46:26 +0100351 else
352 echo Unknown Debian package for openolt
Matteo Scandolod43bb302021-04-20 10:19:29 -0700353 fi
354 if (${deployment_config.olts[i].fortygig}); then
355 if [[ "${params.inBandManagement}" == "true" ]]; then
356 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
357 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'mkdir -p /opt/openolt/'
358 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/'
359 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'
360 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/'
361 fi
362 fi
363 """
364 return olt_sw_present.toInteger() > 0
365 }
366 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700367 }
368 }
Matteo Scandolod43bb302021-04-20 10:19:29 -0700369 }
370 }
371 }
372 stage('Restart OLT processes') {
373 steps {
374 script {
Andrea Campanellaecefbc82021-08-27 11:06:31 +0200375 //rebooting OLTs
Matteo Scandolod43bb302021-04-20 10:19:29 -0700376 for(int i=0; i < deployment_config.olts.size(); i++) {
Girish Gowdrac5a3ef82021-10-06 12:58:49 -0700377 timeout(15) {
Matteo Scandolod43bb302021-04-20 10:19:29 -0700378 sh returnStdout: true, script: """
379 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
Girish Gowdrac5a3ef82021-10-06 12:58:49 -0700380 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 -0700381 """
382 }
Andrea Campanellaecefbc82021-08-27 11:06:31 +0200383 }
384 sh returnStdout: true, script: """
385 sleep ${params.waitTimerForOltUp}
386 """
387 //Checking dev_management_deamon and openoltprocesses
388 for(int i=0; i < deployment_config.olts.size(); i++) {
389 if ( params.oltAdapterReleaseName != "open-olt" ) {
390 timeout(15) {
391 waitUntil {
392 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'"
393 return devprocess.toInteger() > 0
394 }
Matteo Scandolod43bb302021-04-20 10:19:29 -0700395 }
Andrea Campanellaecefbc82021-08-27 11:06:31 +0200396 timeout(15) {
397 waitUntil {
398 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'"
399 return openoltprocess.toInteger() > 0
400 }
Matteo Scandolod43bb302021-04-20 10:19:29 -0700401 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700402 }
403 }
404 }
405 }
406 }
407 }
408
409 post {
Matteo Scandolo0da60532021-05-06 08:59:42 -0700410 aborted {
411 getPodsInfo("$WORKSPACE/failed")
412 sh """
413 kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/failed/voltha.log || true
414 """
415 archiveArtifacts artifacts: '**/*.log,**/*.txt'
416 }
417 failure {
418 getPodsInfo("$WORKSPACE/failed")
419 sh """
420 kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/failed/voltha.logs || true
421 """
422 archiveArtifacts artifacts: '**/*.log,**/*.txt'
423 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700424 always {
425 archiveArtifacts artifacts: '*.txt'
426 }
427 }
428}