Commit 7f77c320 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

ECOC F5GA Telemetry Demo:

- Updated subscribe telemetry script to stream telemetry data
parent be8e7bb6
Loading
Loading
Loading
Loading
+48 −3
Original line number Diff line number Diff line
@@ -19,10 +19,55 @@ cd $(dirname $0)


echo "[E2E] Subscribe Telemetry slice1..."
curl --request POST --location --header 'Content-Type: application/json' \
# POST to create subscription and capture response
resp=$(curl -sS --request POST --location --header 'Content-Type: application/json' \
    --data @data/telemetry/subscription-slice1.json \
    http://0.0.0.0:80/restconf/operations/subscriptions:establish-subscription
echo
    http://0.0.0.0:80/restconf/operations/subscriptions:establish-subscription)
echo "$resp"

# Ensure `jq` is available for JSON parsing
if ! command -v jq >/dev/null 2>&1; then
    echo "Error: jq is required but not installed. Install jq and retry." >&2
    exit 1
fi

# Extract the subscription URI from the JSON response
# Example response: {"identifier":"4086","uri":"/restconf/data/subscriptions/4086"}
uri=$(echo "$resp" | jq -r '.uri // empty')

if [ -z "$uri" ]; then
    echo "Failed to extract subscription URI from response" >&2
    exit 1
fi

# Build full URL (use http for RESTCONF chunked/SSE-style streaming)
full_url="http://0.0.0.0:80${uri}"

echo "Streaming telemetry from '$full_url' (press Ctrl+C to stop)..."

# Attempt a long-lived HTTP GET that will dump data as it arrives.
# Many RESTCONF subscription implementations use chunked responses / SSE
# and this curl invocation will keep printing incoming data.
curl -N -sS -H 'Accept: application/yang-data+json' "$full_url"

# If your server exposes a WebSocket endpoint instead, use a websocket client
# such as `websocat` or `wscat`. Example (requires websocat):
#   websocat "ws://0.0.0.0:80${uri}"
# Or using node's wscat:
#   npx wscat -c "ws://0.0.0.0:80${uri}"

# If you need a Python websocket client (requires `websocket-client`):
#   python3 - <<'PY'
#from websocket import create_connection
#ws = create_connection('ws://0.0.0.0:80' + '${uri}')
#try:
#    while True:
#        msg = ws.recv()
#        print(msg)
#finally:
#    ws.close()
#PY

echo

echo "Done!"