Skip to content

Commit

Permalink
Periodically push the netcfg instaed of one time push (#368)
Browse files Browse the repository at this point in the history
- Change the container image, we need jq and curl now
- Check the device value every 30 seconds
  • Loading branch information
hwchiu authored Mar 30, 2021
1 parent 6107e89 commit 4839f45
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion onos-tost/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
apiVersion: v1
name: onos-tost
version: 0.1.24
version: 0.1.25
kubeVersion: ">=1.10.0"
appVersion: 1.0.2-b4
description: ONOS helm chart for TOST
Expand Down
7 changes: 5 additions & 2 deletions onos-tost/templates/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ spec:
containers:
# Push config to ONOS REST API
- name: config-setter
image: curlimages/curl
image: badouralix/curl-jq:alpine
imagePullPolicy: IfNotPresent
env:
- name: USER
Expand All @@ -82,10 +82,13 @@ spec:
- name: CFG_FILE
value: {{ .Values.config.file }}
workingDir: {{ printf "%s/%s" $configDir .Values.config.repo }}
command: ["sh", "-c", "curl -v -u $USER:$PASSWD POST -H 'Content-Type: application/json' $NETCFG_URL -d@$CFG_FOLDER/$CFG_FILE"]
command: ["sh", "-c", "/usr/bin/onos-setter"]
volumeMounts:
- name: config-dir
mountPath: {{ $configDir }}
- name: configmap-config
mountPath: /usr/bin/onos-setter
subPath: onos-setter
volumes:
- name: config-dir
emptyDir: {}
Expand Down
12 changes: 12 additions & 0 deletions onos-tost/templates/configmap-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ metadata:
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
data:
onos-setter: |
#!/bin/sh
while true
set -e -x
do
DEVICE_COUNT=$(curl -s -u $USER:$PASSWD -X GET --header 'Accept: application/json' $NETCFG_URL | jq -r '.devices' | jq length)
if [ $DEVICE_COUNT = 0 ]; then
curl -v -u $USER:$PASSWD -X POST -H 'Content-Type: application/json' $NETCFG_URL -d@$CFG_FOLDER/$CFG_FILE
fi
sleep 30s
done
onos-config: |
#!/bin/sh
set -e -x
Expand Down

0 comments on commit 4839f45

Please sign in to comment.