[VOL-3780] Using different S-Tags in multiple BBSim deployments

Change-Id: I9a3ad351ce6c324625c0cabc26266afba3c15e91
diff --git a/vars/volthaStackDeploy.groovy b/vars/volthaStackDeploy.groovy
index b39c84f..b7e43fc 100644
--- a/vars/volthaStackDeploy.groovy
+++ b/vars/volthaStackDeploy.groovy
@@ -41,13 +41,32 @@
     """
 
     for(int i = 0;i<cfg.bbsimReplica;i++) {
-      // TODO differentiate olt_id between different stacks
-       sh """
-         helm upgrade --install --create-namespace -n ${cfg.volthaNamespace} bbsim${i} onf/bbsim \
-         --set olt_id="${cfg.stackId}${i}" \
-         -f $WORKSPACE/voltha-helm-charts/examples/${cfg.workflow}-values.yaml \
-         ${cfg.extraHelmFlags}
-       """
+      // NOTE we don't need to update the tag for DT
+      script {
+        sh """
+        rm -f $WORKSPACE/bbsimCfg${cfg.stackId}${i}.yaml
+        """
+        if (cfg.workflow == "att" || cfg.workflow == "tt") {
+          def startingStag = 900
+          def bbsimCfg = readYaml file: "$WORKSPACE/voltha-helm-charts/examples/${cfg.workflow}-values.yaml"
+          // NOTE we assume that the only service that needs a different s_tag is the first one in the list
+          bbsimCfg["servicesConfig"]["services"][0]["s_tag"] = startingStag + i
+          println "Using BBSim Service config ${bbsimCfg}"
+          writeYaml file: "$WORKSPACE/bbsimCfg${cfg.stackId}${i}.yaml", data: bbsimCfg
+        } else {
+          // NOTE if it's DT just copy the file over
+          sh """
+          cp $WORKSPACE/voltha-helm-charts/examples/${cfg.workflow}-values.yaml $WORKSPACE/bbsimCfg${cfg.stackId}${i}.yaml
+          """
+        }
+      }
+
+      sh """
+        helm upgrade --install --create-namespace -n ${cfg.volthaNamespace} bbsim${i} onf/bbsim \
+        --set olt_id="${cfg.stackId}${i}" \
+        -f $WORKSPACE/bbsimCfg${cfg.stackId}${i}.yaml \
+        ${cfg.extraHelmFlags}
+      """
     }
 
     println "Wait for VOLTHA Stack ${cfg.stackName} to start"