VOL-3213 - (2) allow settings for onos and bbsim

- any values for onos and bbsim in *-values.yaml
- fix monitor.sh (bug)
- add bbsim index to ced script

Change-Id: I3b53ec546276fb57902d5fd475ce7fb44943e399
diff --git a/.gitignore b/.gitignore
index fd2c35e..e941ef0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,3 +13,4 @@
 minimal-env.sh
 full-env.sh
 .DS_Store
+kube-config-*
diff --git a/full-values.yaml b/full-values.yaml
index 253c7b9..bc671f3 100644
--- a/full-values.yaml
+++ b/full-values.yaml
@@ -23,22 +23,21 @@
 # this block and replace "<VALUE>" with "voltha-2.1".
 defaults:
   image_tag: master
+  image_pullPolicy: Always
 
 private_etcd_cluster: false
 private_kafka_cluster: false
 
-# OFAGENT IMPLEMENTATION
-# ----------------------
-# There are currently two implementations of OFAGENT: the original written in
-# Python and the reimplementation written in Go. The variable `use_ofagent_go`
-# can be used to optionally select the implementation. The Go version is the
-# version to be part of the official release and is the default. The Python
-# verison has been deprecated and is no longer being actively workes, but is
-# being left as an option for this release.
+# OPENONU-ADAPTER IMPLEMENTATION
+# ------------------------------
+# There are currently two implementations of OPENONU-ADAPTER: the original
+# written in Python and the reimplementation written in Go. The variable
+# `use_openonu_adapter_go` can be used to optionally use the new Go
+# implementation. This is done by setting that value to `true`.
 #
 # Along with this change you will also may need to set the Docker image
-# information below (search for START_OFAGENT_GO).
-use_ofagent_go: true
+# information below (search for START_OPENONU_ADAPTER_GO).
+use_openonu_adapter_go: false
 
 images:
   onos:
@@ -72,18 +71,18 @@
 #  bbsim:
 #    repository: voltha/bbsim
 #    tag: master
-# START_OFAGENT_GO - Comment the following block to use the
-# Python implementation of the ofagent
 #  ofagent:
 #    repository: voltha/voltha-ofagent-go
 #    tag: master
-# END_OFAGENT_GO
-#  ofagent:
-#    repository: voltha/voltha-ofagent-py
-#    tag: 2.1.1
 #  rw_core:
 #    repository: voltha/voltha-rw-core
 #    tag: 2.1.1
+# START_OPENONU_ADAPTER_GO - Uncomment the following block to use the
+# Go implementation of the openonu-adapter
+#  adapter_open_onu_go:
+#    repository: voltha-openonu-adapter-go
+#    tag: master
+# END_OPENONU_ADAPTER_GO
 
 etcd:
   replicas: 3
@@ -135,27 +134,35 @@
 # open-onu:
 #   fullNameOverride: voltha-adapter-openonu
 
-onos_env:
-  - name: POD_IP
-    valueFrom:
-    fieldRef:
-      fieldPath: status.podIP
-  - name: NAMESPACE
-    valueFrom:
-    fieldRef:
-      fieldPath: metadata.namespace
-  - name: ONOS_APPS
-    value: "drivers,openflow-base,hostprovider"
-
-# No persistent volume in Atomix to have clean state for each re-deploy of ONOS
-atomix:
-  persistence:
-    enabled: false
+onos:
+  image:
+    repository: voltha/voltha-onos
+    tag: master
+    pullPolicy: Always
+  onos_env:
+    - name: POD_IP
+      valueFrom:
+      fieldRef:
+        fieldPath: status.podIP
+    - name: NAMESPACE
+      valueFrom:
+      fieldRef:
+        fieldPath: metadata.namespace
+    - name: ONOS_APPS
+      value: "drivers,openflow-base,hostprovider"
+  # No persistent volume in Atomix to have clean state for each re-deploy of ONOS
+  atomix:
+    persistence:
+      enabled: false
 
 # Customization for BBSIM
-kafka_broker: 'voltha-kafka.voltha.svc.cluster.local:9092'
-pon: 1
-onu: 1
+bbsim:
+  nni: 1
+  pon: 1
+  onu: 1
+  sadisFormat: "att"
+  kafkaEventTopic: "bbsim"
+  enableEvents: false
 
 # SHOCK THE MONKEY OR LET LOSE THE DOGS OF WAR
 # The VOLTHA charts have support for adding extra labels to deployments and
diff --git a/minimal-values.yaml b/minimal-values.yaml
index b9d16c6..0488de2 100644
--- a/minimal-values.yaml
+++ b/minimal-values.yaml
@@ -134,27 +134,35 @@
 # open-onu:
 #   fullNameOverride: voltha-adapter-openonu
 
-onos_env:
-  - name: POD_IP
-    valueFrom:
-    fieldRef:
-      fieldPath: status.podIP
-  - name: NAMESPACE
-    valueFrom:
-    fieldRef:
-      fieldPath: metadata.namespace
-  - name: ONOS_APPS
-    value: "drivers,openflow-base,hostprovider"
-
-# No persistent volume in Atomix to have clean state for each re-deploy of ONOS
-atomix:
-  persistence:
-    enabled: false
+onos:
+  image:
+    repository: voltha/voltha-onos
+    tag: master
+    pullPolicy: Always
+  onos_env:
+    - name: POD_IP
+      valueFrom:
+      fieldRef:
+        fieldPath: status.podIP
+    - name: NAMESPACE
+      valueFrom:
+      fieldRef:
+        fieldPath: metadata.namespace
+    - name: ONOS_APPS
+      value: "drivers,openflow-base,hostprovider"
+  # No persistent volume in Atomix to have clean state for each re-deploy of ONOS
+  atomix:
+    persistence:
+      enabled: false
 
 # Customization for BBSIM
-kafka_broker: 'voltha-kafka.voltha.svc.cluster.local:9092'
-pon: 1
-onu: 1
+bbsim:
+  nni: 1
+  pon: 1
+  onu: 1
+  sadisFormat: "att"
+  kafkaEventTopic: "bbsim"
+  enableEvents: false
 
 # SHOCK THE MONKEY OR LET LOSE THE DOGS OF WAR
 # The VOLTHA charts have support for adding extra labels to deployments and
diff --git a/scripts/ced b/scripts/ced
index 1d85473..e1e1527 100755
--- a/scripts/ced
+++ b/scripts/ced
@@ -1,4 +1,12 @@
 #!/usr/bin/env bash
+REQ=$(test $# -gt 0 && echo $1 || echo 0)
+IDX=$((REQ + 1))
 set -x
-BBSIM=$(kubectl get --all-namespaces -l app=bbsim svc -o json | jq -r '.items[] | .metadata.name + "." + .metadata.namespace + ".svc:50060"' | head -1)
+BBSIM=$(kubectl get --all-namespaces -l app=bbsim svc -o json | jq -r '.items[] | .metadata.name + "." + .metadata.namespace + ".svc:50060"' | sed "$IDX!d")
+set +x
+if [[ -z "$BBSIM" ]]; then
+    >&2 echo "ERROR: No BBSIM instance found as index '$REQ'"
+    exit 1
+fi
+set -x
 exec voltctl device enable "$(voltctl device create -t openolt -H "$BBSIM")"
diff --git a/scripts/monitor.sh b/scripts/monitor.sh
index 4621941..b5952a2 100755
--- a/scripts/monitor.sh
+++ b/scripts/monitor.sh
@@ -67,7 +67,7 @@
 echo
 kubectl get --all-namespaces pods,svc,configmap | grep -v kube-system | cut -c -$__COLS
 echo
-kubectl  describe --all-namespaces  pods | grep Image: | grep '\(voltha\|bbsim\)' | sed -e "s/^ *//g" -e "s/: */: /g" | sort -u | cut -c -$COLS
+kubectl  describe --all-namespaces  pods | grep Image: | grep '\(voltha\|bbsim\)' | sed -e "s/^ *//g" -e "s/: */: /g" | sort -u | cut -c -$__COLS
 echo
 echo "DB SIZE: $("$SCRIPTPATH/etcd-db-size.sh")"
 echo
diff --git a/voltha b/voltha
index e41d5d8..8bb1059 100755
--- a/voltha
+++ b/voltha
@@ -1161,6 +1161,7 @@
     elif [ "${FILTER:0:1}" == "+" ]; then
         cp "$NAME-values.yaml" "$VALUES_FILE"
         yq r - "${FILTER:1}" <"$NAME-values.yaml" >>"$VALUES_FILE"
+        cat "$VALUES_FILE" >>"$LOG"
     else
         yq r - "$FILTER" <"$NAME-values.yaml" >"$VALUES_FILE"
     fi
@@ -1631,7 +1632,7 @@
         bspin "Verify ONOS LEGACY installed $BIRD"
         if [ "$HELM_USE_UPGRADE" == "yes" ] || [ "$(helm list --deployed --short --namespace "$INFRA_NS" "^onos\$" | wc -l)" -ne 1 ]; then
             espin "$NOT_VERIFIED"
-            INTERNAL_EXTRA_HELM_INSTALL_ARGS="$SET_TAG $EXTRA_HELM_FLAGS" helm_install - "$INFRA_NS" onos "$ONOS_CHART" "$ONOS_CHART_VERSION" - "$_HELM_DESC ONOS LEGACY"
+            INTERNAL_EXTRA_HELM_INSTALL_ARGS="$SET_TAG $EXTRA_HELM_FLAGS" helm_install - "$INFRA_NS" onos "$ONOS_CHART" "$ONOS_CHART_VERSION" "+onos" "$_HELM_DESC ONOS LEGACY"
             INTERNAL_EXTRA_HELM_INSTALL_ARGS=
         else
             espin "$VERIFIED"
@@ -1679,7 +1680,7 @@
             fi
 
             INTERNAL_EXTRA_HELM_INSTALL_ARGS="--set image.pullPolicy=$_ONOS_PULL_POLICY,image.repository=$_ONOS_REPO,image.tag=$_ONOS_TAG,replicas=$NUM_OF_ONOS,atomix.replicas=$NUM_OF_ATOMIX" \
-                helm_install - "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION" - "$_HELM_DESC ONOS CLASSIC"
+                helm_install - "$INFRA_NS" onos "$ONOS_CLASSIC_CHART" "$ONOS_CLASSIC_CHART_VERSION" "+onos" "$_HELM_DESC ONOS CLASSIC"
             INTERNAL_EXTRA_HELM_INSTALL_ARGS=
         else
             espin "$VERIFIED"
@@ -2105,7 +2106,17 @@
             else
                 INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set dhcp=false"
             fi
-            helm_install - "$BBSIM_NS" "bbsim${instance_num}" "$VOLTHA_BBSIM_CHART" "$VOLTHA_BBSIM_CHART_VERSION" - "$_HELM_DESC BBSIM${instance_num}"
+            if is_in "$WITH_KAFKA" "yes,external"; then
+                _HOST=kafka.$INFRA_NS.svc
+                _PORT=9092
+                INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafkaAddress=$_HOST:$_PORT"
+            elif [ "$WITH_KAFKA" != "no" ]; then
+                _HOST="$(echo "$WITH_KAFKA" | cut -d: -f1)"
+                _PORT="$(echo "$WITH_KAFKA" | cut -s -d: -f2)"
+                _PORT=${_PORT:-9092}
+                INTERNAL_EXTRA_HELM_INSTALL_ARGS+=" --set kafkaAddress=$_HOST:$_PORT"
+            fi
+            helm_install - "$BBSIM_NS" "bbsim${instance_num}" "$VOLTHA_BBSIM_CHART" "$VOLTHA_BBSIM_CHART_VERSION" "+bbsim" "$_HELM_DESC BBSIM${instance_num}"
             INTERNAL_EXTRA_HELM_INSTALL_ARGS=
         else
             espin - "$VERIFIED"