Matteo Scandolo | 42f6e57 | 2021-01-25 15:11:34 -0800 | [diff] [blame] | 1 | |
| 2 | def call(Map config) { |
| 3 | // note that I can't define this outside the function as there's no global scope in Groovy |
| 4 | def defaultConfig = [ |
| 5 | onosReplica: 1, |
| 6 | atomixReplica: 1, |
| 7 | kafkaReplica: 1, |
| 8 | etcdReplica: 1, |
| 9 | bbsimReplica: 1, |
| 10 | infraNamespace: "infra", |
| 11 | volthaNamespace: "voltha", |
| 12 | stackName: "voltha", |
| 13 | workflow: "att", |
| 14 | extraHelmFlags: "", |
| 15 | ] |
| 16 | |
| 17 | if (!config) { |
| 18 | config = [:] |
| 19 | } |
| 20 | |
| 21 | def cfg = defaultConfig + config |
| 22 | |
| 23 | println "Deploying VOLTHA Stack with the following parameters: ${cfg}." |
| 24 | |
| 25 | sh """ |
| 26 | helm upgrade --install --create-namespace -n ${cfg.volthaNamespace} ${cfg.stackName} onf/voltha-stack ${cfg.extraHelmFlags} \ |
| 27 | --set global.stack_name=${cfg.stackName} \ |
| 28 | --set global.voltha_infra_name=voltha-infra \ |
| 29 | --set global.voltha_infra_namespace=${cfg.infraNamespace} \ |
| 30 | """ |
| 31 | |
| 32 | for(int i = 0;i<cfg.bbsimReplica;i++) { |
| 33 | // TODO differentiate olt_id between different stacks |
| 34 | sh """ |
| 35 | helm upgrade --install --create-namespace -n ${cfg.volthaNamespace} bbsim${i} onf/bbsim ${cfg.extraHelmFlags} \ |
| 36 | --set olt_id="1${i}" \ |
| 37 | -f $WORKSPACE/voltha-helm-charts/examples/${cfg.workflow}-values.yaml |
| 38 | """ |
| 39 | } |
| 40 | |
| 41 | println "Wait for VOLTHA Stack ${cfg.stackName} to start" |
| 42 | |
| 43 | sh """ |
| 44 | set +x |
| 45 | voltha=\$(kubectl get pods -n ${cfg.volthaNamespace} -l app.kubernetes.io/part-of=voltha --no-headers | grep "0/" | wc -l) |
| 46 | while [[ \$voltha != 0 ]]; do |
| 47 | sleep 5 |
| 48 | voltha=\$(kubectl get pods -n ${cfg.volthaNamespace} -l app.kubernetes.io/part-of=voltha --no-headers | grep "0/" | wc -l) |
| 49 | done |
| 50 | """ |
| 51 | |
| 52 | // also make sure that the ONOS config is loaded |
| 53 | println "Wait for ONOS Config loader to complete" |
| 54 | |
| 55 | sh """ |
| 56 | set +x |
| 57 | config=\$(kubectl get jobs.batch -n ${cfg.infraNamespace} --no-headers | grep "0/" | wc -l) |
| 58 | while [[ \$config != 0 ]]; do |
| 59 | sleep 5 |
| 60 | config=\$(kubectl get jobs.batch -n ${cfg.infraNamespace} --no-headers | grep "0/" | wc -l) |
| 61 | done |
| 62 | """ |
| 63 | } |