blob: 0b0d11648279e68d4bcb60ae8d8b2987ab1df5c2 [file] [log] [blame]
Matteo Scandolo42f6e572021-01-25 15:11:34 -08001
2def 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 = [
Matteo Scandolo42f6e572021-01-25 15:11:34 -08005 bbsimReplica: 1,
6 infraNamespace: "infra",
7 volthaNamespace: "voltha",
8 stackName: "voltha",
Matteo Scandolo2bc660a2021-02-12 10:52:25 -08009 stackId: 1, // NOTE this is used to differentiate between BBSims across multiple stacks
Matteo Scandolo42f6e572021-01-25 15:11:34 -080010 workflow: "att",
11 extraHelmFlags: "",
Matteo Scandolofcfc60d2021-02-24 09:06:48 -080012 localCharts: false,
Matteo Scandolo42f6e572021-01-25 15:11:34 -080013 ]
14
15 if (!config) {
16 config = [:]
17 }
18
19 def cfg = defaultConfig + config
20
Matteo Scandolofcfc60d2021-02-24 09:06:48 -080021 def volthaStackChart = "onf/voltha-stack"
22
23 if (cfg.localCharts) {
24 volthaStackChart = "$WORKSPACE/voltha-helm-charts/voltha-stack"
25
26 sh """
27 pushd $WORKSPACE/voltha-helm-charts/voltha-stack
28 helm dep update
29 popd
30 """
31 }
32
Matteo Scandolo42f6e572021-01-25 15:11:34 -080033 println "Deploying VOLTHA Stack with the following parameters: ${cfg}."
34
35 sh """
Matteo Scandolofcfc60d2021-02-24 09:06:48 -080036 helm upgrade --install --create-namespace -n ${cfg.volthaNamespace} ${cfg.stackName} ${volthaStackChart} ${cfg.extraHelmFlags} \
Matteo Scandolo42f6e572021-01-25 15:11:34 -080037 --set global.stack_name=${cfg.stackName} \
38 --set global.voltha_infra_name=voltha-infra \
39 --set global.voltha_infra_namespace=${cfg.infraNamespace} \
40 """
41
42 for(int i = 0;i<cfg.bbsimReplica;i++) {
43 // TODO differentiate olt_id between different stacks
44 sh """
45 helm upgrade --install --create-namespace -n ${cfg.volthaNamespace} bbsim${i} onf/bbsim ${cfg.extraHelmFlags} \
Matteo Scandolo2bc660a2021-02-12 10:52:25 -080046 --set olt_id="${cfg.stackId}${i}" \
Matteo Scandolo42f6e572021-01-25 15:11:34 -080047 -f $WORKSPACE/voltha-helm-charts/examples/${cfg.workflow}-values.yaml
48 """
49 }
50
51 println "Wait for VOLTHA Stack ${cfg.stackName} to start"
52
53 sh """
54 set +x
55 voltha=\$(kubectl get pods -n ${cfg.volthaNamespace} -l app.kubernetes.io/part-of=voltha --no-headers | grep "0/" | wc -l)
56 while [[ \$voltha != 0 ]]; do
57 sleep 5
58 voltha=\$(kubectl get pods -n ${cfg.volthaNamespace} -l app.kubernetes.io/part-of=voltha --no-headers | grep "0/" | wc -l)
59 done
60 """
61
62 // also make sure that the ONOS config is loaded
63 println "Wait for ONOS Config loader to complete"
64
65 sh """
66 set +x
67 config=\$(kubectl get jobs.batch -n ${cfg.infraNamespace} --no-headers | grep "0/" | wc -l)
68 while [[ \$config != 0 ]]; do
69 sleep 5
70 config=\$(kubectl get jobs.batch -n ${cfg.infraNamespace} --no-headers | grep "0/" | wc -l)
71 done
72 """
73}