blob: fd74f58ccded38d53d802cfd9081da62017a78b1 [file] [log] [blame]
---
# 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
# 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;
echo -e "Loading 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 "Loading $CFG config";
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;
done