[VOL-4247] Using latest upstream ONOS chart and removing custom onos-config-loader from the voltha-infra-chart

Change-Id: I7560442c0c2e57d0a589ce00b1c07ca6b7aa6777
diff --git a/voltha-infra/Chart.yaml b/voltha-infra/Chart.yaml
index f698988..bd0f496 100644
--- a/voltha-infra/Chart.yaml
+++ b/voltha-infra/Chart.yaml
@@ -29,12 +29,12 @@
 name: voltha-infra
 
 appVersion: "2.9-dev"
-version: 2.9.0
+version: 2.9.1
 
 dependencies:
   - name: onos-classic
     repository: https://charts.onosproject.org
-    version: 0.1.16
+    version: 0.1.19
     condition: onos-classic.enabled
   - name: bbsim-sadis-server
     repository: https://charts.opencord.org
diff --git a/voltha-infra/templates/clusterrolebinding.yaml b/voltha-infra/templates/etcd-periodic-defrag-cluster-role-binding.yaml
similarity index 82%
rename from voltha-infra/templates/clusterrolebinding.yaml
rename to voltha-infra/templates/etcd-periodic-defrag-cluster-role-binding.yaml
index 5ddc9c1..dc18b1c 100644
--- a/voltha-infra/templates/clusterrolebinding.yaml
+++ b/voltha-infra/templates/etcd-periodic-defrag-cluster-role-binding.yaml
@@ -15,13 +15,13 @@
 apiVersion: "rbac.authorization.k8s.io/v1"
 kind: "ClusterRoleBinding"
 metadata:
-  name: "{{ .Release.Name }}-onos-config-loader-pod-reader"
+  name: "{{ .Release.Name }}-etcd-defrag"
   namespace: {{ .Release.Namespace | quote }}
 subjects:
   - kind: "ServiceAccount"
-    name: "{{ .Release.Name }}-onos-config-loader-service-account"
+    name: "{{ .Release.Name }}-service-account"
     namespace: {{ .Release.Namespace | quote }}
 roleRef:
     kind: "ClusterRole"
-    name: "{{ .Release.Name }}-onos-config-loader-pod-reader"
-    apiGroup: "rbac.authorization.k8s.io"
+    name: "{{ .Release.Name }}-etcd-defrag"
+    apiGroup: "rbac.authorization.k8s.io"
\ No newline at end of file
diff --git a/voltha-infra/templates/clusterrole.yaml b/voltha-infra/templates/etcd-periodic-defrag-cluster-role.yaml
similarity index 92%
rename from voltha-infra/templates/clusterrole.yaml
rename to voltha-infra/templates/etcd-periodic-defrag-cluster-role.yaml
index ba7a0aa..610b662 100644
--- a/voltha-infra/templates/clusterrole.yaml
+++ b/voltha-infra/templates/etcd-periodic-defrag-cluster-role.yaml
@@ -15,9 +15,9 @@
 apiVersion: "rbac.authorization.k8s.io/v1"
 kind: "ClusterRole"
 metadata:
-  name: "{{ .Release.Name }}-onos-config-loader-pod-reader"
+  name: "{{ .Release.Name }}-etcd-defrag"
   namespace: {{ .Release.Namespace | quote }}
 rules:
   - apiGroups: [""]
     resources: ["pods", "pods/exec"]
-    verbs: ["get", "list", "watch", "create"]
+    verbs: ["get", "list", "watch", "create"]
\ No newline at end of file
diff --git a/voltha-infra/templates/etcd-periodic-defrag.yaml b/voltha-infra/templates/etcd-periodic-defrag.yaml
index 29b8083..3144f03 100644
--- a/voltha-infra/templates/etcd-periodic-defrag.yaml
+++ b/voltha-infra/templates/etcd-periodic-defrag.yaml
@@ -25,11 +25,11 @@
       template:
         spec:
           restartPolicy: OnFailure
-          serviceAccountName: "{{ .Release.Name }}-onos-config-loader-service-account"
+          serviceAccountName: "{{ .Release.Name }}-service-account"
           containers:
             - name: etcd-db-defrag
-              image: '{{ tpl .Values.images.onos_config_loader.registry . }}{{ tpl .Values.images.onos_config_loader.repository . }}:{{ tpl .Values.images.onos_config_loader.tag . }}'
-              imagePullPolicy: {{ tpl .Values.images.onos_config_loader.pullPolicy . }}
+              image: '{{ tpl .Values.etcd.defrag.image.registry . }}{{ tpl .Values.etcd.defrag.image.repository . }}:{{ tpl .Values.etcd.defrag.image.tag . }}'
+              imagePullPolicy: {{ tpl .Values.etcd.defrag.image.pullPolicy . }}
               command:
                 - /bin/sh
                 - -c
diff --git a/voltha-infra/templates/onos-config-loader-configmap.yaml b/voltha-infra/templates/onos-config-loader-configmap.yaml
deleted file mode 100644
index 612d3a1..0000000
--- a/voltha-infra/templates/onos-config-loader-configmap.yaml
+++ /dev/null
@@ -1,24 +0,0 @@
----
-
-# Copyright 2018-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-apiVersion: v1
-kind: ConfigMap
-metadata:
-  name: {{ .Release.Name }}-onos-configs-data
-data:
-  netcfg.json: {{ tpl .Values.onos.netcfg . | quote }}
-  {{- range $key, $val := .Values.onos.componentConfig }}
-  {{ $key }}: {{ $val | quote }}
-  {{- end }}
diff --git a/voltha-infra/templates/onos-config-loader-script.yaml b/voltha-infra/templates/onos-config-loader-script.yaml
deleted file mode 100644
index 6491ab7..0000000
--- a/voltha-infra/templates/onos-config-loader-script.yaml
+++ /dev/null
@@ -1,89 +0,0 @@
----
-
-# Copyright 2020-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-apiVersion: v1
-kind: ConfigMap
-metadata:
-  name: {{ .Release.Name }}-onos-configs-loader
-data:
-  loader.sh: >
-    set -euo pipefail
-
-    # onos-config-loader most likely start before ONOS is deployed, so check for ONOS before waiting for it to be ready
-
-    has_onos=$(kubectl get pods -l app=onos-classic --all-namespaces | wc -l);
-
-    while [[ $has_onos == 0 ]]; do
-      echo -e "Waiting for ONOS to be deployed";
-      sleep 5;
-      has_onos=$(kubectl get pods -l app=onos-classic --all-namespaces | wc -l);
-    done
-
-    # wait all ONOS pods to be ready
-
-    onos_starting=$(kubectl get pods -l app=onos-classic --all-namespaces --field-selector=status.phase!=Running | wc -l);
-
-    while [[ $onos_starting != 0 ]]; do
-      echo -e "$onos_starting ONOS instances are still starting...";
-      sleep 5;
-      onos_starting=$(kubectl get pods --all-namespaces -l app=onos-classic | grep "0/" | wc -l);
-    done
-
-    # a POST to a non ready netcfg return 207 in case of failure, while a GET returns 404,
-    # check the apps key is ready to accept data before sending them
-
-    until curl --fail -sSL --user {{ .Values.onos.username }}:{{ .Values.onos.password }} -X GET -H 'Accept: application/json' "http://{{ .Release.Name }}-onos-classic-hs:8181/onos/v1/network/configuration/apps";
-    do
-      echo -e "Waiting for netcfg to be active";
-      sleep 5;
-    done
-
-    echo -e "\n\nLoading netcfg into ONOS\n";
-    cat /opt/configs/netcfg.json;
-    responseCode=$(curl --write-out '%{http_code}' --fail -sSL --user {{ .Values.onos.username }}:{{ .Values.onos.password }} -X POST "http://{{ .Release.Name }}-onos-classic-hs:8181/onos/v1/network/configuration/" -H Content-type:application/json -d @/opt/configs/netcfg.json);
-    if [[ $responseCode == 207 ]]; then
-      echo "Failed to load netcfg, exiting..."
-      exit 1
-    fi
-
-    sleep 5;
-    echo -e "Updated netconfig is:";
-    curl --fail -sSL --user {{ .Values.onos.username }}:{{ .Values.onos.password }} -X GET -H 'Accept: application/json' "http://{{ .Release.Name }}-onos-classic-hs:8181/onos/v1/network/configuration";
-    echo -e "\nCompleted on: ";
-    date;
-
-    echo -e "\n\n\nLoading component configs into ONOS\n";
-    CFGS=$(ls /opt/configs | grep -v netcfg.json);
-    for CFG in ${CFGS};
-    do
-      echo -e "Check that component $CFG is active";
-      until curl --fail -sSL --user {{ .Values.onos.username }}:{{ .Values.onos.password }} -X GET "http://{{ .Release.Name }}-onos-classic-hs:8181/onos/v1/configuration/$CFG";
-      do
-        echo -e "Waiting for $CFG to be active";
-        sleep 5;
-      done
-      echo -e "\nLoading $CFG config";
-      cat /opt/configs/$CFG;
-      responseCode=$(curl --write-out '%{http_code}' --fail -sSL --user {{ .Values.onos.username }}:{{ .Values.onos.password }} -X POST "http://{{ .Release.Name }}-onos-classic-hs:8181/onos/v1/configuration/$CFG" -H Content-type:application/json -d @/opt/configs/$CFG);
-      if [[ $responseCode == 207 ]]; then
-        echo "Failed to load $CFG, exiting..."
-        exit 1
-      fi
-      echo -e "Updated component config for $CFG is:";
-      curl --fail -sSL --user {{ .Values.onos.username }}:{{ .Values.onos.password }} -X GET "http://{{ .Release.Name }}-onos-classic-hs:8181/onos/v1/configuration/$CFG";
-      echo -e "\nCompleted on: ";
-      date;
-      echo -e "\n\n\n"
-    done
diff --git a/voltha-infra/templates/onos-config-loader.yaml b/voltha-infra/templates/onos-config-loader.yaml
deleted file mode 100644
index 0c04cdc..0000000
--- a/voltha-infra/templates/onos-config-loader.yaml
+++ /dev/null
@@ -1,63 +0,0 @@
----
-
-# Copyright 2018-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-apiVersion: batch/v1
-kind: Job
-metadata:
-  name: {{ template "fullname" . }}-onos-config-loader
-  labels:
-    app: onos-config-loader
-    chart: {{ .Chart.Name }}
-    release: {{ .Release.Name }}
-spec:
-  backoffLimit: 12
-  template:
-    metadata:
-      labels:
-        app: onos-config-loader
-        release: {{ .Release.Name }}
-      annotations:
-        checksum/config: {{ include (print $.Template.BasePath "/onos-config-loader-configmap.yaml") . | sha256sum }}
-    spec:
-      restartPolicy: OnFailure
-      serviceAccountName: "{{ .Release.Name }}-onos-config-loader-service-account"
-      containers:
-        - name: onos-config-loader
-          image: '{{ tpl .Values.images.onos_config_loader.registry . }}{{ tpl .Values.images.onos_config_loader.repository . }}:{{ tpl .Values.images.onos_config_loader.tag . }}'
-          imagePullPolicy: {{ tpl .Values.images.onos_config_loader.pullPolicy . }}
-          command:
-            - "/bin/bash"
-            - "/opt/loader/loader.sh"
-          volumeMounts:
-            - name: onos-configs
-              mountPath: /opt/configs
-            - name: onos-loader
-              mountPath: /opt/loader
-            - name: kube-config-volume
-              mountPath: /etc/kube
-      volumes:
-        - name: onos-configs
-          configMap:
-            name: {{ .Release.Name }}-onos-configs-data
-        - name: onos-loader
-          configMap:
-            name: {{ .Release.Name }}-onos-configs-loader
-            defaultMode: 0777
-        - name: kube-config-volume
-          configMap:
-            # Provide the name of the ConfigMap containing the files you want
-            # to add to the container
-            name: kube-config
diff --git a/voltha-infra/templates/serviceaccount.yaml b/voltha-infra/templates/serviceaccount.yaml
deleted file mode 100644
index 6cba9a8..0000000
--- a/voltha-infra/templates/serviceaccount.yaml
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright 2020-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
----
-apiVersion: "v1"
-kind: "ServiceAccount"
-metadata:
-  name: "{{ .Release.Name }}-onos-config-loader-service-account"
-  namespace: {{ .Release.Namespace | quote }}
diff --git a/voltha-infra/values.yaml b/voltha-infra/values.yaml
index e79aa6b..a2d464a 100644
--- a/voltha-infra/values.yaml
+++ b/voltha-infra/values.yaml
@@ -21,13 +21,6 @@
   image_tag: ~
   image_pullPolicy: "Always"
 
-images:
-  onos_config_loader:
-    registry: '{{ .Values.global.image_registry }}'
-    repository: '{{ .Values.global.image_org }}voltha-ci-tools'
-    tag: '{{- if hasKey .Values.global "image_tag" }}{{- if .Values.global.image_tag }}{{ .Values.global.image_tag }}-onos-config-loader{{- else }}2.3.2-onos-config-loader{{- end }}{{- else }}2.3.2-onos-config-loader{{- end }}'
-    pullPolicy: '{{ .Values.global.image_pullPolicy }}'
-
 # components config
 onos-classic:
   enabled: true
@@ -63,6 +56,79 @@
     java_opts: >
       -Xmx2G
       -XX:-UseContainerSupport
+  config:
+    enabled: true
+    netcfg: >
+      {
+        "apps" : {
+          "org.opencord.dhcpl2relay" : {
+            "dhcpl2relay" : {
+              "useOltUplinkForServerPktInOut" : true
+            }
+          },
+          "org.opencord.kafka": {
+            "kafka" : {
+              "bootstrapServers" : "{{ .Release.Name }}-kafka.{{ .Release.Namespace }}.svc:9092"
+            }
+          },
+          "org.opencord.aaa" : {
+            "AAA": {
+              "radiusConnectionType" : "socket",
+              "radiusHost": "{{ .Release.Name }}-freeradius.{{ .Release.Namespace }}.svc",
+              "radiusServerPort": "1812",
+              "radiusSecret": "SECRET"
+            }
+          },
+          "org.opencord.sadis": {
+            "sadis": {
+              "integration": {
+                "url": "http://bbsim-sadis-server.{{ .Release.Namespace }}.svc:58080/subscribers/%s",
+                "cache": {
+                  "enabled": true,
+                  "maxsize": 50,
+                  "ttl": "PT1m"
+                }
+              }
+            },
+            "bandwidthprofile": {
+              "integration": {
+                "url": "http://bbsim-sadis-server.{{ .Release.Namespace }}.svc:58080/profiles/%s",
+                "cache": {
+                  "enabled": true,
+                  "maxsize": 50,
+                  "ttl": "PT1m"
+                }
+              }
+            }
+          }
+        }
+      }
+    componentConfig:
+      "org.opencord.olt.impl.OltFlowService": >
+        {
+          "enableDhcpOnNni": "true",
+          "defaultTechProfileId": "64",
+          "enableIgmpOnNni": "false",
+          "enableEapol": "true",
+          "enableDhcpV6": "false",
+          "enableDhcpV4": "true"
+        }
+      "org.onosproject.provider.lldp.impl.LldpLinkProvider": >
+        {
+          "enabled": "false"
+        }
+      "org.onosproject.net.flow.impl.FlowRuleManager": >
+        {
+          "purgeOnDisconnection": "false"
+        }
+      "org.onosproject.net.meter.impl.MeterManager": >
+        {
+          "purgeOnDisconnection": "false"
+        }
+      "org.onosproject.net.group.impl.GroupManager": >
+        {
+          "purgeOnDisconnection": "false"
+        }
 
 bbsim-sadis-server:
   enabled: true
@@ -77,8 +143,13 @@
   # ETCD defrag creates a CronJob that runs "etcdctl defrag --cluster"
   # on a defined schedule
   defrag:
-    enabled: false
+    enabled: true
     schedule: "*/5 * * * *"
+    image:
+      registry: '{{ .Values.global.image_registry }}'
+      repository: 'opennetworking/utils'
+      tag: 0.2.0
+      pullPolicy: 'IfNotPresent'
 
   ingress:
     enabled: false
@@ -129,84 +200,6 @@
 efk:
   enabled: false
 
-# onos configuration
-# used in the job "onos-config-loader"
-onos:
-  # NOTE that these values won't change the configuration in the ONOS container, they are only used in the script that loads the config
-  username: karaf
-  password: karaf
-  netcfg: >
-    {
-      "apps" : {
-        "org.opencord.dhcpl2relay" : {
-          "dhcpl2relay" : {
-            "useOltUplinkForServerPktInOut" : true
-          }
-        },
-        "org.opencord.kafka": {
-          "kafka" : {
-            "bootstrapServers" : "{{ .Release.Name }}-kafka.{{ .Release.Namespace }}.svc:9092"
-          }
-        },
-        "org.opencord.aaa" : {
-          "AAA": {
-            "radiusConnectionType" : "socket",
-            "radiusHost": "{{ .Release.Name }}-freeradius.{{ .Release.Namespace }}.svc",
-            "radiusServerPort": "1812",
-            "radiusSecret": "SECRET"
-          }
-        },
-        "org.opencord.sadis": {
-          "sadis": {
-            "integration": {
-              "url": "http://bbsim-sadis-server.{{ .Release.Namespace }}.svc:58080/subscribers/%s",
-              "cache": {
-                "enabled": true,
-                "maxsize": 50,
-                "ttl": "PT1m"
-              }
-            }
-          },
-          "bandwidthprofile": {
-            "integration": {
-              "url": "http://bbsim-sadis-server.{{ .Release.Namespace }}.svc:58080/profiles/%s",
-              "cache": {
-                "enabled": true,
-                "maxsize": 50,
-                "ttl": "PT1m"
-              }
-            }
-          }
-        }
-      }
-    }
-  componentConfig:
-    "org.opencord.olt.impl.OltFlowService": >
-      {
-        "enableDhcpOnNni": "true",
-        "defaultTechProfileId": "64",
-        "enableIgmpOnNni": "false",
-        "enableEapol": "true",
-        "enableDhcpV6": "false",
-        "enableDhcpV4": "true"
-      }
-    "org.onosproject.provider.lldp.impl.LldpLinkProvider": >
-      {
-        "enabled": "false"
-      }
-    "org.onosproject.net.flow.impl.FlowRuleManager": >
-      {
-        "purgeOnDisconnection": "false"
-      }
-    "org.onosproject.net.meter.impl.MeterManager": >
-      {
-        "purgeOnDisconnection": "false"
-      }
-    "org.onosproject.net.group.impl.GroupManager": >
-      {
-        "purgeOnDisconnection": "false"
-      }
-
 # START EFK Setup to push voltha logs
 # elasticstack config
 # ref: https://github.com/elastic/helm-charts/tree/7.7.0/elasticsearch