Fixing kill_port_forwar method

Change-Id: Icd1fbf4f7c670bc16234ab62b614d3fe6f85d43f
diff --git a/releases/voltha-2.5 b/releases/voltha-2.5
index 13268c0..a5c5d3e 100644
--- a/releases/voltha-2.5
+++ b/releases/voltha-2.5
@@ -14,6 +14,10 @@
 export HELM_VERSION=v3.2.4
 export KIND_VERSION=v0.8.1
 
+# lock bbsim-sadis server to Ciena version
+export BBSIM_SADIS_SERVER_CHART=bbsim-sadis/bbsim-sadis-server
+export BBSIM_SADIS_SERVER_CHART_VERSION=1.1.0
+
 # defaults.image_tag=null will use the image tags in the Helm charts rather than
 # kind-voltha's default which is 'master'.
 # Also we need to specify the tag for voltha/voltha-onos image since this is
diff --git a/voltha b/voltha
index 4fe8e4c..6413d39 100755
--- a/voltha
+++ b/voltha
@@ -1069,53 +1069,52 @@
 }
 
 kill_port_forward() {
-    local TAG P_IDS PARENTS KIDS UNKNOWN PP_ID PF NS
+    local TAG P_IDS PARENTS KIDS UNKNOWN PP_ID NS
 
-    while [ $# -gt 0 ]; do
-        NS=$1; shift
-        PF=$1; shift
-        TAG=
-        if [ "$PF" != "__ALL__" ]; then
-            TAG=$SVC-$NS-$NAME
-        fi
-        PARENTS=
-        KIDS=
-        UNKNOWN=
-        # shellcheck disable=SC2009
-        P_IDS="$(ps e -ww -A | grep "_TAG=$TAG" | grep -v grep | awk '{print $1}')"
-        if [ -n "$P_IDS" ]; then
-            for P_ID in $P_IDS; do
-                PP_ID="$(ps -o ppid "$P_ID" | tail -n +2)"
-                if [ -n "$PP_ID" ]; then
-                    if [ "$PP_ID" -eq 1 ]; then
-                        PARENTS="$PARENTS $P_ID"
-                    else
-                        KIDS="$KIDS $P_ID"
-                    fi
+    NS=$1; shift
+    SVC=$1; shift
+
+    TAG=
+    if [ "$SVC" != "__ALL__" ]; then
+        TAG=$SVC-$NS-$NAME
+    fi
+    PARENTS=
+    KIDS=
+    UNKNOWN=
+    # shellcheck disable=SC2009
+    P_IDS="$(ps e -ww -A | grep "_TAG=$TAG" | grep -v grep | awk '{print $1}')"
+    if [ -n "$P_IDS" ]; then
+        for P_ID in $P_IDS; do
+            PP_ID="$(ps -o ppid "$P_ID" | tail -n +2)"
+            if [ -n "$PP_ID" ]; then
+                if [ "$PP_ID" -eq 1 ]; then
+                    PARENTS="$PARENTS $P_ID"
                 else
-                    UNKNOWN="$UNKNOWN $P_ID"
+                    KIDS="$KIDS $P_ID"
                 fi
+            else
+                UNKNOWN="$UNKNOWN $P_ID"
+            fi
+        done
+        if [ -n "$PARENTS" ]; then
+            # shellcheck disable=SC2086
+            while ps -h $PARENTS >/dev/null 2>&1; do
+                (set -x; eval "kill -9 $PARENTS" >>"$LOG" 2>&1) >>"$LOG" 2>&1
             done
-            if [ -n "$PARENTS" ]; then
-                # shellcheck disable=SC2086
-                while ps -h $PARENTS >/dev/null 2>&1; do
-                    (set -x; eval "kill -9 $PARENTS" >>"$LOG" 2>&1) >>"$LOG" 2>&1
-                done
-            fi
-            if [ -n "$KIDS" ]; then
-                # shellcheck disable=SC2086
-                while ps -h $KIDS >/dev/null 2>&1; do
-                    (set -x; eval "kill -9 $KIDS" >>"$LOG" 2>&1) >>"$LOG" 2>&1
-                done
-            fi
-            if [ -n "$UNKNOWN" ]; then
-                # shellcheck disable=SC2086
-                while ps -h $UNKNOWN >/dev/null 2>&1; do
-                    (set -x; eval "kill -9 $UNKNOWN" >>"$LOG" 2>&1) >>"$LOG" 2>&1
-                done
-            fi
         fi
-    done
+        if [ -n "$KIDS" ]; then
+            # shellcheck disable=SC2086
+            while ps -h $KIDS >/dev/null 2>&1; do
+                (set -x; eval "kill -9 $KIDS" >>"$LOG" 2>&1) >>"$LOG" 2>&1
+            done
+        fi
+        if [ -n "$UNKNOWN" ]; then
+            # shellcheck disable=SC2086
+            while ps -h $UNKNOWN >/dev/null 2>&1; do
+                (set -x; eval "kill -9 $UNKNOWN" >>"$LOG" 2>&1) >>"$LOG" 2>&1
+            done
+        fi
+    fi
 }
 
 resolve_chart_name() {
@@ -1848,6 +1847,7 @@
     incubator|https://kubernetes-charts-incubator.storage.googleapis.com|Google_Incubator \
     onos|https://charts.onosproject.org|ONF_ONOS \
     atomix|https://charts.atomix.io|ONF_Atomix \
+    bbsim-sadis|https://ciena.github.io/bbsim-sadis-server/charts|Custom_BBSIM_SADIS_Server \
     elastic|https://helm.elastic.co|Elastic \
     kiwigrid|https://kiwigrid.github.io|Fluentd-ElasticSearch\
     bitnami|https://charts.bitnami.com/bitnami|Bitnami"
@@ -2720,6 +2720,14 @@
         if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm_is_deployed "$BBSIM_NS" "^bbsim${instance_num}\$")" -ne 1 ]; then
             espin - "$NOT_VERIFIED"
 
+            if [[ $(semver_greater "$VOLTHA_BBSIM_CHART_VERSION" "4.0.3") == "true" ]]; then
+              # this is past voltha-2.5, we support multiple stacks
+              OLT_ID=$BBSIM_BASE_INDEX$instance
+            else
+              # this is voltha-2.5 or earlier
+              OLT_ID=$instance
+            fi
+
             if [[ $(semver_greater "$VOLTHA_BBSIM_CHART_VERSION" "3.1.0") == "true" ]]; then
               # this is the latest BBSim with support for TT
               # when we deploy multiple BBSims we need to update the configuration
@@ -2727,11 +2735,11 @@
               _TAG="$((900+instance))"
               BBSIM_TMP="$(mktemp -u)"
               sed -e "s/\":TAG:\"/$_TAG/g" "$BBSIM_CFG" > "$BBSIM_TMP"
-              INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set olt_id=$BBSIM_BASE_INDEX$instance -f $BBSIM_TMP"
+              INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set olt_id=$OLT_ID -f $BBSIM_TMP"
             else
               # these are older versio of BBSim
               S_TAG="$((900+instance))"
-              INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set olt_id=$instance,s_tag=$S_TAG"
+              INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set olt_id=$OLT_ID,s_tag=$S_TAG"
               if [ "$WITH_EAPOL" == "yes" ]; then
                  INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set auth=true"
               else