Checking that ONOS netcfg is ready to accept data

Change-Id: I1d74c03f36271a6ef04573eb3009250eab9702df
diff --git a/voltha-infra/Chart.yaml b/voltha-infra/Chart.yaml
index b68a668..398fc80 100644
--- a/voltha-infra/Chart.yaml
+++ b/voltha-infra/Chart.yaml
@@ -29,7 +29,7 @@
 name: voltha-infra
 
 appVersion: "1.0"
-version: 0.1.3
+version: 0.1.4
 
 dependencies:
   - name: onos-classic
diff --git a/voltha-infra/templates/onos-config-loader-script.yaml b/voltha-infra/templates/onos-config-loader-script.yaml
index 25c6d0a..891c400 100644
--- a/voltha-infra/templates/onos-config-loader-script.yaml
+++ b/voltha-infra/templates/onos-config-loader-script.yaml
@@ -21,6 +21,14 @@
   loader.sh: >
     set -euo pipefail
 
+    # 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 "Loading netcfg into ONOS\n";
     curl --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;