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