Joey Armstrong | df24f60 | 2023-03-02 18:18:21 -0500 | [diff] [blame] | 1 | // -*- groovy -*- |
Joey Armstrong | 980e37f | 2023-02-28 18:57:41 -0500 | [diff] [blame] | 2 | // Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
Joey Armstrong | df24f60 | 2023-03-02 18:18:21 -0500 | [diff] [blame] | 15 | // ----------------------------------------------------------------------- |
| 16 | // Intent: used to deploy VOLTHA and configure ONOS physical PODs |
| 17 | // ----------------------------------------------------------------------- |
Joey Armstrong | 980e37f | 2023-02-28 18:57:41 -0500 | [diff] [blame] | 18 | |
| 19 | // NOTE we are importing the library even if it's global so that it's |
| 20 | // easier to change the keywords during a replay |
| 21 | library identifier: 'cord-jenkins-libraries@master', |
| 22 | retriever: modernSCM([ |
| 23 | $class: 'GitSCMSource', |
| 24 | remote: 'https://gerrit.opencord.org/ci-management.git' |
| 25 | ]) |
| 26 | |
| 27 | def infraNamespace = "infra" |
| 28 | def volthaNamespace = "voltha" |
| 29 | |
Joey Armstrong | df24f60 | 2023-03-02 18:18:21 -0500 | [diff] [blame] | 30 | // ----------------------------------------------------------------------- |
| 31 | // ----------------------------------------------------------------------- |
| 32 | def getIam(String func) |
| 33 | { |
| 34 | // Cannot rely on a stack trace due to jenkins manipulation |
| 35 | String src = [ |
| 36 | 'jjb', |
| 37 | 'pipeline', |
| 38 | 'voltha', |
| 39 | 'playground', |
| 40 | 'voltha-tt-physical-functional-tests.groovy' |
| 41 | ].join('/') |
| 42 | String iam = [src, func].join('::') |
| 43 | return iam |
| 44 | } |
| 45 | |
| 46 | // ----------------------------------------------------------------------- |
| 47 | // ----------------------------------------------------------------------- |
Joey Armstrong | 980e37f | 2023-02-28 18:57:41 -0500 | [diff] [blame] | 48 | def deploy_custom_oltAdapterChart(namespace, name, chart, extraHelmFlags) { |
| 49 | sh """ |
| 50 | helm install --create-namespace --set defaults.image_pullPolicy=Always --namespace ${namespace} ${extraHelmFlags} ${name} ${chart} |
| 51 | """ |
| 52 | } |
| 53 | |
Joey Armstrong | df24f60 | 2023-03-02 18:18:21 -0500 | [diff] [blame] | 54 | pipeline |
| 55 | { |
| 56 | /* no label, executor is determined by JJB */ |
| 57 | agent |
| 58 | { |
| 59 | label "${params.buildNode}" |
Joey Armstrong | 980e37f | 2023-02-28 18:57:41 -0500 | [diff] [blame] | 60 | } |
Joey Armstrong | df24f60 | 2023-03-02 18:18:21 -0500 | [diff] [blame] | 61 | |
| 62 | options |
| 63 | { |
| 64 | timeout(time: 35, unit: 'MINUTES') |
| 65 | } |
| 66 | |
| 67 | environment |
| 68 | { |
| 69 | PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin" |
| 70 | KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf" |
| 71 | } |
| 72 | |
| 73 | stages |
| 74 | { |
| 75 | stage('IAM') |
| 76 | { |
Joey Armstrong | 0691c35 | 2023-03-02 18:36:15 -0500 | [diff] [blame] | 77 | String iam = getIam('main') |
Joey Armstrong | df24f60 | 2023-03-02 18:18:21 -0500 | [diff] [blame] | 78 | println("** ${iam}: ENTER") |
| 79 | println("** ${iam}: LEAVE") |
| 80 | } |
| 81 | |
| 82 | stage('Download Code') |
| 83 | { |
| 84 | steps { |
| 85 | getVolthaCode([ |
| 86 | branch: "${branch}", |
| 87 | volthaSystemTestsChange: "${volthaSystemTestsChange}", |
| 88 | volthaHelmChartsChange: "${volthaHelmChartsChange}", |
| 89 | ]) |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | stage ("Parse deployment configuration file") { |
| 94 | steps { |
| 95 | sh returnStdout: true, script: "rm -rf ${configBaseDir}" |
| 96 | sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}" |
| 97 | script { |
| 98 | String conf = "${configBaseDir}/${configDeploymentDir}/${configFileName}" |
| 99 | String flow = params.workFlow |
| 100 | |
| 101 | conf += (flow == 'DT') ? '-DT.yaml' |
| 102 | : (flow == 'TT') ? '-TT.yaml' |
| 103 | : '.yaml' |
| 104 | |
| 105 | deployment_config = readYaml file: conf |
| 106 | |
| 107 | /* |
| 108 | if ( params.workFlow == "DT" ) |
| 109 | { |
| 110 | conf += '-DT.yaml' |
| 111 | // deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml" |
Joey Armstrong | 980e37f | 2023-02-28 18:57:41 -0500 | [diff] [blame] | 112 | } |
| 113 | else if ( params.workFlow == "TT" ) |
| 114 | { |
| 115 | deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml" |
| 116 | } |
| 117 | else |
| 118 | { |
| 119 | deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml" |
| 120 | } |
Joey Armstrong | df24f60 | 2023-03-02 18:18:21 -0500 | [diff] [blame] | 121 | */ |
Joey Armstrong | 980e37f | 2023-02-28 18:57:41 -0500 | [diff] [blame] | 122 | } |
| 123 | } |
| 124 | } |
Joey Armstrong | df24f60 | 2023-03-02 18:18:21 -0500 | [diff] [blame] | 125 | |
Joey Armstrong | 980e37f | 2023-02-28 18:57:41 -0500 | [diff] [blame] | 126 | stage('Clean up') { |
| 127 | steps { |
| 128 | timeout(15) { |
| 129 | script { |
| 130 | helmTeardown(["default", infraNamespace, volthaNamespace]) |
| 131 | } |
| 132 | timeout(1) { |
| 133 | sh returnStdout: false, script: ''' |
| 134 | # remove orphaned port-forward from different namespaces |
| 135 | ps aux | grep port-forw | grep -v grep | awk '{print $2}' | xargs --no-run-if-empty kill -9 || true |
| 136 | ''' |
| 137 | } |
| 138 | } |
| 139 | } |
| 140 | } |
| 141 | stage('Install Voltha') { |
| 142 | steps { |
| 143 | timeout(20) { |
| 144 | installVoltctl("${branch}") |
| 145 | script { |
| 146 | // if we're downloading a voltha-helm-charts patch, then install from a local copy of the charts |
| 147 | def localCharts = false |
| 148 | if (volthaHelmChartsChange != "") { |
| 149 | localCharts = true |
| 150 | } |
| 151 | |
| 152 | // should the config file be suffixed with the workflow? see "deployment_config" |
| 153 | def localHelmFlags = "-f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/voltha/${configFileName}.yml --set global.log_level=${logLevel} " |
| 154 | |
| 155 | if (workFlow.toLowerCase() == "dt") { |
| 156 | localHelmFlags += " --set radius.enabled=false " |
| 157 | } |
| 158 | if (workFlow.toLowerCase() == "tt") { |
| 159 | localHelmFlags += " --set radius.enabled=false --set global.incremental_evto_update=true " |
| 160 | if (enableMultiUni.toBoolean()) { |
| 161 | localHelmFlags += " --set voltha-adapter-openonu.adapter_open_onu.uni_port_mask=${uniPortMask} " |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | // NOTE temporary workaround expose ONOS node ports (pod-config needs to be updated to contain these values) |
| 166 | // and to connect the ofagent to all instances of ONOS |
| 167 | localHelmFlags = localHelmFlags + " --set onos-classic.onosSshPort=30115 " + |
| 168 | "--set onos-classic.onosApiPort=30120 " + |
| 169 | "--set onos-classic.onosOfPort=31653 " + |
| 170 | "--set onos-classic.individualOpenFlowNodePorts=true " + |
| 171 | "--set voltha.onos_classic.replicas=${params.NumOfOnos}" |
| 172 | |
| 173 | if (bbsimReplicas.toInteger() != 0) { |
| 174 | localHelmFlags = localHelmFlags + " --set onu=${onuNumber},pon=${ponNumber} " |
| 175 | } |
| 176 | |
| 177 | // adding user specified helm flags at the end so they'll have priority over everything else |
| 178 | localHelmFlags = localHelmFlags + " ${extraHelmFlags}" |
| 179 | |
| 180 | def numberOfAdaptersToWait = 2 |
| 181 | |
| 182 | if(openoltAdapterChart != "onf/voltha-adapter-openolt") { |
| 183 | localHelmFlags = localHelmFlags + " --set voltha-adapter-openolt.enabled=false" |
| 184 | // We skip waiting for adapters in the volthaDeploy step because it's already waiting for |
| 185 | // both of them after the deployment of the custom olt adapter. See line 156. |
| 186 | numberOfAdaptersToWait = 0 |
| 187 | } |
| 188 | |
| 189 | volthaDeploy([ |
| 190 | workflow: workFlow.toLowerCase(), |
| 191 | extraHelmFlags: localHelmFlags, |
| 192 | localCharts: localCharts, |
| 193 | kubeconfig: "$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf", |
| 194 | onosReplica: params.NumOfOnos, |
| 195 | atomixReplica: params.NumOfAtomix, |
| 196 | kafkaReplica: params.NumOfKafka, |
| 197 | etcdReplica: params.NumOfEtcd, |
| 198 | bbsimReplica: bbsimReplicas.toInteger(), |
| 199 | withFttb: withFttb.toBoolean(), |
| 200 | adaptersToWait: numberOfAdaptersToWait, |
| 201 | ]) |
| 202 | |
| 203 | if(openoltAdapterChart != "onf/voltha-adapter-openolt"){ |
| 204 | extraHelmFlags = extraHelmFlags + " --set global.log_level=${logLevel}" |
| 205 | deploy_custom_oltAdapterChart(volthaNamespace, oltAdapterReleaseName, openoltAdapterChart, extraHelmFlags) |
| 206 | waitForAdapters([ |
| 207 | adaptersToWait: 2 |
| 208 | ]) |
| 209 | } |
| 210 | } |
| 211 | sh """ |
| 212 | 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"& |
| 213 | 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"& |
| 214 | 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"& |
| 215 | ps aux | grep port-forward |
| 216 | """ |
| 217 | getPodsInfo("$WORKSPACE") |
| 218 | } |
| 219 | } |
| 220 | } |
| 221 | stage('Push Tech-Profile') { |
| 222 | steps { |
| 223 | script { |
| 224 | if ( params.configurePod && params.profile != "Default" ) { |
| 225 | for(int i=0; i < deployment_config.olts.size(); i++) { |
| 226 | def tech_prof_directory = "XGS-PON" |
| 227 | if (deployment_config.olts[i].containsKey("board_technology")){ |
| 228 | tech_prof_directory = deployment_config.olts[i]["board_technology"] |
| 229 | } |
| 230 | timeout(1) { |
| 231 | sh returnStatus: true, script: """ |
| 232 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 233 | etcd_container=\$(kubectl get pods -n ${infraNamespace} -l app.kubernetes.io/name=etcd --no-headers | awk 'NR==1{print \$1}') |
| 234 | if [[ "${workFlow}" == "TT" ]]; then |
| 235 | kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-HSIA.json \$etcd_container:/tmp/hsia.json |
| 236 | 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' |
| 237 | kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-VoIP.json \$etcd_container:/tmp/voip.json |
| 238 | 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' |
| 239 | if [[ "${params.enableMultiUni}" == "true" ]]; then |
| 240 | 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 |
| 241 | 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' |
| 242 | 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 |
| 243 | 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' |
| 244 | else |
| 245 | kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-MCAST-AdditionalBW-None.json \$etcd_container:/tmp/mcast_additionalBW_none.json |
| 246 | 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' |
| 247 | kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-MCAST-AdditionalBW-NA.json \$etcd_container:/tmp/mcast_additionalBW_na.json |
| 248 | 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' |
| 249 | fi |
| 250 | else |
| 251 | kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-${profile}.json \$etcd_container:/tmp/flexpod.json |
| 252 | 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' |
| 253 | fi |
| 254 | """ |
| 255 | } |
| 256 | timeout(1) { |
| 257 | sh returnStatus: true, script: """ |
| 258 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 259 | etcd_container=\$(kubectl get pods -n ${infraNamespace} -l app.kubernetes.io/name=etcd --no-headers | awk 'NR==1{print \$1}') |
| 260 | kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/${tech_prof_directory}/64' |
| 261 | """ |
| 262 | } |
| 263 | } |
| 264 | } |
| 265 | } |
| 266 | } |
| 267 | } |
| 268 | stage('Push MIB templates') { |
| 269 | steps { |
| 270 | sh """ |
| 271 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 272 | etcd_container=\$(kubectl get pods -n ${infraNamespace} -l app.kubernetes.io/name=etcd --no-headers | awk 'NR==1{print \$1}') |
| 273 | kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/MIB_Alpha.json \$etcd_container:/tmp/MIB_Alpha.json |
| 274 | 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' |
| 275 | 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' |
| 276 | kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/MIB_Scom.json \$etcd_container:/tmp/MIB_Scom.json |
| 277 | 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' |
| 278 | 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' |
| 279 | """ |
| 280 | } |
| 281 | } |
| 282 | stage('Push Sadis-config') { |
| 283 | steps { |
| 284 | timeout(1) { |
| 285 | sh returnStatus: true, script: """ |
| 286 | if [[ "${workFlow}" == "DT" ]]; then |
| 287 | 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 |
| 288 | elif [[ "${workFlow}" == "TT" ]]; then |
| 289 | 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 |
| 290 | else |
| 291 | # this is the ATT case, rename the file in *-sadis-ATT.json so that we can avoid special cases and just load the file |
| 292 | 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 |
| 293 | fi |
| 294 | """ |
| 295 | } |
| 296 | } |
| 297 | } |
| 298 | stage('Switch Configurations in ONOS') { |
| 299 | steps { |
| 300 | script { |
| 301 | if ( deployment_config.fabric_switches.size() > 0 ) { |
| 302 | timeout(1) { |
| 303 | def netcfg = "$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch.json" |
| 304 | if (params.inBandManagement){ |
| 305 | netcfg = "$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch-inband.json" |
| 306 | } |
| 307 | sh """ |
| 308 | 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} |
| 309 | curl -sSL --user karaf:karaf -X POST http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting/active |
| 310 | """ |
| 311 | } |
| 312 | timeout(3) { |
| 313 | setOnosLogLevels([ |
| 314 | onosNamespace: infraNamespace, |
| 315 | apps: [ |
| 316 | 'org.opencord.dhcpl2relay', |
| 317 | 'org.opencord.olt', |
| 318 | 'org.opencord.aaa', |
| 319 | 'org.opencord.maclearner', |
| 320 | 'org.onosproject.net.flowobjective.impl.FlowObjectiveManager', |
| 321 | 'org.onosproject.net.flowobjective.impl.InOrderFlowObjectiveManager' |
| 322 | ] |
| 323 | ]) |
| 324 | waitUntil { |
| 325 | sr_active_out = sh returnStatus: true, script: """ |
| 326 | curl -sSL --user karaf:karaf -X GET http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting | jq '.state' | grep ACTIVE |
| 327 | 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" |
| 328 | 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" |
| 329 | 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" |
| 330 | """ |
| 331 | return sr_active_out == 0 |
| 332 | } |
| 333 | } |
| 334 | timeout(8) { |
| 335 | for(int i=0; i < deployment_config.hosts.src.size(); i++) { |
| 336 | for(int j=0; j < deployment_config.olts.size(); j++) { |
| 337 | def aggPort = -1 |
| 338 | if(deployment_config.olts[j].serial == deployment_config.hosts.src[i].olt){ |
| 339 | aggPort = deployment_config.olts[j].aggPort |
| 340 | if(aggPort == -1){ |
| 341 | throw new Exception("Upstream port for the olt is not configured, field aggPort is empty") |
| 342 | } |
| 343 | sh """ |
| 344 | sleep 10 # NOTE why are we sleeping? |
| 345 | 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' |
| 346 | """ |
| 347 | } |
| 348 | } |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | } |
| 353 | } |
| 354 | } |
| 355 | stage('Reinstall OLT software') { |
| 356 | steps { |
| 357 | script { |
| 358 | if ( params.reinstallOlt ) { |
| 359 | for(int i=0; i < deployment_config.olts.size(); i++) { |
| 360 | // NOTE what is oltDebVersion23? is that for VOLTHA-2.3? do we still need this differentiation? |
| 361 | sh returnStdout: true, script: """ |
| 362 | ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts |
| 363 | if [ "${params.inBandManagement}" == "true" ]; then |
| 364 | 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' |
| 365 | fi |
| 366 | 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}" |
| 367 | sleep 10 |
| 368 | """ |
| 369 | timeout(5) { |
| 370 | waitUntil { |
| 371 | olt_sw_present = sh returnStdout: true, script: """ |
| 372 | if [[ "${deployment_config.olts[i].oltDebVersion}" == *"asfvolt16"* ]]; then |
| 373 | 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' |
| 374 | elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"asgvolt64"* ]]; then |
| 375 | 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' |
| 376 | elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-1600x-w"* ]]; then |
| 377 | 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' |
| 378 | elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-1600g-w"* ]]; then |
| 379 | 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' |
| 380 | elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"rlt-3200g-w"* ]]; then |
| 381 | 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' |
| 382 | elif [[ "${deployment_config.olts[i].oltDebVersion}" == *"sda3016ss"* ]]; then |
| 383 | 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' |
| 384 | else |
| 385 | echo Unknown Debian package for openolt |
| 386 | fi |
| 387 | if (${deployment_config.olts[i].fortygig}); then |
| 388 | if [[ "${params.inBandManagement}" == "true" ]]; then |
| 389 | ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts |
| 390 | sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'mkdir -p /opt/openolt/' |
| 391 | 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/' |
| 392 | 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' |
| 393 | 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/' |
| 394 | fi |
| 395 | fi |
| 396 | """ |
| 397 | return olt_sw_present.toInteger() > 0 |
| 398 | } |
| 399 | } |
| 400 | } |
| 401 | } |
| 402 | } |
| 403 | } |
| 404 | } |
| 405 | stage('Restart OLT processes') { |
| 406 | steps { |
| 407 | script { |
| 408 | //rebooting OLTs |
| 409 | for(int i=0; i < deployment_config.olts.size(); i++) { |
| 410 | timeout(15) { |
| 411 | sh returnStdout: true, script: """ |
| 412 | ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts |
| 413 | 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 |
| 414 | """ |
| 415 | } |
| 416 | } |
| 417 | sh returnStdout: true, script: """ |
| 418 | sleep ${params.waitTimerForOltUp} |
| 419 | """ |
| 420 | //Checking dev_management_deamon and openoltprocesses |
| 421 | for(int i=0; i < deployment_config.olts.size(); i++) { |
| 422 | if ( params.oltAdapterReleaseName != "open-olt" ) { |
| 423 | timeout(15) { |
| 424 | waitUntil { |
| 425 | 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'" |
| 426 | return devprocess.toInteger() > 0 |
| 427 | } |
| 428 | } |
| 429 | timeout(15) { |
| 430 | waitUntil { |
| 431 | 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'" |
| 432 | return openoltprocess.toInteger() > 0 |
| 433 | } |
| 434 | } |
| 435 | } |
| 436 | } |
| 437 | } |
| 438 | } |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | post { |
| 443 | aborted { |
| 444 | getPodsInfo("$WORKSPACE/failed") |
| 445 | sh """ |
| 446 | kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/failed/voltha.log || true |
| 447 | """ |
| 448 | archiveArtifacts artifacts: '**/*.log,**/*.txt' |
| 449 | } |
| 450 | failure { |
| 451 | getPodsInfo("$WORKSPACE/failed") |
| 452 | sh """ |
| 453 | kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/failed/voltha.logs || true |
| 454 | """ |
| 455 | archiveArtifacts artifacts: '**/*.log,**/*.txt' |
| 456 | } |
| 457 | always { |
| 458 | archiveArtifacts artifacts: '*.txt' |
| 459 | } |
| 460 | } |
| 461 | } |