blob: 8ca2480a5677be286a76b30d2b66aed5995759b3 [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 Scandolobefe3732021-03-25 13:45:56 -070033 echo -e "\n\nLoading netcfg into ONOS\n";
34 cat /opt/configs/netcfg.json;
Matteo Scandoloa2e4be32021-03-02 10:28:22 -080035 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);
36 if [[ $responseCode == 207 ]]; then
37 echo "Failed to load netcfg, exiting..."
38 exit 1
39 fi
Matteo Scandolob4c5f4e2020-11-11 12:05:23 -080040
Matteo Scandolobefe3732021-03-25 13:45:56 -070041 sleep 5;
42 echo -e "Updated netconfig is:";
43 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";
44 echo -e "\nCompleted on: ";
45 date;
46
47 echo -e "\n\n\nLoading component configs into ONOS\n";
Matteo Scandolob4c5f4e2020-11-11 12:05:23 -080048 CFGS=$(ls /opt/configs | grep -v netcfg.json);
49 for CFG in ${CFGS};
50 do
Matteo Scandolodf2ac532021-02-05 14:05:41 -080051 echo -e "Check that component $CFG is active";
52 until curl --fail -sSL --user {{ .Values.onos.username }}:{{ .Values.onos.password }} -X GET "http://{{ .Release.Name }}-onos-classic-hs:8181/onos/v1/configuration/$CFG";
53 do
54 echo -e "Waiting for $CFG to be active";
55 sleep 5;
56 done
Matteo Scandolobefe3732021-03-25 13:45:56 -070057 echo -e "\nLoading $CFG config";
58 cat /opt/configs/$CFG;
Matteo Scandolo87ed1332021-03-17 17:29:18 -070059 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);
60 if [[ $responseCode == 207 ]]; then
61 echo "Failed to load $CFG, exiting..."
62 exit 1
63 fi
Matteo Scandolobefe3732021-03-25 13:45:56 -070064 echo -e "Updated component config for $CFG is:";
65 curl --fail -sSL --user {{ .Values.onos.username }}:{{ .Values.onos.password }} -X GET "http://{{ .Release.Name }}-onos-classic-hs:8181/onos/v1/configuration/$CFG";
66 echo -e "\nCompleted on: ";
67 date;
68 echo -e "\n\n\n"
Matteo Scandolob4c5f4e2020-11-11 12:05:23 -080069 done