VOL-3213 - 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: Id6e1040fbe9f47af6233d8f560940b5401b60df0
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..53a657e 100644
--- a/full-values.yaml
+++ b/full-values.yaml
@@ -23,33 +23,32 @@
 # 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:
-    repository: voltha/voltha-onos
+#images:
+#  onos:
+#    repository: voltha/voltha-onos
     # IMAGE_SELECTION
     # ---------------
     # The helm chart used to deploy ONOS is the public ONOS helm chart so,
     # there is a need to specify the exact image repository and image tag.
     # If you would like to use the "master", "voltha-2.1", or other image
     # just replace the "tag" value below.
-    tag: master
+    #    tag: master
 
 # IMAGE_SELECTION
 # ---------------
@@ -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..b7adf13 100644
--- a/minimal-values.yaml
+++ b/minimal-values.yaml
@@ -39,16 +39,16 @@
 # information below (search for START_OPENONU_ADAPTER_GO).
 use_openonu_adapter_go: false
 
-images:
-  onos:
-    repository: voltha/voltha-onos
+#images:
+#  onos:
+#    repository: voltha/voltha-onos
     # IMAGE_SELECTION
     # ---------------
     # The helm chart used to deploy ONOS is the public ONOS helm chart so,
     # there is a need to specify the exact image repository and image tag.
     # If you would like to use the "master", "voltha-2.1", or other image
     # just replace the "tag" value below.
-    tag: master
+    #    tag: master
 
 # IMAGE_SELECTION
 # ---------------
@@ -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..6acc1f9 100755
--- a/voltha
+++ b/voltha
@@ -1631,7 +1631,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"
@@ -2105,7 +2105,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"