#!/bin/bash
# iperf-benchmark-weave lifecycle script

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SLICE_NAME="${SLICE_NAME:-iperf-benchmark-slice}"
SITE="${SITE:-RENC}"

echo "=== iperf-benchmark-weave ==="
echo "Slice: $SLICE_NAME"
echo "Site: $SITE"
echo "Action: $1"

case "$1" in
    start)
        python3 "$SCRIPT_DIR/iperf_benchmark.py" start "$SLICE_NAME" "$SITE" 2>&1 | tee "$SCRIPT_DIR/weave.log"
        ;;
    stop)
        python3 "$SCRIPT_DIR/iperf_benchmark.py" stop "$SLICE_NAME" 2>&1 | tee "$SCRIPT_DIR/weave.log"
        ;;
    monitor)
        python3 "$SCRIPT_DIR/iperf_benchmark.py" monitor "$SLICE_NAME" 2>&1 | tee "$SCRIPT_DIR/weave.log"
        ;;
    *)
        echo "Usage: $0 {start|stop|monitor}"
        exit 1
        ;;
esac