Joey Armstrong | 96158a9 | 2022-11-25 10:36:06 -0500 | [diff] [blame] | 1 | #!/usr/bin/env groovy |
Joey Armstrong | 7987c11 | 2022-12-05 12:42:43 -0500 | [diff] [blame] | 2 | // ----------------------------------------------------------------------- |
Joey Armstrong | af679da | 2023-01-31 14:22:41 -0500 | [diff] [blame] | 3 | // Copyright 2021-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. |
| 16 | // ----------------------------------------------------------------------- |
| 17 | |
| 18 | // ----------------------------------------------------------------------- |
Joey Armstrong | 7987c11 | 2022-12-05 12:42:43 -0500 | [diff] [blame] | 19 | // ----------------------------------------------------------------------- |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 20 | String getIam(String func) { |
Joey Armstrong | 7987c11 | 2022-12-05 12:42:43 -0500 | [diff] [blame] | 21 | // Cannot rely on a stack trace due to jenkins manipulation |
| 22 | String src = 'vars/volthaStackDeploy.groovy' |
| 23 | String iam = [src, func].join('::') |
| 24 | return iam |
| 25 | } |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 26 | |
Joey Armstrong | 7987c11 | 2022-12-05 12:42:43 -0500 | [diff] [blame] | 27 | // ----------------------------------------------------------------------- |
Joey Armstrong | 74ec08c | 2023-08-31 11:25:57 -0400 | [diff] [blame] | 28 | // Intent: Log progress message |
| 29 | // ----------------------------------------------------------------------- |
| 30 | void enter(String name) { |
| 31 | // Announce ourselves for log usability |
| 32 | String iam = getIam(name) |
| 33 | println("${iam}: ENTER") |
| 34 | return |
| 35 | } |
| 36 | |
| 37 | // ----------------------------------------------------------------------- |
| 38 | // Intent: Log progress message |
| 39 | // ----------------------------------------------------------------------- |
| 40 | void leave(String name) { |
| 41 | // Announce ourselves for log usability |
| 42 | String iam = getIam(name) |
| 43 | println("${iam}: LEAVE") |
| 44 | return |
| 45 | } |
| 46 | |
| 47 | // ----------------------------------------------------------------------- |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 48 | // Intent: |
Joey Armstrong | 7987c11 | 2022-12-05 12:42:43 -0500 | [diff] [blame] | 49 | // ----------------------------------------------------------------------- |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 50 | void deployVolthaStack(Map cfg) { |
| 51 | enter('deployVolthaStack') |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 52 | |
Joey Armstrong | 74ec08c | 2023-08-31 11:25:57 -0400 | [diff] [blame] | 53 | sh(label : "Create VOLTHA Stack ${cfg.stackName}, (namespace=${cfg.volthaNamespace})", |
| 54 | script : """ |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 55 | |
| 56 | helm upgrade --install --create-namespace \ |
| 57 | -n ${cfg.volthaNamespace} ${cfg.stackName} ${cfg.volthaStackChart} \ |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 58 | --set global.stack_name=${cfg.stackName} \ |
| 59 | --set global.voltha_infra_name=voltha-infra \ |
Matteo Scandolo | 529e882 | 2021-07-21 10:20:18 -0700 | [diff] [blame] | 60 | --set voltha.onos_classic.replicas=${cfg.onosReplica} \ |
Jan Klare | 7b06523 | 2023-09-22 16:23:48 +0200 | [diff] [blame] | 61 | --set voltha.ingress.enabled=true |
| 62 | --set voltha.ingress.enableVirtualHosts=true |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 63 | --set global.voltha_infra_namespace=${cfg.infraNamespace} \ |
Matteo Scandolo | ed1afdd | 2021-04-02 16:25:45 -0700 | [diff] [blame] | 64 | ${cfg.extraHelmFlags} |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 65 | """) |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 66 | |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 67 | for (int i = 0; i < cfg.bbsimReplica; i++) { |
Joey Armstrong | 74ec08c | 2023-08-31 11:25:57 -0400 | [diff] [blame] | 68 | // NOTE we don't need to update the tag for DT |
| 69 | script { |
| 70 | sh(label : "Create config[$i]: bbsimCfg${cfg.stackId}${i}.yaml", |
| 71 | script : "rm -f $WORKSPACE/bbsimCfg${cfg.stackId}${i}.yaml", |
| 72 | ) |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 73 | |
Joey Armstrong | 8d12f65 | 2023-09-13 18:25:33 -0400 | [diff] [blame] | 74 | if (cfg.workflow == 'att' || cfg.workflow == 'tt') { |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 75 | int startingStag = 900 |
Joey Armstrong | 6f50765 | 2023-09-18 10:35:07 -0400 | [diff] [blame] | 76 | def serviceConfigFile = cfg.workflow // type(?) String |
Joey Armstrong | 74ec08c | 2023-08-31 11:25:57 -0400 | [diff] [blame] | 77 | if (cfg.withMacLearning && cfg.workflow == 'tt') { |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 78 | serviceConfigFile = 'tt-maclearner' |
Joey Armstrong | 74ec08c | 2023-08-31 11:25:57 -0400 | [diff] [blame] | 79 | } |
Joey Armstrong | 6f50765 | 2023-09-18 10:35:07 -0400 | [diff] [blame] | 80 | // bbsimCfg: type(?) Map |
Joey Armstrong | 74ec08c | 2023-08-31 11:25:57 -0400 | [diff] [blame] | 81 | def bbsimCfg = readYaml file: "$WORKSPACE/voltha-helm-charts/examples/${serviceConfigFile}-values.yaml" |
| 82 | // NOTE we assume that the only service that needs a different s_tag is the first one in the list |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 83 | bbsimCfg['servicesConfig']['services'][0]['s_tag'] = startingStag + i |
Joey Armstrong | 74ec08c | 2023-08-31 11:25:57 -0400 | [diff] [blame] | 84 | println "Using BBSim Service config ${bbsimCfg['servicesConfig']}" |
| 85 | writeYaml file: "$WORKSPACE/bbsimCfg${cfg.stackId}${i}.yaml", data: bbsimCfg |
| 86 | } else { |
| 87 | // NOTE if it's DT just copy the file over |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 88 | sh(label : 'DT install', |
| 89 | script : """ |
| 90 | cp $WORKSPACE/voltha-helm-charts/examples/${cfg.workflow}-values.yaml \ |
| 91 | $WORKSPACE/bbsimCfg${cfg.stackId}${i}.yaml |
| 92 | """) |
| 93 | } // if (cfg) |
| 94 | } // script |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 95 | |
Joey Armstrong | 74ec08c | 2023-08-31 11:25:57 -0400 | [diff] [blame] | 96 | sh(label : "HELM: Create namespace=${cfg.volthaNamespace} bbsim${i}", |
| 97 | script : """ |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 98 | helm upgrade --install --create-namespace -n ${cfg.volthaNamespace} bbsim${i} ${cfg.bbsimChart} \ |
Matteo Scandolo | 0ce69f1 | 2021-05-04 08:44:53 -0700 | [diff] [blame] | 99 | --set olt_id="${cfg.stackId}${i}" \ |
| 100 | -f $WORKSPACE/bbsimCfg${cfg.stackId}${i}.yaml \ |
| 101 | ${cfg.extraHelmFlags} |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 102 | """) |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 103 | } // for |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 104 | |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 105 | leave('deployVolthaStack') |
| 106 | return |
| 107 | } |
Matteo Scandolo | 937f479 | 2021-09-24 11:05:52 -0700 | [diff] [blame] | 108 | |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 109 | // ----------------------------------------------------------------------- |
| 110 | // Intent: Wait until the pod completed, meaning ONOS fully deployed |
| 111 | // ----------------------------------------------------------------------- |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 112 | // Todo: Move logic like this into a standalone script. |
| 113 | // Use jenkins stash or native JJB logic to publish out to nodes. |
| 114 | // ----------------------------------------------------------------------- |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 115 | void launchVolthaStack(Map cfg) { |
| 116 | enter('launchVolthaStack') |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 117 | |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 118 | /* ----------------------------------------------------------------------- |
| 119 | * % kubectl get pods |
| 120 | 17:40:15 bbsim0-868479698c-z66mk 0/1 ContainerCreating 0 6s |
| 121 | 17:40:15 voltha-voltha-adapter-openolt-68c84bf786-z98rh 0/1 Running 0 8s |
| 122 | |
| 123 | * % kubectl port-forward --address 0.0.0.0 |
| 124 | 17:40:15 error: unable to forward port because pod is not running. Current status=Pending |
| 125 | * ----------------------------------------------------------------------- |
| 126 | */ |
| 127 | sh(label : "Wait for VOLTHA Stack (stack=${cfg.stackName}, namespace=${cfg.volthaNamespace}) to start", |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 128 | script : """ |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 129 | |
| 130 | cat <<EOM |
| 131 | |
| 132 | ** ----------------------------------------------------------------------- |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 133 | ** Wait for VOLTHA Stack (stack=${cfg.stackName}, namespace=${cfg.volthaNamespace}) to start |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 134 | ** ----------------------------------------------------------------------- |
| 135 | EOM |
| 136 | |
| 137 | # set -euo pipefail |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 138 | set +x # # Logs are noisy when commented |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 139 | |
| 140 | declare -i count=0 |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 141 | declare -i debug=1 # uncomment to enable debugging |
| 142 | # declare -i verbose=1 # uncomment to enable debugging |
Joey Armstrong | 8da0894 | 2023-09-14 13:52:49 -0400 | [diff] [blame] | 143 | vsd_log='volthaStackDeploy.tmp' |
Joey Armstrong | d4af72d | 2023-09-18 14:23:35 -0400 | [diff] [blame] | 144 | echo > \$vsd_log |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 145 | |
Joey Armstrong | cfb8594 | 2023-09-15 11:47:02 -0400 | [diff] [blame] | 146 | declare -i rc=0 # exit status |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 147 | while true; do |
| 148 | |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 149 | # Gather |
| 150 | kubectl get pods -n ${cfg.volthaNamespace} \ |
| 151 | -l app.kubernetes.io/part-of=voltha --no-headers \ |
| 152 | > \$vsd_log |
| 153 | |
| 154 | count=\$((\$count - 1)) |
| 155 | |
| 156 | # Display activity every iteration ? |
| 157 | [[ -v verbose ]] && { count=0; } |
| 158 | |
| 159 | # Display activity every minute or so {sleep(5) x count=10} |
| 160 | if [[ \$count -lt 1 ]]; then |
| 161 | count=10 |
| 162 | cat \$vsd_log |
| 163 | fi |
| 164 | |
| 165 | ## ----------------------- |
Joey Armstrong | 6f50765 | 2023-09-18 10:35:07 -0400 | [diff] [blame] | 166 | ## Probe for cluster state |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 167 | ## ----------------------- |
| 168 | if grep -q -e 'ContainerCreating' \$vsd_log; then |
| 169 | echo -e '\nvolthaStackDeploy.groovy: ContainerCrating active' |
| 170 | [[ -v debug ]] && grep -e 'ContainerCreating' \$vsd_log |
Joey Armstrong | cfb8594 | 2023-09-15 11:47:02 -0400 | [diff] [blame] | 171 | |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 172 | elif grep -q -e '0/' \$vsd_log; then |
| 173 | echo -e '\nvolthaStackDeploy.groovy: Waiting for status=Running' |
| 174 | [[ -v debug ]] && grep -e '0/' \$vsd_log |
Joey Armstrong | cfb8594 | 2023-09-15 11:47:02 -0400 | [diff] [blame] | 175 | |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 176 | elif ! grep -q '/' \$vsd_log; then |
| 177 | echo -e '\nvolthaStackDeploy.groovy: Waiting for initial pod activity' |
| 178 | [[ ! -v verbose ]] && { cat \$vsd_log; } |
Joey Armstrong | cfb8594 | 2023-09-15 11:47:02 -0400 | [diff] [blame] | 179 | |
| 180 | # ----------------------------------------------------------------------- |
| 181 | # voltha-adapter-openolt-68c84bf786-8xsfc 0/1 CrashLoopBackOff 2 69s |
| 182 | # voltha-adapter-openolt-68c84bf786-8xsfc 0/1 Error 3 85s |
| 183 | # ----------------------------------------------------------------------- |
| 184 | elif grep -q 'Error' \$vsd_log; then |
| 185 | echo -e '\nvolthaStackDeploy.groovy: Detected cluster state=Error' |
| 186 | cat \$vsd_log |
| 187 | rc=1 # fatal |
| 188 | break |
| 189 | |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 190 | # ----------------------------------------------------------------------- |
| 191 | # An extra conditon needed here but shell coding is tricky: |
| 192 | # "svc x/y Running 0 6s |
| 193 | # Verify (x == y) && (x > 0) |
Joey Armstrong | 6f50765 | 2023-09-18 10:35:07 -0400 | [diff] [blame] | 194 | # Wait until job failure/we have an actual need for it. |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 195 | # ----------------------------------------------------------------------- |
Joey Armstrong | d4af72d | 2023-09-18 14:23:35 -0400 | [diff] [blame] | 196 | # Could check for all services 'Running', is that reliable (?) |
| 197 | # ----------------------------------------------------------------------- |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 198 | else |
| 199 | echo -e '\nvolthaStackDeploy.groovy: Voltha stack has launched' |
| 200 | [[ ! -v verbose ]] && { cat \$vsd_log; } |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 201 | break |
| 202 | fi |
| 203 | |
Joey Armstrong | 358f224 | 2023-09-15 09:49:21 -0400 | [diff] [blame] | 204 | ## Support argument --timeout (?) |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 205 | sleep 5 |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 206 | |
| 207 | done |
| 208 | rm -f \$vsd_log |
Joey Armstrong | cfb8594 | 2023-09-15 11:47:02 -0400 | [diff] [blame] | 209 | exit \$rc |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 210 | """) |
Joey Armstrong | 96158a9 | 2022-11-25 10:36:06 -0500 | [diff] [blame] | 211 | |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 212 | leave('launchVolthaStack') |
| 213 | return |
| 214 | } |
| 215 | |
| 216 | // ----------------------------------------------------------------------- |
Joey Armstrong | 8d12f65 | 2023-09-13 18:25:33 -0400 | [diff] [blame] | 217 | // Intent: Wait until the pod completed, meaning ONOS fully deployed |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 218 | // ----------------------------------------------------------------------- |
Joey Armstrong | 8d12f65 | 2023-09-13 18:25:33 -0400 | [diff] [blame] | 219 | void waitForOnosDeploy(Map cfg) { |
| 220 | enter('waitForOnosDeploy') |
| 221 | |
| 222 | sh(label : 'Wait for ONOS full deployment', |
Joey Armstrong | 6f50765 | 2023-09-18 10:35:07 -0400 | [diff] [blame] | 223 | script : """ |
Joey Armstrong | 8d12f65 | 2023-09-13 18:25:33 -0400 | [diff] [blame] | 224 | |
| 225 | cat <<EOM |
| 226 | |
| 227 | ** ----------------------------------------------------------------------- |
| 228 | ** Wait for ONOS full deployment |
| 229 | ** ----------------------------------------------------------------------- |
| 230 | EOM |
| 231 | |
| 232 | # set -euo pipefail |
| 233 | set +x # # Noisy when commented (default: uncommented) |
| 234 | |
| 235 | declare -i count=0 |
Joey Armstrong | d4af72d | 2023-09-18 14:23:35 -0400 | [diff] [blame] | 236 | declare -i debug=1 # uncomment to enable debugging |
| 237 | # declare -i verbose=1 # uncomment to enable debugging |
Joey Armstrong | 8da0894 | 2023-09-14 13:52:49 -0400 | [diff] [blame] | 238 | vsd_log='volthaStackDeploy.tmp' |
Joey Armstrong | d4af72d | 2023-09-18 14:23:35 -0400 | [diff] [blame] | 239 | echo > \$vsd_log |
| 240 | |
| 241 | declare -i rc=0 # exit status |
Joey Armstrong | 8d12f65 | 2023-09-13 18:25:33 -0400 | [diff] [blame] | 242 | while true; do |
| 243 | |
Joey Armstrong | d4af72d | 2023-09-18 14:23:35 -0400 | [diff] [blame] | 244 | # Gather -- should we check for count(svc > 1) ? |
| 245 | kubectl get pods -l app=onos-config-loader \ |
| 246 | -n ${cfg.infraNamespace} --no-headers \ |
| 247 | --field-selector=status.phase=Running \ |
| 248 | > \$vsd_log |
| 249 | |
| 250 | count=\$((\$count - 1)) |
| 251 | |
| 252 | # Display activity every iteration ? |
| 253 | [[ -v verbose ]] && { count=0; } |
| 254 | |
| 255 | # Display activity every minute or so {sleep(5) x count=10} |
| 256 | if [[ \$count -lt 1 ]]; then |
| 257 | count=10 |
| 258 | cat \$vsd_log |
| 259 | fi |
| 260 | |
| 261 | ## ----------------------- |
| 262 | ## Probe for cluster state |
| 263 | ## ----------------------- |
| 264 | if grep -q -e 'ContainerCreating' \$vsd_log; then |
| 265 | echo -e '\nvolthaStackDeploy.groovy: ContainerCrating active' |
| 266 | [[ -v debug ]] && grep -e 'ContainerCreating' \$vsd_log |
| 267 | |
| 268 | elif grep -q -e '0/' \$vsd_log; then |
| 269 | echo -e '\nvolthaStackDeploy.groovy: Waiting for status=Running' |
| 270 | [[ -v debug ]] && grep -e '0/' \$vsd_log |
| 271 | |
| 272 | elif ! grep -q '/' \$vsd_log; then |
| 273 | echo -e '\nvolthaStackDeploy.groovy: Waiting for initial pod activity' |
| 274 | [[ ! -v verbose ]] && { cat \$vsd_log; } |
| 275 | |
| 276 | # ----------------------------------------------------------------------- |
| 277 | # voltha-adapter-openolt-68c84bf786-8xsfc 0/1 CrashLoopBackOff 2 69s |
| 278 | # voltha-adapter-openolt-68c84bf786-8xsfc 0/1 Error 3 85s |
| 279 | # ----------------------------------------------------------------------- |
| 280 | elif grep -q 'Error' \$vsd_log; then |
| 281 | echo -e '\nvolthaStackDeploy.groovy: Detected cluster state=Error' |
| 282 | cat \$vsd_log |
| 283 | rc=1 # fatal |
| 284 | break |
| 285 | |
| 286 | # ----------------------------------------------------------------------- |
| 287 | # An extra conditon needed here but shell coding is tricky: |
| 288 | # "svc x/y Running 0 6s |
| 289 | # Verify (x == y) && (x > 0) |
| 290 | # Wait until job failure/we have an actual need for it. |
| 291 | # ----------------------------------------------------------------------- |
| 292 | # Could check for all services 'Running', is that reliable (?) |
| 293 | # ----------------------------------------------------------------------- |
| 294 | else |
| 295 | echo -e '\nvolthaStackDeploy.groovy: Voltha stack has launched' |
| 296 | [[ ! -v verbose ]] && { cat \$vsd_log; } |
Joey Armstrong | 8d12f65 | 2023-09-13 18:25:33 -0400 | [diff] [blame] | 297 | break |
| 298 | fi |
| 299 | |
Joey Armstrong | d4af72d | 2023-09-18 14:23:35 -0400 | [diff] [blame] | 300 | ## Support argument --timeout (?) |
Joey Armstrong | 8d12f65 | 2023-09-13 18:25:33 -0400 | [diff] [blame] | 301 | sleep 5 |
Joey Armstrong | 8d12f65 | 2023-09-13 18:25:33 -0400 | [diff] [blame] | 302 | |
Joey Armstrong | 8d12f65 | 2023-09-13 18:25:33 -0400 | [diff] [blame] | 303 | done |
| 304 | rm -f \$vsd_log |
Joey Armstrong | 8c34712 | 2023-09-18 17:04:49 -0400 | [diff] [blame] | 305 | exit \$rc |
Joey Armstrong | 8d12f65 | 2023-09-13 18:25:33 -0400 | [diff] [blame] | 306 | """) |
| 307 | |
| 308 | leave('waitForOnosDeploy') |
| 309 | return |
| 310 | } |
| 311 | |
| 312 | // ----------------------------------------------------------------------- |
| 313 | // ----------------------------------------------------------------------- |
| 314 | void process(Map config) { |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 315 | enter('process') |
| 316 | |
| 317 | // note that I can't define this outside the function as there's no global scope in Groovy |
| 318 | Map defaultConfig = [ |
| 319 | bbsimReplica: 1, |
| 320 | infraNamespace: 'infra', |
| 321 | volthaNamespace: 'voltha', |
| 322 | stackName: 'voltha', |
| 323 | stackId: 1, // NOTE this is used to differentiate between BBSims across multiple stacks |
| 324 | workflow: 'att', |
| 325 | withMacLearning: false, |
| 326 | withFttb: false, |
| 327 | extraHelmFlags: '', |
| 328 | localCharts: false, |
| 329 | onosReplica: 1, |
| 330 | adaptersToWait: 2, |
| 331 | ] |
| 332 | |
| 333 | Map cfg = defaultConfig + config |
| 334 | |
| 335 | // Augment config map |
| 336 | cfg.volthaStackChart = 'onf/voltha-stack' |
| 337 | cfg.bbsimChart = 'onf/bbsim' |
| 338 | |
| 339 | if (cfg.localCharts) { |
| 340 | cfg.volthaStackChart = "$WORKSPACE/voltha-helm-charts/voltha-stack" |
| 341 | cfg.bbsimChart = "$WORKSPACE/voltha-helm-charts/bbsim" |
| 342 | |
| 343 | sh(label : 'HELM: Update voltha-stack deps', |
| 344 | script : """ |
| 345 | pushd $WORKSPACE/voltha-helm-charts/voltha-stack |
| 346 | helm dep update |
| 347 | popd |
| 348 | """) |
| 349 | } |
| 350 | |
| 351 | println "Deploying VOLTHA Stack with the following parameters: ${cfg}." |
| 352 | deployVolthaStack(cfg) |
| 353 | launchVolthaStack(cfg) |
| 354 | waitForAdapters(cfg) |
Joey Armstrong | 8d12f65 | 2023-09-13 18:25:33 -0400 | [diff] [blame] | 355 | waitForOnosDeploy(cfg) |
Joey Armstrong | 74ec08c | 2023-08-31 11:25:57 -0400 | [diff] [blame] | 356 | leave('process') |
Joey Armstrong | e93c3fa | 2023-09-11 09:34:24 -0400 | [diff] [blame] | 357 | |
Joey Armstrong | 7987c11 | 2022-12-05 12:42:43 -0500 | [diff] [blame] | 358 | return |
Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 359 | } |
Joey Armstrong | 7987c11 | 2022-12-05 12:42:43 -0500 | [diff] [blame] | 360 | |
| 361 | // ----------------------------------------------------------------------- |
| 362 | // ----------------------------------------------------------------------- |
Joey Armstrong | 6f50765 | 2023-09-18 10:35:07 -0400 | [diff] [blame] | 363 | def call(Map config=[:]) { // Function return type(?) |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 364 | try { |
Joey Armstrong | 74ec08c | 2023-08-31 11:25:57 -0400 | [diff] [blame] | 365 | enter('main') |
| 366 | process(config) |
Joey Armstrong | 7987c11 | 2022-12-05 12:42:43 -0500 | [diff] [blame] | 367 | } |
Joey Armstrong | 74ec08c | 2023-08-31 11:25:57 -0400 | [diff] [blame] | 368 | catch (Exception err) { // groovylint-disable-line CatchException |
| 369 | ans = false |
| 370 | println("** volthaStackDeploy.groovy: EXCEPTION ${err}") |
| 371 | throw err |
Joey Armstrong | 7987c11 | 2022-12-05 12:42:43 -0500 | [diff] [blame] | 372 | } |
Joey Armstrong | cd3f075 | 2023-09-11 18:10:12 -0400 | [diff] [blame] | 373 | finally { |
Joey Armstrong | 74ec08c | 2023-08-31 11:25:57 -0400 | [diff] [blame] | 374 | leave('main') |
Joey Armstrong | 7987c11 | 2022-12-05 12:42:43 -0500 | [diff] [blame] | 375 | } |
| 376 | return |
| 377 | } |
| 378 | |
| 379 | // [EOF] |