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