cleanup, sensible default override capability, openolt and onu support

Change-Id: I8e542dfe40947324c44a19605dde23d0e5198afe
diff --git a/voltha/Chart.yaml b/voltha/Chart.yaml
index aa52ca8..458881f 100644
--- a/voltha/Chart.yaml
+++ b/voltha/Chart.yaml
@@ -17,5 +17,5 @@
 description: A Helm chart for Voltha based on K8S resources in Voltha project
 icon: https://guide.opencord.org/logos/cord.svg
 
-version: 2.0.1
+version: 2.0.2
 appVersion: 2.0.0
diff --git a/voltha/templates/affinity-router.yaml b/voltha/templates/api-server.yaml
similarity index 80%
rename from voltha/templates/affinity-router.yaml
rename to voltha/templates/api-server.yaml
index ab8b4b2..490cb7e 100644
--- a/voltha/templates/affinity-router.yaml
+++ b/voltha/templates/api-server.yaml
@@ -45,8 +45,8 @@
       serviceAccountName: {{ .Values.serviceaccount }}
       containers:
       - name: arouter
-        image: {{ .Values.registry }}{{ .Values.images.afrouter.repository }}:{{ tpl .Values.images.afrouter.tag . }}
-        imagePullPolicy: {{ .Values.images.afrouter.pullPolicy }}
+        image: {{ tpl .Values.images.afrouter.registry . }}{{ tpl .Values.images.afrouter.repository . }}:{{ tpl .Values.images.afrouter.tag . }}
+        imagePullPolicy: {{ tpl .Values.images.afrouter.pullPolicy . }}
         volumeMounts:
         - name: config-volume
           mountPath: /app/config
@@ -61,8 +61,8 @@
         env:
         - name: POD_NAMESPACE
           value: {{ .Release.Namespace }}
-        image: {{ .Values.registry }}{{ .Values.images.afrouterd.repository }}:{{ tpl .Values.images.afrouterd.tag . }}
-        imagePullPolicy: {{ .Values.images.afrouterd.pullPolicy }}
+        image: {{ tpl .Values.images.afrouterd.registry . }}{{ tpl .Values.images.afrouterd.repository . }}:{{ tpl .Values.images.afrouterd.tag . }}
+        imagePullPolicy: {{ tpl .Values.images.afrouterd.pullPolicy . }}
         command: ["/app/arouterd"]
       restartPolicy: Always
       volumes:
diff --git a/voltha/templates/cli.yaml b/voltha/templates/cli.yaml
index 244c4ca..edb4eb0 100644
--- a/voltha/templates/cli.yaml
+++ b/voltha/templates/cli.yaml
@@ -48,8 +48,8 @@
       serviceAccountName: {{ .Values.serviceaccount }}
       containers:
         - name: vcli
-          image: {{ .Values.registry }}{{ .Values.images.cli.repository }}:{{ tpl .Values.images.cli.tag . }}
-          imagePullPolicy: {{ .Values.images.cli.pullPolicy }}
+          image: {{ tpl .Values.images.cli.registry . }}{{ tpl .Values.images.cli.repository . }}:{{ tpl .Values.images.cli.tag . }}
+          imagePullPolicy: {{ tpl .Values.images.cli.pullPolicy . }}
           env:
             - name: POD_IP
               valueFrom:
diff --git a/voltha/templates/ofagent.yaml b/voltha/templates/ofagent.yaml
index 2dd9e74..ab256b8 100644
--- a/voltha/templates/ofagent.yaml
+++ b/voltha/templates/ofagent.yaml
@@ -31,8 +31,8 @@
       serviceAccountName: {{ .Values.serviceaccount }}
       containers:
       - name: ofagent
-        image: {{ .Values.registry }}{{ .Values.images.ofagent.repository }}:{{ tpl .Values.images.ofagent.tag . }}
-        imagePullPolicy: {{ .Values.images.ofagent.pullPolicy }}
+        image: {{ tpl .Values.images.ofagent.registry . }}{{ tpl .Values.images.ofagent.repository . }}:{{ tpl .Values.images.ofagent.tag . }}
+        imagePullPolicy: {{ tpl .Values.images.ofagent.pullPolicy . }}
         env:
         - name: CONTROLLER_SERVICE
           value: "{{ .Values.services.controller.service }}:{{ .Values.services.controller.port }}"
diff --git a/voltha/templates/ro-core.yaml b/voltha/templates/ro-core.yaml
index 8225e00..7644c5a 100644
--- a/voltha/templates/ro-core.yaml
+++ b/voltha/templates/ro-core.yaml
@@ -45,8 +45,8 @@
       serviceAccountName: {{ .Values.serviceaccount }}
       containers:
         - name: voltha
-          image: {{ .Values.registry }}{{ .Values.images.ro_core.repository }}:{{ tpl .Values.images.ro_core.tag . }}
-          imagePullPolicy: {{ .Values.images.ro_core.pullPolicy }}
+          image: {{ tpl .Values.images.ro_core.registry . }}{{ tpl .Values.images.ro_core.repository . }}:{{ tpl .Values.images.ro_core.tag . }}
+          imagePullPolicy: {{ tpl .Values.images.ro_core.pullPolicy . }}
           env:
             - name: NAMESPACE
               value: {{ quote .Release.Namespace }}
@@ -54,15 +54,11 @@
               valueFrom:
                 fieldRef:
                   fieldPath: status.podIP
-            - name: ETCD_SERVICE
-              value: {{ quote .Values.services.etcd.service }}
-            - name: ETCD_SERVICE_PORT
-              value: {{ quote .Values.services.etcd.port }}
           args:
             - "/app/ro_core"
             - "-kv_store_type=etcd"
-            - "-kv_store_host=$(ETCD_SERVICE)"
-            - "-kv_store_port=$(ETCD_SERVICE_PORT)"
+            - "-kv_store_host={{ .Values.services.etcd.service }}"
+            - "-kv_store_port={{ .Values.services.etcd.port }}"
             - "-grpc_host=$(POD_IP)"
             - "-grpc_port=50057"
             - "-banner=true"
diff --git a/voltha/templates/rw-core.yaml b/voltha/templates/rw-core.yaml
index 5be011d..7945d57 100644
--- a/voltha/templates/rw-core.yaml
+++ b/voltha/templates/rw-core.yaml
@@ -15,6 +15,12 @@
 {{- $root := . -}}
 {{- $count := mul .Values.replicas.rw_core 2 | int }}
 {{- $tag := tpl .Values.images.rw_core.tag . }}
+{{- $repository := tpl .Values.images.rw_core.repository . }}
+{{- $registry := tpl .Values.images.rw_core.registry . }}
+{{- $pullpolicy := tpl .Values.images.rw_core.pullPolicy . }}
+{{- $core_timeout := tpl $root.Values.rw_core.core_timeout . }}
+{{- $long_request_timeout := tpl $root.Values.rw_core.timeout_long_request . }}
+{{- $request_timeout := tpl $root.Values.rw_core.timeout_request . }}
 {{- range $i, $e := until $count }}
 {{- $core_idx := add $i 1 }}
 {{- $affinity_group := add1 (mod $i 2) }}
@@ -60,8 +66,8 @@
       serviceAccountName: {{ $root.Values.serviceaccount }}
       containers:
         - name: voltha
-          image: {{ $root.Values.registry }}{{ $root.Values.images.rw_core.repository }}:{{ $tag }}
-          imagePullPolicy: {{ $root.Values.images.rw_core.pullPolicy }}
+          image: {{ $registry }}{{ $repository }}:{{ $tag }}
+          imagePullPolicy: {{ $pullpolicy }}
           env:
             - name: NAMESPACE
               value: {{ quote $root.Release.Namespace }}
@@ -69,36 +75,25 @@
               valueFrom:
                 fieldRef:
                   fieldPath: status.podIP
-            - name: ETCD_SERVICE
-              value: {{ quote $root.Values.services.etcd.service }}
-            - name: ETCD_SERVICE_PORT
-              value: {{ quote $root.Values.services.etcd.port }}
-            - name: ADAPTER_KAFKA_SERVICE
-              value: {{ quote $root.Values.services.kafka.adapter.service }}
-            - name: ADAPTER_KAFKA_SERVICE_PORT
-              value: {{ quote $root.Values.services.kafka.adapter.port }}
-            - name: CLUSTER_KAFKA_SERVICE
-              value: {{ quote $root.Values.services.kafka.cluster.service }}
-            - name: CLUSTER_KAFKA_SERVICE_PORT
-              value: {{ quote $root.Values.services.kafka.cluster.port }}
           args:
             - "/app/rw_core"
             - "-kv_store_type=etcd"
-            - "-kv_store_host=$(ETCD_SERVICE)"
-            - "-kv_store_port=$(ETCD_SERVICE_PORT)"
+            - "-kv_store_host={{ $root.Values.services.etcd.service }}"
+            - "-kv_store_port={{ $root.Values.services.etcd.port }}"
             - "-grpc_host=$(POD_IP)"
             - "-grpc_port=50057"
             - "-banner=true"
-            - "-kafka_adapter_host=$(ADAPTER_KAFKA_SERVICE)"
-            - "-kafka_adapter_port=$(ADAPTER_KAFKA_SERVICE_PORT)"
-            - "-kafka_cluster_host=$(CLUSTER_KAFKA_SERVICE)"
-            - "-kafka_cluster_port=$(CLUSTER_KAFKA_SERVICE_PORT)"
+            - "-kafka_adapter_host={{ $root.Values.services.kafka.adapter.service }}"
+            - "-kafka_adapter_port={{ $root.Values.services.kafka.adapter.port }}"
+            - "-kafka_cluster_host={{ $root.Values.services.kafka.cluster.port }}"
+            - "-kafka_cluster_port={{ $root.Values.services.kafka.cluster.port }}"
             - "-rw_core_topic=rwcore"
             - "-kv_store_data_prefix=service/voltha"
             - "-in_competing_mode=true"
-            - "-timeout_long_request=8000"
-            - "-timeout_request=6000"
-            - "-log_level=4"
+            - "-core_timeout={{ $core_timeout }}"
+            - "-timeout_long_request={{ $long_request_timeout }}"
+            - "-timeout_request={{ $request_timeout }}"
+            - "-log_level=2"
           ports:
             - containerPort: 50057
               name: grpc-port
diff --git a/voltha/values.yaml b/voltha/values.yaml
index 27da6d9..7221470 100644
--- a/voltha/values.yaml
+++ b/voltha/values.yaml
@@ -13,11 +13,19 @@
 # limitations under the License.
 
 ---
-registry: ''
 serviceaccount: voltha-serviceaccount
 private_etcd_cluster: true
 private_kafka_cluster: true
 
+# Default overrides
+defaults:
+  image_registry:
+  image_tag:
+  image_org:
+  image_pullPolicy:
+  rw_core:
+    timeout:
+
 # Configure the Kafka sub-chart (if it is used)
 kafka:
   configurationOverrides:
@@ -65,35 +73,47 @@
   afrouter: 1
   afrouterd: 1
 
+rw_core:
+  core_timeout: '{{ .Values.defaults.rw_core.timeout | default "8000" }}'
+  timeout_long_request: '{{ .Values.defaults.rw_core.timeout | default "8000" }}'
+  timeout_request: '{{ .Values.defaults.rw_core.timeout | default "8000" }}'
+
+
 # Define Docker images to be used
 images:
   cli:
-    repository: 'volthacore/voltha-cli'
-    tag: '{{ .Chart.AppVersion }}'
-    pullPolicy: 'Always'
+    registry: '{{ .Values.defaults.image_registry | default "" }}'
+    repository: '{{ .Values.defaults.image_org | default "voltha/" }}voltha-cli'
+    tag: '{{ .Values.defaults.image_tag | default .Chart.AppVersion }}'
+    pullPolicy: '{{ .Values.defaults.image_pullPolicy | default "Always" }}'
 
   ofagent:
-    repository: 'volthacore/voltha-ofagent'
-    tag: '{{ .Chart.AppVersion }}'
-    pullPolicy: 'Always'
+    registry: '{{ .Values.defaults.image_registry | default "" }}'
+    repository: '{{ .Values.defaults.image_org | default "voltha/" }}voltha-ofagent'
+    tag: '{{ .Values.defaults.image_tag | default .Chart.AppVersion }}'
+    pullPolicy: '{{ .Values.defaults.image_pullPolicy | default "Always" }}'
 
   ro_core:
-    repository: 'volthacore/voltha-ro-core'
-    tag: '{{ .Chart.AppVersion }}'
-    pullPolicy: 'Always'
+    registry: '{{ .Values.defaults.image_registry | default "" }}'
+    repository: '{{ .Values.defaults.image_org | default "voltha/" }}voltha-ro-core'
+    tag: '{{ .Values.defaults.image_tag | default .Chart.AppVersion }}'
+    pullPolicy: '{{ .Values.defaults.image_pullPolicy | default "Always" }}'
 
   rw_core:
-    repository: 'volthacore/voltha-rw-core'
-    tag: '{{ .Chart.AppVersion }}'
-    pullPolicy: 'Always'
+    registry: '{{ .Values.defaults.image_registry | default "" }}'
+    repository: '{{ .Values.defaults.image_org | default "voltha/" }}voltha-rw-core'
+    tag: '{{ .Values.defaults.image_tag | default .Chart.AppVersion }}'
+    pullPolicy: '{{ .Values.defaults.image_pullPolicy | default "Always" }}'
 
   afrouter:
-    repository: 'volthacore/voltha-afrouter'
-    tag: '{{ .Chart.AppVersion }}'
-    pullPolicy: 'Always'
+    registry: '{{ .Values.defaults.image_registry | default "" }}'
+    repository: '{{ .Values.defaults.image_org | default "voltha/" }}voltha-afrouter'
+    tag: '{{ .Values.defaults.image_tag | default .Chart.AppVersion }}'
+    pullPolicy: '{{ .Values.defaults.image_pullPolicy | default "Always" }}'
 
   afrouterd:
-    repository: 'volthacore/voltha-afrouterd'
-    tag: '{{ .Chart.AppVersion }}'
-    pullPolicy: 'Always'
+    registry: '{{ .Values.defaults.image_registry | default "" }}'
+    repository: '{{ .Values.defaults.image_org | default "voltha/" }}voltha-afrouterd'
+    tag: '{{ .Values.defaults.image_tag | default .Chart.AppVersion }}'
+    pullPolicy: '{{ .Values.defaults.image_pullPolicy | default "Always" }}'
     restartPolicy: 'Always'