blob: 17d48b33b549421507c2cf2586b91be32bd718c4 [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="voltha-api" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n ${volthaNamespace} svc/voltha-voltha-api 55555:55555; done"&
182 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"&
183 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 -0700184 ps aux | grep port-forward
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700185 """
Matteo Scandolod43bb302021-04-20 10:19:29 -0700186 getPodsInfo("$WORKSPACE")
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700187 }
Matteo Scandolod43bb302021-04-20 10:19:29 -0700188 }
189 }
190 stage('Push Tech-Profile') {
191 steps {
192 script {
193 if ( params.configurePod && params.profile != "Default" ) {
194 for(int i=0; i < deployment_config.olts.size(); i++) {
195 def tech_prof_directory = "XGS-PON"
Girish Gowdrab8e98862021-07-07 14:09:13 -0700196 if (deployment_config.olts[i].containsKey("board_technology")){
Girish Gowdra28af4562021-07-07 11:52:13 -0700197 tech_prof_directory = deployment_config.olts[i]["board_technology"]
Matteo Scandolod43bb302021-04-20 10:19:29 -0700198 }
199 timeout(1) {
200 sh returnStatus: true, script: """
201 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Andrea Campanella04b393a2021-07-22 10:48:33 +0200202 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 -0700203 if [[ "${workFlow}" == "TT" ]]; then
TorstenThieme1befe442022-01-25 10:35:10 +0000204 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-HSIA.json \$etcd_container:/tmp/hsia.json
205 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'
206 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-VoIP.json \$etcd_container:/tmp/voip.json
207 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 +0000208 if [[ "${params.enableMultiUni}" == "true" ]]; then
Hardik Windlass6598b032021-07-02 10:12:01 +0000209 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
210 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'
211 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
212 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'
213 else
Hardik Windlass6598b032021-07-02 10:12:01 +0000214 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-MCAST-AdditionalBW-None.json \$etcd_container:/tmp/mcast_additionalBW_none.json
215 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'
216 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-MCAST-AdditionalBW-NA.json \$etcd_container:/tmp/mcast_additionalBW_na.json
217 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'
218 fi
Matteo Scandolod43bb302021-04-20 10:19:29 -0700219 else
220 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-${profile}.json \$etcd_container:/tmp/flexpod.json
221 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'
222 fi
223 """
224 }
225 timeout(1) {
226 sh returnStatus: true, script: """
227 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Andrea Campanella04b393a2021-07-22 10:48:33 +0200228 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 -0700229 kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/${tech_prof_directory}/64'
230 """
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700231 }
232 }
233 }
234 }
235 }
236 }
Matteo Scandolod43bb302021-04-20 10:19:29 -0700237 stage('Push MIB templates') {
238 steps {
239 sh """
240 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Andrea Campanella04b393a2021-07-22 10:48:33 +0200241 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 -0700242 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/MIB_Alpha.json \$etcd_container:/tmp/MIB_Alpha.json
243 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'
244 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'
245 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/MIB_Scom.json \$etcd_container:/tmp/MIB_Scom.json
246 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'
247 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'
248 """
249 }
250 }
251 stage('Push Sadis-config') {
252 steps {
253 timeout(1) {
254 sh returnStatus: true, script: """
255 if [[ "${workFlow}" == "DT" ]]; 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-DT.json
257 elif [[ "${workFlow}" == "TT" ]]; then
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-TT.json
259 else
260 # this is the ATT case, rename the file in *-sadis-ATT.json so that we can avoid special cases and just load the file
261 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 -0700262 fi
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700263 """
Matteo Scandolod43bb302021-04-20 10:19:29 -0700264 }
265 }
266 }
267 stage('Switch Configurations in ONOS') {
268 steps {
269 script {
270 if ( deployment_config.fabric_switches.size() > 0 ) {
271 timeout(1) {
272 def netcfg = "$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch.json"
273 if (params.inBandManagement){
274 netcfg = "$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch-inband.json"
275 }
276 sh """
277 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}
278 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 -0700279 """
Matteo Scandolod43bb302021-04-20 10:19:29 -0700280 }
Hardik Windlassc97ceae2022-05-13 10:12:55 +0530281 timeout(3) {
Matteo Scandolo857376b2021-11-05 14:53:22 -0700282 setOnosLogLevels([
283 onosNamespace: infraNamespace,
284 apps: [
285 'org.opencord.dhcpl2relay',
286 'org.opencord.olt',
287 'org.opencord.aaa',
Andrea Campanellac0762392022-03-11 15:01:13 +0100288 'org.opencord.maclearner',
Matteo Scandolo857376b2021-11-05 14:53:22 -0700289 'org.onosproject.net.flowobjective.impl.FlowObjectiveManager',
290 'org.onosproject.net.flowobjective.impl.InOrderFlowObjectiveManager'
291 ]
292 ])
Matteo Scandolod43bb302021-04-20 10:19:29 -0700293 waitUntil {
294 sr_active_out = sh returnStatus: true, script: """
Matteo Scandolod43bb302021-04-20 10:19:29 -0700295 curl -sSL --user karaf:karaf -X GET http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting | jq '.state' | grep ACTIVE
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.provider.lldp.impl.LldpLinkProvider enabled false"
297 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"
298 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"
299 """
300 return sr_active_out == 0
301 }
302 }
Hardik Windlassc97ceae2022-05-13 10:12:55 +0530303 timeout(8) {
Matteo Scandolod43bb302021-04-20 10:19:29 -0700304 for(int i=0; i < deployment_config.hosts.src.size(); i++) {
305 for(int j=0; j < deployment_config.olts.size(); j++) {
306 def aggPort = -1
307 if(deployment_config.olts[j].serial == deployment_config.hosts.src[i].olt){
308 aggPort = deployment_config.olts[j].aggPort
309 if(aggPort == -1){
310 throw new Exception("Upstream port for the olt is not configured, field aggPort is empty")
311 }
312 sh """
Hardik Windlass728a86c2021-10-01 17:58:12 +0530313 sleep 10 # NOTE why are we sleeping?
Matteo Scandolod43bb302021-04-20 10:19:29 -0700314 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'
315 """
316 }
317 }
318 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700319 }
320 }
321 }
322 }
Matteo Scandolod43bb302021-04-20 10:19:29 -0700323 }
324 stage('Reinstall OLT software') {
325 steps {
326 script {
327 if ( params.reinstallOlt ) {
328 for(int i=0; i < deployment_config.olts.size(); i++) {
329 // NOTE what is oltDebVersion23? is that for VOLTHA-2.3? do we still need this differentiation?
330 sh returnStdout: true, script: """
Hardik Windlass6cdbfa22021-07-13 06:21:35 +0000331 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
332 if [ "${params.inBandManagement}" == "true" ]; then
Matteo Scandolod43bb302021-04-20 10:19:29 -0700333 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 -0700334 fi
Hardik Windlass6cdbfa22021-07-13 06:21:35 +0000335 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 -0700336 sleep 10
337 """
338 timeout(5) {
339 waitUntil {
340 olt_sw_present = sh returnStdout: true, script: """
Andrea Campanella272bd202021-12-17 09:46:26 +0100341 if [[ "${deployment_config.olts[i].oltDebVersion}" == *"asfvolt16"* ]]; 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 asfvolt16 | wc -l'
Andrea Campanella272bd202021-12-17 09:46:26 +0100343 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"asgvolt64"* ]]; then
Matteo Scandolod43bb302021-04-20 10:19:29 -0700344 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 +0100345 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-1600x-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-1600x-w | wc -l'
347 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-1600g-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-1600g-w | wc -l'
349 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-3200g-w"* ]]; then
350 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 -0700351 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"sda3016ss"* ]]; then
352 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 +0100353 else
354 echo Unknown Debian package for openolt
Matteo Scandolod43bb302021-04-20 10:19:29 -0700355 fi
356 if (${deployment_config.olts[i].fortygig}); then
357 if [[ "${params.inBandManagement}" == "true" ]]; then
358 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
359 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'mkdir -p /opt/openolt/'
360 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/'
361 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'
362 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/'
363 fi
364 fi
365 """
366 return olt_sw_present.toInteger() > 0
367 }
368 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700369 }
370 }
Matteo Scandolod43bb302021-04-20 10:19:29 -0700371 }
372 }
373 }
374 stage('Restart OLT processes') {
375 steps {
376 script {
Andrea Campanellaecefbc82021-08-27 11:06:31 +0200377 //rebooting OLTs
Matteo Scandolod43bb302021-04-20 10:19:29 -0700378 for(int i=0; i < deployment_config.olts.size(); i++) {
Girish Gowdrac5a3ef82021-10-06 12:58:49 -0700379 timeout(15) {
Matteo Scandolod43bb302021-04-20 10:19:29 -0700380 sh returnStdout: true, script: """
381 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
Girish Gowdrac5a3ef82021-10-06 12:58:49 -0700382 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 -0700383 """
384 }
Andrea Campanellaecefbc82021-08-27 11:06:31 +0200385 }
386 sh returnStdout: true, script: """
387 sleep ${params.waitTimerForOltUp}
388 """
389 //Checking dev_management_deamon and openoltprocesses
390 for(int i=0; i < deployment_config.olts.size(); i++) {
391 if ( params.oltAdapterReleaseName != "open-olt" ) {
392 timeout(15) {
393 waitUntil {
394 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'"
395 return devprocess.toInteger() > 0
396 }
Matteo Scandolod43bb302021-04-20 10:19:29 -0700397 }
Andrea Campanellaecefbc82021-08-27 11:06:31 +0200398 timeout(15) {
399 waitUntil {
400 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'"
401 return openoltprocess.toInteger() > 0
402 }
Matteo Scandolod43bb302021-04-20 10:19:29 -0700403 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700404 }
405 }
406 }
407 }
408 }
409 }
410
411 post {
Matteo Scandolo0da60532021-05-06 08:59:42 -0700412 aborted {
413 getPodsInfo("$WORKSPACE/failed")
414 sh """
415 kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/failed/voltha.log || true
416 """
417 archiveArtifacts artifacts: '**/*.log,**/*.txt'
418 }
419 failure {
420 getPodsInfo("$WORKSPACE/failed")
421 sh """
422 kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/failed/voltha.logs || true
423 """
424 archiveArtifacts artifacts: '**/*.log,**/*.txt'
425 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700426 always {
427 archiveArtifacts artifacts: '*.txt'
428 }
429 }
430}