blob: c68de533bcd2f549c61cd68c448dd1f5d1c3a5e0 [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: "",
12 ]
13
14 if (!config) {
15 config = [:]
16 }
17
18 def cfg = defaultConfig + config
19
20 println "Deploying VOLTHA Stack with the following parameters: ${cfg}."
21
22 sh """
23 helm upgrade --install --create-namespace -n ${cfg.volthaNamespace} ${cfg.stackName} onf/voltha-stack ${cfg.extraHelmFlags} \
24 --set global.stack_name=${cfg.stackName} \
25 --set global.voltha_infra_name=voltha-infra \
26 --set global.voltha_infra_namespace=${cfg.infraNamespace} \
27 """
28
29 for(int i = 0;i<cfg.bbsimReplica;i++) {
30 // TODO differentiate olt_id between different stacks
31 sh """
32 helm upgrade --install --create-namespace -n ${cfg.volthaNamespace} bbsim${i} onf/bbsim ${cfg.extraHelmFlags} \
Matteo Scandolo2bc660a2021-02-12 10:52:25 -080033 --set olt_id="${cfg.stackId}${i}" \
Matteo Scandolo42f6e572021-01-25 15:11:34 -080034 -f $WORKSPACE/voltha-helm-charts/examples/${cfg.workflow}-values.yaml
35 """
36 }
37
38 println "Wait for VOLTHA Stack ${cfg.stackName} to start"
39
40 sh """
41 set +x
42 voltha=\$(kubectl get pods -n ${cfg.volthaNamespace} -l app.kubernetes.io/part-of=voltha --no-headers | grep "0/" | wc -l)
43 while [[ \$voltha != 0 ]]; do
44 sleep 5
45 voltha=\$(kubectl get pods -n ${cfg.volthaNamespace} -l app.kubernetes.io/part-of=voltha --no-headers | grep "0/" | wc -l)
46 done
47 """
48
49 // also make sure that the ONOS config is loaded
50 println "Wait for ONOS Config loader to complete"
51
52 sh """
53 set +x
54 config=\$(kubectl get jobs.batch -n ${cfg.infraNamespace} --no-headers | grep "0/" | wc -l)
55 while [[ \$config != 0 ]]; do
56 sleep 5
57 config=\$(kubectl get jobs.batch -n ${cfg.infraNamespace} --no-headers | grep "0/" | wc -l)
58 done
59 """
60}