blob: fd74f58ccded38d53d802cfd9081da62017a78b1 [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 Scandolo88056cd2021-02-17 12:32:19 -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";
34 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;
35
36 echo -e "Loading component configs into ONOS\n";
37 CFGS=$(ls /opt/configs | grep -v netcfg.json);
38 for CFG in ${CFGS};
39 do
Matteo Scandolodf2ac532021-02-05 14:05:41 -080040 echo -e "Check that component $CFG is active";
41 until curl --fail -sSL --user {{ .Values.onos.username }}:{{ .Values.onos.password }} -X GET "http://{{ .Release.Name }}-onos-classic-hs:8181/onos/v1/configuration/$CFG";
42 do
43 echo -e "Waiting for $CFG to be active";
44 sleep 5;
45 done
46 echo -e "Loading $CFG config";
Matteo Scandolob4c5f4e2020-11-11 12:05:23 -080047 curl --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;
48 done