blob: 3aef911b72eebdd49cd04d3771cdf0dbb39d68ce [file] [log] [blame]
Kailash6f5acb62019-08-28 14:38:45 -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
15node ("${TestNodeName}") {
Suchitra Vemurib4f365f2020-03-27 15:09:36 -070016 def withKind = false
Andy Bavieraf5883e2020-06-03 12:54:21 -070017 def VolthaEtcdPort = '2379'
Suchitra Vemurib4f365f2020-03-27 15:09:36 -070018 if (params.withKind != null){
19 withKind = params.withKind
20 }
Andy Bavieraf5883e2020-06-03 12:54:21 -070021 if (params.VolthaEtcdPort != null){
22 VolthaEtcdPort = params.VolthaEtcdPort
23 }
Kailash6f5acb62019-08-28 14:38:45 -070024 timeout (100) {
25 try {
26 stage ("Parse deployment configuration file") {
Suchitra Vemurib4f365f2020-03-27 15:09:36 -070027 sh returnStdout: true, script: "rm -rf ${configBaseDir} voltha-system-tests kind-voltha"
Suchitra Vemurie514b8c2019-09-23 19:37:18 -070028 sh returnStdout: true, script: "git clone -b master ${cordRepoUrl}/${configBaseDir}"
Suchitra Vemurifa44e592021-03-25 11:38:41 -070029 sh returnStdout: true, script: "git clone -b master ${cordRepoUrl}/voltha-system-tests"
Suchitra Vemuria9562212020-04-10 19:32:03 -070030 sh returnStdout: true, script: "git clone -b master ${cordRepoUrl}/kind-voltha"
Suchitra Vemurib4f365f2020-03-27 15:09:36 -070031 if ( params.workFlow == "DT" ) {
32 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
33 }
Suchitra Vemuri32dea012020-07-08 16:40:06 -070034 else if ( params.workFlow == "TT" )
35 {
36 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
37 }
Suchitra Vemurib4f365f2020-03-27 15:09:36 -070038 else
39 {
40 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
41 }
Kailash6f5acb62019-08-28 14:38:45 -070042 }
43 stage('Clean up') {
Suchitra Vemuri76261d02020-05-08 16:33:32 -070044 timeout(15) {
Kailash6f5acb62019-08-28 14:38:45 -070045 sh returnStdout: true, script: """
Andrea Campanellad9891e62020-07-24 16:14:22 +020046 echo "cleaning up"
Kailash6f5acb62019-08-28 14:38:45 -070047 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Andrea Campanellad9891e62020-07-24 16:14:22 +020048 HELM_MAJOR=\$(helm version --client --short | sed -E -e 's/^.*v([0-9]+)\\.[0-9]+\\.[0-9]+.*\$/\\1/')
Matteo Scandoloa41975b2020-07-24 11:14:29 -070049 for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet|local-path-storage|cattle');
Matteo Scandolo1294aeb2019-09-24 16:20:32 -070050 do
51 echo "Purging chart: \${hchart}"
Andrea Campanellad9891e62020-07-24 16:14:22 +020052 if [ \$HELM_MAJOR -le 2 ]; then
53 helm delete --purge "\${hchart}"
54 else
55 helm uninstall "\${hchart}"
56 fi
Matteo Scandolo1294aeb2019-09-24 16:20:32 -070057 done
Andrea Campanellad9891e62020-07-24 16:14:22 +020058 if [ \$HELM_MAJOR -gt 2 ]; then
Matteo Scandoloa41975b2020-07-24 11:14:29 -070059 for hchart in \$(helm list -q -n voltha | grep -E -v 'docker-registry|mavenrepo|ponnet|local-path-storage|cattle');
Andrea Campanellad9891e62020-07-24 16:14:22 +020060 do
61 echo "Purging chart: \${hchart}"
62 if [ \$HELM_MAJOR -le 2 ]; then
63 helm delete --purge "\${hchart}"
64 else
65 helm uninstall -n voltha "\${hchart}"
66 fi
67 done
68 fi
Kailash6f5acb62019-08-28 14:38:45 -070069 """
70 timeout(5) {
71 waitUntil {
72 helm_deleted = sh returnStdout: true, script: """
Matteo Scandoloa41975b2020-07-24 11:14:29 -070073
74 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
75 HELM_MAJOR=\$(helm version --client --short | sed -E -e 's/^.*v([0-9]+)\\.[0-9]+\\.[0-9]+.*\$/\\1/')
76
77 if [ \$HELM_MAJOR -le 2 ]; then
78 helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet|local-path-storage|cattle' | wc -l
79 else
80 helm list -q --all-namespaces | grep -E -v 'docker-registry|mavenrepo|ponnet|local-path-storage|cattle' | wc -l
81 fi
Kailash6f5acb62019-08-28 14:38:45 -070082 """
83 return helm_deleted.toInteger() == 0
84 }
85 }
86 timeout(5) {
87 waitUntil {
88 kubectl_deleted = sh returnStdout: true, script: """
89 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
Matteo Scandoloa41975b2020-07-24 11:14:29 -070090 kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet|local-path-storage|cattle' | wc -l
Kailash6f5acb62019-08-28 14:38:45 -070091 """
92 return kubectl_deleted.toInteger() == 0
93 }
94 }
Suchitra Vemurib4f365f2020-03-27 15:09:36 -070095 timeout(1) {
Hung-Wei Chiu2fa15622020-04-07 16:40:35 -070096 sh returnStdout: false, script: """
97 #Remove all while true; do kubectl port-forward ...done; rules
98 for port_fwd_id in `ps -ax | grep "port-forward" | grep -E "onos|voltha" | grep "while true"| awk '{print \$1}'`;
99 do
Matteo Scandolobc27e9c2020-07-27 09:34:10 -0700100 kill -9 \$port_fwd_id || true
Hung-Wei Chiu2fa15622020-04-07 16:40:35 -0700101 done
102
103 #Remove all kubectl port-forward rules
104 for port_fwd_id in `ps -ax | grep "port-forward" | grep -E "onos|voltha" | awk '{print \$1}'`;
105 do
Matteo Scandolobc27e9c2020-07-27 09:34:10 -0700106 kill -9 \$port_fwd_id || true
Hung-Wei Chiu2fa15622020-04-07 16:40:35 -0700107 done
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700108 """
109 }
Kailash6f5acb62019-08-28 14:38:45 -0700110 }
111 }
Suchitra Vemuri1934abc2019-11-05 12:41:11 -0800112 stage('Install Voltha') {
Suchitra Vemuri76261d02020-05-08 16:33:32 -0700113 timeout(20) {
Kailash6f5acb62019-08-28 14:38:45 -0700114 sh returnStdout: true, script: """
115 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
116 cd kind-voltha/
Andy Bavier4f23d9d2020-07-02 06:14:00 -0700117 export EXTRA_HELM_FLAGS=""
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700118 if [ "${branch}" != "master" ]; then
119 cd $WORKSPACE/kind-voltha
Andy Bavier4f23d9d2020-07-02 06:14:00 -0700120 # The releases/ file also specifies EXTRA_HELM_FLAGS
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700121 source releases/${branch}
Suchitra Vemuri1934abc2019-11-05 12:41:11 -0800122 fi
Andy Bavier4f23d9d2020-07-02 06:14:00 -0700123 # Make sure that the EXTRA_HELM_FLAGS from the releases/ file appear at the end to override earlier values
124 export EXTRA_HELM_FLAGS="-f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/voltha/${configFileName}.yml \$EXTRA_HELM_FLAGS"
Andy Bavier7cee6f42019-11-05 16:49:47 -0700125
Andy Bavieraf5883e2020-06-03 12:54:21 -0700126 # JENKINS_NODE_COOKIE=dontKillMe ask Jenkins doesn't kill the proces after this job.
127 # we want the `while true; do kubectl port-forward` keep alive
128 export JENKINS_NODE_COOKIE=dontKillMe
129 export NUM_OF_OPENONU=${NumOfOpenOnu}
130 export NUM_OF_ONOS=${NumOfOnos}
131 export NUM_OF_ATOMIX=${NumOfAtomix}
Andy Bavier7cee6f42019-11-05 16:49:47 -0700132 # VOL-2194 ONOS SSH and REST ports hardcoded to 30115/30120 in tests
Andy Bavieraf5883e2020-06-03 12:54:21 -0700133 export ONOS_SSH_PORT=30115
134 export ONOS_API_PORT=30120
135 export VOLTHA_LOG_LEVEL=DEBUG
136 export WITH_SIM_ADAPTERS=n
137 export DEPLOY_K8S=no
138 export INSTALL_KUBECTL=no
139 export INSTALL_HELM=no
Matteo Scandolobc27e9c2020-07-27 09:34:10 -0700140 export WITH_RADIUS=yes
Andy Bavieraf5883e2020-06-03 12:54:21 -0700141 export FANCY=0
Matteo Scandolo2ac2d622020-07-30 11:58:23 -0700142 export SCHEDULE_ON_CONTROL_NODES=yes
Andrea Campanella252d94f2020-12-16 12:28:51 +0100143 export VOLTHA_ADAPTER_OPEN_OLT_CHART=${openoltAdapterChart}
Andy Bavieraf5883e2020-06-03 12:54:21 -0700144 # VOL-3162 Forwaring port 2379 does not work on ONF demo pod
145 export VOLTHA_ETCD_PORT=${VolthaEtcdPort}
146
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700147 if [[ "${workFlow}" == "DT" ]]; then
Andy Bavieraf5883e2020-06-03 12:54:21 -0700148 WITH_EAPOL=no WITH_DHCP=no WITH_IGMP=no WITH_RADIUS=no ./voltha up
Suchitra Vemuri32dea012020-07-08 16:40:06 -0700149 elif [[ "${workFlow}" == "TT" ]]; then
Girish Gowdra88dc4e92020-09-11 15:02:36 -0700150 WITH_EAPOL=no WITH_DHCP=yes WITH_INCREMENTAL_EVTO_UPDATE=yes WITH_IGMP=yes WITH_RADIUS=no ./voltha up
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700151 else
Andy Bavieraf5883e2020-06-03 12:54:21 -0700152 ./voltha up
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700153 fi
Suchitra Vemuric320f962021-02-12 13:45:52 -0800154 # Install BBSim when the parameter is checked
155 if ( ${installBBSim} ); then
156 helm upgrade --install -n voltha bbsim0 onf/bbsim --set olt_id=1 --set onu=${onuNumber},pon=${ponNumber}
157 fi
Andy Bavier7cee6f42019-11-05 16:49:47 -0700158
Matteo Scandolo727c7972020-04-13 13:09:25 -0700159 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.image}{'\\n'}" | sort | uniq
160 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq
Suchitra Vemuri1934abc2019-11-05 12:41:11 -0800161 kubectl get nodes -o wide
162 kubectl get pods -n voltha -o wide
Suchitra Vemuriaf0da132020-10-20 19:34:10 -0700163 kubectl get pods
Kailash6f5acb62019-08-28 14:38:45 -0700164 """
Suchitra Vemuri1934abc2019-11-05 12:41:11 -0800165 }
Kailash6f5acb62019-08-28 14:38:45 -0700166 }
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700167 if ( withKind && deployment_config.fabric_switches.size() > 0 ) {
168 stage('OpenFlow port forward for aggregation switch') {
169 timeout(1) {
170 sh returnStdout: true, script: """
171 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
172 #This uses the default route out, porperly configured is the management
173 mgmt_address=`ip route get 1 | awk '{print \$NF;exit}'`
Andrea Campanellac5f7db72020-05-08 10:58:11 +0200174 JENKINS_NODE_COOKIE=dontkill kubectl port-forward -n default service/onos-onos-classic-hs --address=\$mgmt_address 6653:6653 >> /dev/null 2>&1 &
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700175 """
176 }
177 }
178 }
179 if ( params.configurePod && params.profile != "Default" ) {
Suchitra Vemuri72680092019-10-03 12:39:20 -0700180 stage('Push Tech-Profile') {
Andrea Campanellabea02762020-04-23 10:59:08 +0200181 for(int i=0; i < deployment_config.olts.size(); i++) {
182 def tech_prof_directory = "XGS-PON"
Andrea Campanellaebf6f0d2021-01-12 13:10:29 +0100183 // If no debian package is specified we default to GPON for the ADTRAN OLT.
184 if (!deployment_config.olts[i].containsKey("oltDebVersion") || deployment_config.olts[i].oltDebVersion.contains("asgvolt64")){
Andrea Campanellabea02762020-04-23 10:59:08 +0200185 tech_prof_directory = "GPON"
186 }
187 timeout(1) {
188 out_push_tp = sh returnStatus: true, script: """
189 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Suchitra Vemuri2d045902020-06-08 18:32:19 -0700190 etcd_container=\$(kubectl get pods | grep etcd | awk 'NR==1{print \$1}')
Suchitra Vemuri32dea012020-07-08 16:40:06 -0700191 if [[ "${workFlow}" == "TT" ]]; then
192 kubectl cp $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-HSIA.json \$etcd_container:/tmp/hsia.json
193 put_result=\$(kubectl exec -it \$etcd_container -- /bin/sh -c 'cat /tmp/hsia.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/64')
194 kubectl cp $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-VoIP.json \$etcd_container:/tmp/voip.json
195 put_result=\$(kubectl exec -it \$etcd_container -- /bin/sh -c 'cat /tmp/voip.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/65')
196 kubectl cp $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-MCAST.json \$etcd_container:/tmp/mcast.json
197 put_result=\$(kubectl exec -it \$etcd_container -- /bin/sh -c 'cat /tmp/mcast.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/66')
198 else
199 kubectl cp $WORKSPACE/voltha-system-tests/tests/data/TechProfile-${profile}.json \$etcd_container:/tmp/flexpod.json
200 put_result=\$(kubectl exec -it \$etcd_container -- /bin/sh -c 'cat /tmp/flexpod.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/64')
201 fi
Matteo Scandolobc27e9c2020-07-27 09:34:10 -0700202
Andrea Campanellabea02762020-04-23 10:59:08 +0200203 """
204 return out_push_tp == 0
205 }
206 timeout(1) {
207 out_get_tp = sh returnStatus: true, script: """
Andrea Campanella85b0a8d2020-05-14 12:56:47 +0200208 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Suchitra Vemuri2d045902020-06-08 18:32:19 -0700209 etcd_container=\$(kubectl get pods | grep etcd | awk 'NR==1{print \$1}')
210 get_result=\$(kubectl exec -it \$etcd_container -- /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/${tech_prof_directory}/64')
Andrea Campanellabea02762020-04-23 10:59:08 +0200211 """
212 return out_get_tp == 0
213 }
Suchitra Vemuri72680092019-10-03 12:39:20 -0700214 }
hwchiuc77c7d22019-10-18 13:58:35 -0700215 }
216 }
217 stage('Push Sadis-config') {
218 timeout(1) {
219 sadis_out = sh returnStatus: true, script: """
Suchitra Vemuri992377e2020-06-20 18:03:49 -0700220 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
221 etcd_container=\$(kubectl get pods | grep etcd | awk 'NR==1{print \$1}')
222 kubectl cp $WORKSPACE/voltha-system-tests/tests/data/MIB_Alpha.json \$etcd_container:/tmp/MIB_Alpha.json
223 put_result=\$(kubectl exec -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')
Girish Gowdrad9302d62020-08-07 11:48:43 -0700224 kubectl cp $WORKSPACE/voltha-system-tests/tests/data/MIB_Scom.json \$etcd_container:/tmp/MIB_Scom.json
225 put_result=\$(kubectl exec -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')
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700226 if [[ "${workFlow}" == "DT" ]]; then
227 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
Suchitra Vemuri32dea012020-07-08 16:40:06 -0700228 elif [[ "${workFlow}" == "TT" ]]; then
229 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
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700230 else
Suchitra Vemuri72680092019-10-03 12:39:20 -0700231 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
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700232 fi
233 """
234 return sadis_out == 0
You Wangb9526e62019-10-07 15:25:48 -0700235 }
hwchiuc77c7d22019-10-18 13:58:35 -0700236 }
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700237 if ( deployment_config.fabric_switches.size() > 0 ) {
You Wang25e58612019-10-01 16:30:28 -0700238 stage('Switch Configurations in ONOS') {
239 timeout(1) {
Andrea Campanella817dfb82020-05-21 12:00:28 +0200240 def netcfg = "$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch.json"
241 if (params.inBandManagement){
242 netcfg = "$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch-inband.json"
243 }
You Wang25e58612019-10-01 16:30:28 -0700244 netcfg_out = sh returnStatus: true, script: """
Andrea Campanella817dfb82020-05-21 12:00:28 +0200245 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}
You Wang25e58612019-10-01 16:30:28 -0700246 curl -sSL --user karaf:karaf -X POST http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting/active
Suchitra Vemurib4f365f2020-03-27 15:09:36 -0700247
You Wang25e58612019-10-01 16:30:28 -0700248 """
249 return netcfg_out == 0
250 }
251 timeout(1) {
252 waitUntil {
253 sr_active_out = sh returnStatus: true, script: """
Matteo Scandolo7492e0a2020-08-28 10:15:38 -0700254 sshpass -p karaf ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.dhcpl2relay"
255 sshpass -p karaf ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.aaa"
256 sshpass -p karaf ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.olt"
257 sshpass -p karaf ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set DEBUG org.onosproject.net.flowobjective.impl.FlowObjectiveManager"
258 sshpass -p karaf ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set DEBUG org.onosproject.net.flowobjective.impl.InOrderFlowObjectiveManager"
You Wang25e58612019-10-01 16:30:28 -0700259 curl -sSL --user karaf:karaf -X GET http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting | jq '.state' | grep ACTIVE
Andrea Campanellae756ad32021-03-22 13:54:51 +0100260 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"
Matteo Scandolo7492e0a2020-08-28 10:15:38 -0700261 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"
262 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"
You Wang25e58612019-10-01 16:30:28 -0700263 """
264 return sr_active_out == 0
265 }
266 }
Andrea Campanellabea02762020-04-23 10:59:08 +0200267 timeout(5) {
You Wang25e58612019-10-01 16:30:28 -0700268 for(int i=0; i < deployment_config.hosts.src.size(); i++) {
Andrea Campanellabea02762020-04-23 10:59:08 +0200269 for(int j=0; j < deployment_config.olts.size(); j++) {
Andrea Campanella301ae322020-11-23 11:12:47 +0100270 def aggPort = -1
271 if(deployment_config.olts[j].serial == deployment_config.hosts.src[i].olt){
Andrea Campanellabea02762020-04-23 10:59:08 +0200272 aggPort = deployment_config.olts[j].aggPort
Andrea Campanella301ae322020-11-23 11:12:47 +0100273 if(aggPort == -1){
274 throw new Exception("Upstream port for the olt is not configured, field aggPort is empty")
275 }
276 xconnect_out = sh returnStatus: true, script: """
277 sleep 30
278 version=\$(sshpass -p karaf ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30115 karaf@${deployment_config.nodes[0].ip} "summary" | grep version)
279 sleep 10
280 if [[ \$version == *"version=2.2"* ]]; then
281 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'
282 else
283 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}", "ports": [${deployment_config.fabric_switches[0].bngPort},${aggPort}]}' 'http://${deployment_config.nodes[0].ip}:30120/onos/segmentrouting/xconnect'
284 fi
285 """
Andrea Campanellabea02762020-04-23 10:59:08 +0200286 }
Andrea Campanella301ae322020-11-23 11:12:47 +0100287
Andrea Campanellabea02762020-04-23 10:59:08 +0200288 }
You Wang25e58612019-10-01 16:30:28 -0700289 }
290 }
Kailash6f5acb62019-08-28 14:38:45 -0700291 }
Matteo Scandolo1294aeb2019-09-24 16:20:32 -0700292 }
Suchitra Vemuriaf0da132020-10-20 19:34:10 -0700293 if ( params.reinstallOlt ) {
294 stage('Reinstall OLT software') {
295 for(int i=0; i < deployment_config.olts.size(); i++) {
296 sh returnStdout: true, script: """
297 if [[ "${branch}" != "master" ]] && [[ "${params.inBandManagement}" == "true" ]]; then
298 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
299 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'
300 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].oltDebVersion23}"
301 fi
302 if [[ "${branch}" != "master" ]] && [[ "${params.inBandManagement}" == "false" ]]; then
303 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
304 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].oltDebVersion23}"
305 fi
306 if [[ "${branch}" == "master" ]] && [[ "${params.inBandManagement}" == "true" ]]; then
307 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
Suchitra Vemuri82c512b2020-10-22 12:07:34 -0700308 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'
Suchitra Vemuriaf0da132020-10-20 19:34:10 -0700309 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}"
310 fi
311 if [[ "${branch}" == "master" ]] && [[ "${params.inBandManagement}" == "false" ]]; then
312 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
313 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}"
314 fi
315 sleep 10
316 """
317 timeout(5) {
318 waitUntil {
319 olt_sw_present = sh returnStdout: true, script: """
320 if [ "${deployment_config.olts[i].oltDebVersion}" == *"asfvolt16"* ]; then
321 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'
322 else
323 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'
324 fi
325 if (${deployment_config.olts[i].fortygig}); then
326 if [[ "${params.inBandManagement}" == "true" ]]; then
327 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
328 sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'mkdir -p /opt/openolt/'
329 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/'
330 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'
331 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/'
Suchitra Vemuriaf0da132020-10-20 19:34:10 -0700332 fi
333 fi
334 """
335 return olt_sw_present.toInteger() > 0
336 }
337 }
338 }
339 }
340 stage('Restart OLT processes') {
341 for(int i=0; i < deployment_config.olts.size(); i++) {
Girish Gowdra63ae98b2021-03-15 12:38:16 -0700342 int waitTimerForOltUp = 360
343 if ( params.inBandManagement ) {
344 waitTimerForOltUp = 540
345 }
Suchitra Vemuriaf0da132020-10-20 19:34:10 -0700346 timeout(15) {
347 sh returnStdout: true, script: """
348 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
349 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' || true
Girish Gowdra63ae98b2021-03-15 12:38:16 -0700350 sleep ${waitTimerForOltUp}
Suchitra Vemuriaf0da132020-10-20 19:34:10 -0700351 """
352 }
353 timeout(15) {
354 waitUntil {
355 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'"
356 return devprocess.toInteger() > 0
357 }
358 }
359 timeout(15) {
360 waitUntil {
361 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'"
362 return openoltprocess.toInteger() > 0
363 }
364 }
365 }
366 }
367 }
368 /*if ( params.inBandManagement ) {
Suchitra Vemuriaa99e4c2020-07-15 14:33:03 -0700369 stage('Reboot OLT') {
Suchitra Vemuri36b35692020-07-15 11:48:47 -0700370 for(int i=0; i < deployment_config.olts.size(); i++) {
Suchitra Vemuricdc32d82020-07-17 12:24:46 -0700371 timeout(10) {
Suchitra Vemuri36b35692020-07-15 11:48:47 -0700372 sh returnStdout: true, script: """
373 ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
Girish Gowdra26711d52020-07-28 15:57:02 -0700374 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/startup.log; rm -f /var/log/openolt_process_watchdog.log; reboot' || true
Suchitra Vemuricdc32d82020-07-17 12:24:46 -0700375 sleep 360
Suchitra Vemuri36b35692020-07-15 11:48:47 -0700376 """
377 }
378 timeout(15) {
379 waitUntil {
380 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'"
381 return devprocess.toInteger() > 0
382 }
383 }
384 timeout(15) {
385 waitUntil {
386 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'"
387 return openoltprocess.toInteger() > 0
388 }
389 }
390 }
391 }
Suchitra Vemuriaf0da132020-10-20 19:34:10 -0700392 }*/
Suchitra Vemuri36b35692020-07-15 11:48:47 -0700393
Kailash6f5acb62019-08-28 14:38:45 -0700394 currentBuild.result = 'SUCCESS'
395 } catch (err) {
396 currentBuild.result = 'FAILURE'
397 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
398 throw err
399 }
400 echo "RESULT: ${currentBuild.result}"
401 }
402}