blob: 9dfb58869f330ab827461a74b00dd35374bab6e8 [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
Jan Klare07c40822023-09-28 12:58:06 +000019
Matteo Scandolod82d1de2021-04-06 14:55:58 -070020library identifier: 'cord-jenkins-libraries@master',
21 retriever: modernSCM([
22 $class: 'GitSCMSource',
23 remote: 'https://gerrit.opencord.org/ci-management.git'
24])
25
Joey Armstrong6c0b8552023-06-28 17:41:48 -040026// -----------------------------------------------------------------------
27// -----------------------------------------------------------------------
28def getIam(String func)
29{
30 // Cannot rely on a stack trace due to jenkins manipulation
31 String src = 'jjb/pipeline/master/physical-build.groovy'
32 String iam = [src, func].join('::')
33 return iam
34}
35
Matteo Scandolod82d1de2021-04-06 14:55:58 -070036def infraNamespace = "infra"
37def volthaNamespace = "voltha"
38
Joey Armstrong6c0b8552023-06-28 17:41:48 -040039// -----------------------------------------------------------------------
40// -----------------------------------------------------------------------
Andrea Campanella20361592021-08-26 18:45:28 +020041def deploy_custom_oltAdapterChart(namespace, name, chart, extraHelmFlags) {
Joey Armstrong6c0b8552023-06-28 17:41:48 -040042 String iam = getIam('deploy_custom_oltAdapterChart')
43 println("** ${iam}: ENTER")
44
45 sh """
Andrea Campanella20361592021-08-26 18:45:28 +020046 helm install --create-namespace --set defaults.image_pullPolicy=Always --namespace ${namespace} ${extraHelmFlags} ${name} ${chart}
47 """
Joey Armstrong6c0b8552023-06-28 17:41:48 -040048
49 println("** ${iam}: LEAVE")
50 return
Andrea Campanella20361592021-08-26 18:45:28 +020051}
52
Matteo Scandolod82d1de2021-04-06 14:55:58 -070053pipeline {
54
55 /* no label, executor is determined by JJB */
56 agent {
57 label "${params.buildNode}"
58 }
59 options {
60 timeout(time: 35, unit: 'MINUTES')
61 }
62 environment {
63 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 -070064 KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf"
Matteo Scandolod82d1de2021-04-06 14:55:58 -070065 }
66
67 stages{
68 stage('Download Code') {
Matteo Scandolod43bb302021-04-20 10:19:29 -070069 steps {
70 getVolthaCode([
71 branch: "${branch}",
Hardik Windlass791917b2021-05-28 04:55:37 +000072 volthaSystemTestsChange: "${volthaSystemTestsChange}",
Matteo Scandolod43bb302021-04-20 10:19:29 -070073 volthaHelmChartsChange: "${volthaHelmChartsChange}",
74 ])
75 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -070076 }
77 stage ("Parse deployment configuration file") {
Matteo Scandolod43bb302021-04-20 10:19:29 -070078 steps {
79 sh returnStdout: true, script: "rm -rf ${configBaseDir}"
Hardik Windlass6f854a12021-07-12 13:20:21 +000080 sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
Matteo Scandolod43bb302021-04-20 10:19:29 -070081 script {
82 if ( params.workFlow == "DT" ) {
83 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
84 }
85 else if ( params.workFlow == "TT" )
86 {
87 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
88 }
89 else
90 {
91 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
92 }
93 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -070094 }
95 }
96 stage('Clean up') {
Matteo Scandolod43bb302021-04-20 10:19:29 -070097 steps {
98 timeout(15) {
99 script {
100 helmTeardown(["default", infraNamespace, volthaNamespace])
101 }
102 timeout(1) {
103 sh returnStdout: false, script: '''
Matteo Scandolo16bb6fe2021-04-26 13:15:39 -0700104 # remove orphaned port-forward from different namespaces
Andrea Campanella4c8af942021-05-12 10:12:13 +0200105 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 -0700106 '''
107 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700108 }
109 }
110 }
111 stage('Install Voltha') {
Matteo Scandolod43bb302021-04-20 10:19:29 -0700112 steps {
113 timeout(20) {
Hardik Windlass9658cd22021-10-25 11:13:25 +0000114 installVoltctl("${branch}")
Matteo Scandolod43bb302021-04-20 10:19:29 -0700115 script {
116 // if we're downloading a voltha-helm-charts patch, then install from a local copy of the charts
117 def localCharts = false
118 if (volthaHelmChartsChange != "") {
119 localCharts = true
120 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700121
Matteo Scandolo16bb6fe2021-04-26 13:15:39 -0700122 // should the config file be suffixed with the workflow? see "deployment_config"
Matteo Scandolod47bfb22021-05-24 09:40:05 -0700123 def localHelmFlags = "-f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/voltha/${configFileName}.yml --set global.log_level=${logLevel} "
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700124
Matteo Scandolo16bb6fe2021-04-26 13:15:39 -0700125 if (workFlow.toLowerCase() == "dt") {
Matteo Scandolod47bfb22021-05-24 09:40:05 -0700126 localHelmFlags += " --set radius.enabled=false "
Matteo Scandolo16bb6fe2021-04-26 13:15:39 -0700127 }
128 if (workFlow.toLowerCase() == "tt") {
Matteo Scandolod47bfb22021-05-24 09:40:05 -0700129 localHelmFlags += " --set radius.enabled=false --set global.incremental_evto_update=true "
Hardik Windlassb6e6a3a2021-07-02 17:22:01 +0000130 if (enableMultiUni.toBoolean()) {
Hardik Windlass6598b032021-07-02 10:12:01 +0000131 localHelmFlags += " --set voltha-adapter-openonu.adapter_open_onu.uni_port_mask=${uniPortMask} "
132 }
Matteo Scandolo16bb6fe2021-04-26 13:15:39 -0700133 }
134
Matteo Scandolod43bb302021-04-20 10:19:29 -0700135 // NOTE temporary workaround expose ONOS node ports (pod-config needs to be updated to contain these values)
Andrea Campanella07ec1e22021-06-04 16:18:41 +0200136 // and to connect the ofagent to all instances of ONOS
Matteo Scandolod47bfb22021-05-24 09:40:05 -0700137 localHelmFlags = localHelmFlags + " --set onos-classic.onosSshPort=30115 " +
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700138 "--set onos-classic.onosApiPort=30120 " +
139 "--set onos-classic.onosOfPort=31653 " +
Andrea Campanella07ec1e22021-06-04 16:18:41 +0200140 "--set onos-classic.individualOpenFlowNodePorts=true " +
141 "--set voltha.onos_classic.replicas=${params.NumOfOnos}"
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700142
Hardik Windlass908533a2021-05-24 16:35:58 +0000143 if (bbsimReplicas.toInteger() != 0) {
Matteo Scandolod47bfb22021-05-24 09:40:05 -0700144 localHelmFlags = localHelmFlags + " --set onu=${onuNumber},pon=${ponNumber} "
Hardik Windlassc7379022021-05-12 13:52:24 +0530145 }
146
Matteo Scandolod47bfb22021-05-24 09:40:05 -0700147 // adding user specified helm flags at the end so they'll have priority over everything else
Andrea Campanellad4ab9502021-05-25 10:53:58 +0200148 localHelmFlags = localHelmFlags + " ${extraHelmFlags}"
Matteo Scandolod47bfb22021-05-24 09:40:05 -0700149
Andrea Campanella365ea1e2021-09-28 10:50:01 +0200150 def numberOfAdaptersToWait = 2
151
Andrea Campanellace8aa762021-08-27 09:32:22 +0200152 if(openoltAdapterChart != "onf/voltha-adapter-openolt") {
Andrea Campanella20361592021-08-26 18:45:28 +0200153 localHelmFlags = localHelmFlags + " --set voltha-adapter-openolt.enabled=false"
Andrea Campanella365ea1e2021-09-28 10:50:01 +0200154 // We skip waiting for adapters in the volthaDeploy step because it's already waiting for
155 // both of them after the deployment of the custom olt adapter. See line 156.
156 numberOfAdaptersToWait = 0
Andrea Campanella20361592021-08-26 18:45:28 +0200157 }
158
Matteo Scandolod43bb302021-04-20 10:19:29 -0700159 volthaDeploy([
160 workflow: workFlow.toLowerCase(),
Matteo Scandolod47bfb22021-05-24 09:40:05 -0700161 extraHelmFlags: localHelmFlags,
Matteo Scandolod43bb302021-04-20 10:19:29 -0700162 localCharts: localCharts,
163 kubeconfig: "$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf",
164 onosReplica: params.NumOfOnos,
165 atomixReplica: params.NumOfAtomix,
Hardik Windlassc7379022021-05-12 13:52:24 +0530166 kafkaReplica: params.NumOfKafka,
Hardik Windlass1685e5b2021-05-13 14:07:44 +0530167 etcdReplica: params.NumOfEtcd,
Hardik Windlass908533a2021-05-24 16:35:58 +0000168 bbsimReplica: bbsimReplicas.toInteger(),
Hardik Windlassc97ceae2022-05-13 10:12:55 +0530169 withFttb: withFttb.toBoolean(),
Andrea Campanella365ea1e2021-09-28 10:50:01 +0200170 adaptersToWait: numberOfAdaptersToWait,
Matteo Scandolod43bb302021-04-20 10:19:29 -0700171 ])
Andrea Campanella20361592021-08-26 18:45:28 +0200172
Andrea Campanella365ea1e2021-09-28 10:50:01 +0200173 if(openoltAdapterChart != "onf/voltha-adapter-openolt"){
174 extraHelmFlags = extraHelmFlags + " --set global.log_level=${logLevel}"
175 deploy_custom_oltAdapterChart(volthaNamespace, oltAdapterReleaseName, openoltAdapterChart, extraHelmFlags)
176 waitForAdapters([
177 adaptersToWait: 2
178 ])
179 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700180 }
181 sh """
Matteo Scandolo79f133f2021-04-27 13:53:21 -0700182 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"&
183 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"&
184 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 -0700185 ps aux | grep port-forward
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700186 """
Matteo Scandolod43bb302021-04-20 10:19:29 -0700187 getPodsInfo("$WORKSPACE")
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700188 }
Matteo Scandolod43bb302021-04-20 10:19:29 -0700189 }
190 }
191 stage('Push Tech-Profile') {
192 steps {
193 script {
194 if ( params.configurePod && params.profile != "Default" ) {
195 for(int i=0; i < deployment_config.olts.size(); i++) {
196 def tech_prof_directory = "XGS-PON"
Girish Gowdrab8e98862021-07-07 14:09:13 -0700197 if (deployment_config.olts[i].containsKey("board_technology")){
Girish Gowdra28af4562021-07-07 11:52:13 -0700198 tech_prof_directory = deployment_config.olts[i]["board_technology"]
Matteo Scandolod43bb302021-04-20 10:19:29 -0700199 }
200 timeout(1) {
201 sh returnStatus: true, script: """
202 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Andrea Campanella04b393a2021-07-22 10:48:33 +0200203 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 -0700204 if [[ "${workFlow}" == "TT" ]]; then
TorstenThieme1befe442022-01-25 10:35:10 +0000205 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-HSIA.json \$etcd_container:/tmp/hsia.json
206 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'
207 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-VoIP.json \$etcd_container:/tmp/voip.json
208 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 +0000209 if [[ "${params.enableMultiUni}" == "true" ]]; then
Hardik Windlass6598b032021-07-02 10:12:01 +0000210 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
211 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'
212 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
213 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'
214 else
Hardik Windlass6598b032021-07-02 10:12:01 +0000215 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-MCAST-AdditionalBW-None.json \$etcd_container:/tmp/mcast_additionalBW_none.json
216 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'
217 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-MCAST-AdditionalBW-NA.json \$etcd_container:/tmp/mcast_additionalBW_na.json
218 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'
219 fi
Matteo Scandolod43bb302021-04-20 10:19:29 -0700220 else
221 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-${profile}.json \$etcd_container:/tmp/flexpod.json
222 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'
223 fi
224 """
225 }
226 timeout(1) {
227 sh returnStatus: true, script: """
228 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Andrea Campanella04b393a2021-07-22 10:48:33 +0200229 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 -0700230 kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/${tech_prof_directory}/64'
231 """
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700232 }
233 }
234 }
235 }
236 }
237 }
Matteo Scandolod43bb302021-04-20 10:19:29 -0700238 stage('Push MIB templates') {
239 steps {
240 sh """
241 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Andrea Campanella04b393a2021-07-22 10:48:33 +0200242 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 -0700243 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/MIB_Alpha.json \$etcd_container:/tmp/MIB_Alpha.json
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/go_templates/BRCM/BVM4K00BRA0915-0083/5023_020O02414'
245 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'
246 kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/MIB_Scom.json \$etcd_container:/tmp/MIB_Scom.json
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/go_templates/SCOM/Glasfaser-Modem/090140.1.0.304'
248 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'
249 """
250 }
251 }
252 stage('Push Sadis-config') {
253 steps {
254 timeout(1) {
255 sh returnStatus: true, script: """
256 if [[ "${workFlow}" == "DT" ]]; then
257 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
258 elif [[ "${workFlow}" == "TT" ]]; then
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-TT.json
260 else
261 # this is the ATT case, rename the file in *-sadis-ATT.json so that we can avoid special cases and just load the file
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 @$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-sadis.json
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700263 fi
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700264 """
Matteo Scandolod43bb302021-04-20 10:19:29 -0700265 }
266 }
267 }
268 stage('Switch Configurations in ONOS') {
269 steps {
270 script {
271 if ( deployment_config.fabric_switches.size() > 0 ) {
272 timeout(1) {
273 def netcfg = "$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch.json"
274 if (params.inBandManagement){
275 netcfg = "$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch-inband.json"
276 }
277 sh """
278 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}
279 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 -0700280 """
Matteo Scandolod43bb302021-04-20 10:19:29 -0700281 }
Hardik Windlassc97ceae2022-05-13 10:12:55 +0530282 timeout(3) {
Matteo Scandolo857376b2021-11-05 14:53:22 -0700283 setOnosLogLevels([
284 onosNamespace: infraNamespace,
285 apps: [
286 'org.opencord.dhcpl2relay',
287 'org.opencord.olt',
288 'org.opencord.aaa',
Andrea Campanellac0762392022-03-11 15:01:13 +0100289 'org.opencord.maclearner',
Matteo Scandolo857376b2021-11-05 14:53:22 -0700290 'org.onosproject.net.flowobjective.impl.FlowObjectiveManager',
291 'org.onosproject.net.flowobjective.impl.InOrderFlowObjectiveManager'
292 ]
293 ])
Matteo Scandolod43bb302021-04-20 10:19:29 -0700294 waitUntil {
295 sr_active_out = sh returnStatus: true, script: """
Matteo Scandolod43bb302021-04-20 10:19:29 -0700296 curl -sSL --user karaf:karaf -X GET http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting | jq '.state' | grep ACTIVE
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.provider.lldp.impl.LldpLinkProvider enabled 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.flow.impl.FlowRuleManager purgeOnDisconnection false"
299 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"
300 """
301 return sr_active_out == 0
302 }
303 }
Hardik Windlassc97ceae2022-05-13 10:12:55 +0530304 timeout(8) {
Matteo Scandolod43bb302021-04-20 10:19:29 -0700305 for(int i=0; i < deployment_config.hosts.src.size(); i++) {
306 for(int j=0; j < deployment_config.olts.size(); j++) {
307 def aggPort = -1
308 if(deployment_config.olts[j].serial == deployment_config.hosts.src[i].olt){
309 aggPort = deployment_config.olts[j].aggPort
310 if(aggPort == -1){
311 throw new Exception("Upstream port for the olt is not configured, field aggPort is empty")
312 }
313 sh """
Hardik Windlass728a86c2021-10-01 17:58:12 +0530314 sleep 10 # NOTE why are we sleeping?
Matteo Scandolod43bb302021-04-20 10:19:29 -0700315 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'
316 """
317 }
318 }
319 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700320 }
321 }
322 }
323 }
Matteo Scandolod43bb302021-04-20 10:19:29 -0700324 }
325 stage('Reinstall OLT software') {
326 steps {
327 script {
328 if ( params.reinstallOlt ) {
329 for(int i=0; i < deployment_config.olts.size(); i++) {
330 // NOTE what is oltDebVersion23? is that for VOLTHA-2.3? do we still need this differentiation?
331 sh returnStdout: true, script: """
Hardik Windlass6cdbfa22021-07-13 06:21:35 +0000332 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
333 if [ "${params.inBandManagement}" == "true" ]; then
Matteo Scandolod43bb302021-04-20 10:19:29 -0700334 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 -0700335 fi
Hardik Windlass6cdbfa22021-07-13 06:21:35 +0000336 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 -0700337 sleep 10
338 """
339 timeout(5) {
340 waitUntil {
341 olt_sw_present = sh returnStdout: true, script: """
Andrea Campanella272bd202021-12-17 09:46:26 +0100342 if [[ "${deployment_config.olts[i].oltDebVersion}" == *"asfvolt16"* ]]; then
Matteo Scandolod43bb302021-04-20 10:19:29 -0700343 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 +0100344 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"asgvolt64"* ]]; then
Matteo Scandolod43bb302021-04-20 10:19:29 -0700345 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 +0100346 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-1600x-w"* ]]; then
347 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'
348 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-1600g-w"* ]]; then
349 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'
350 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-3200g-w"* ]]; then
351 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 -0700352 elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"sda3016ss"* ]]; then
353 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 +0100354 else
355 echo Unknown Debian package for openolt
Matteo Scandolod43bb302021-04-20 10:19:29 -0700356 fi
357 if (${deployment_config.olts[i].fortygig}); then
358 if [[ "${params.inBandManagement}" == "true" ]]; then
359 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
360 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'mkdir -p /opt/openolt/'
361 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/'
362 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'
363 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/'
364 fi
365 fi
366 """
367 return olt_sw_present.toInteger() > 0
368 }
369 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700370 }
371 }
Matteo Scandolod43bb302021-04-20 10:19:29 -0700372 }
373 }
374 }
375 stage('Restart OLT processes') {
376 steps {
377 script {
Andrea Campanellaecefbc82021-08-27 11:06:31 +0200378 //rebooting OLTs
Matteo Scandolod43bb302021-04-20 10:19:29 -0700379 for(int i=0; i < deployment_config.olts.size(); i++) {
Girish Gowdrac5a3ef82021-10-06 12:58:49 -0700380 timeout(15) {
Matteo Scandolod43bb302021-04-20 10:19:29 -0700381 sh returnStdout: true, script: """
382 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
Girish Gowdrac5a3ef82021-10-06 12:58:49 -0700383 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 -0700384 """
385 }
Andrea Campanellaecefbc82021-08-27 11:06:31 +0200386 }
387 sh returnStdout: true, script: """
388 sleep ${params.waitTimerForOltUp}
389 """
390 //Checking dev_management_deamon and openoltprocesses
391 for(int i=0; i < deployment_config.olts.size(); i++) {
392 if ( params.oltAdapterReleaseName != "open-olt" ) {
393 timeout(15) {
394 waitUntil {
395 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'"
396 return devprocess.toInteger() > 0
397 }
Matteo Scandolod43bb302021-04-20 10:19:29 -0700398 }
Andrea Campanellaecefbc82021-08-27 11:06:31 +0200399 timeout(15) {
400 waitUntil {
401 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'"
402 return openoltprocess.toInteger() > 0
403 }
Matteo Scandolod43bb302021-04-20 10:19:29 -0700404 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700405 }
406 }
407 }
408 }
409 }
410 }
411
412 post {
Matteo Scandolo0da60532021-05-06 08:59:42 -0700413 aborted {
414 getPodsInfo("$WORKSPACE/failed")
415 sh """
416 kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/failed/voltha.log || true
417 """
418 archiveArtifacts artifacts: '**/*.log,**/*.txt'
419 }
420 failure {
421 getPodsInfo("$WORKSPACE/failed")
422 sh """
423 kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/failed/voltha.logs || true
424 """
425 archiveArtifacts artifacts: '**/*.log,**/*.txt'
426 }
Matteo Scandolod82d1de2021-04-06 14:55:58 -0700427 always {
428 archiveArtifacts artifacts: '*.txt'
429 }
430 }
431}