blob: b4578d8cd8b7fb5d3e2d2c2e5a2a6d3cd375889b [file] [log] [blame]
Matteo Scandolob4c5f4e2020-11-11 12:05:23 -08001---
2
3# Copyright 2020-present Open Networking Foundation
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16apiVersion: v1
17kind: ConfigMap
18metadata:
19 name: {{ .Release.Name }}-onos-configs-loader
20data:
21 loader.sh: >
22 set -euo pipefail
23
Matteo Scandolo98c06bf2021-02-17 10:12:22 -080024 # a POST to a non ready netcfg return 207 in case of failure, while a GET returns 404,
25 # check the apps key is ready to accept data before sending them
Matteo Scandoloa2e4be32021-03-02 10:28:22 -080026
Matteo Scandolo98c06bf2021-02-17 10:12:22 -080027 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";
28 do
29 echo -e "Waiting for netcfg to be active";
30 sleep 5;
31 done
32
Matteo Scandolob4c5f4e2020-11-11 12:05:23 -080033 echo -e "Loading netcfg into ONOS\n";
Matteo Scandoloa2e4be32021-03-02 10:28:22 -080034 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);
35 if [[ $responseCode == 207 ]]; then
36 echo "Failed to load netcfg, exiting..."
37 exit 1
38 fi
Matteo Scandolob4c5f4e2020-11-11 12:05:23 -080039
40 echo -e "Loading component configs into ONOS\n";
41 CFGS=$(ls /opt/configs | grep -v netcfg.json);
42 for CFG in ${CFGS};
43 do
Matteo Scandolodf2ac532021-02-05 14:05:41 -080044 echo -e "Check that component $CFG is active";
45 until curl --fail -sSL --user {{ .Values.onos.username }}:{{ .Values.onos.password }} -X GET "http://{{ .Release.Name }}-onos-classic-hs:8181/onos/v1/configuration/$CFG";
46 do
47 echo -e "Waiting for $CFG to be active";
48 sleep 5;
49 done
50 echo -e "Loading $CFG config";
Matteo Scandolo87ed1332021-03-17 17:29:18 -070051 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);
52 if [[ $responseCode == 207 ]]; then
53 echo "Failed to load $CFG, exiting..."
54 exit 1
55 fi
Matteo Scandolob4c5f4e2020-11-11 12:05:23 -080056 done