blob: 1cad92d8ee6b30ef08f7fd4697b0ae0a2175b056 [file] [log] [blame]
Thomas Vachuska1627dc82015-11-13 12:22:14 -08001#!/bin/bash
2# -----------------------------------------------------------------------------
3# ONOS network configuration uploader.
4# -----------------------------------------------------------------------------
5
6[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7. $ONOS_ROOT/tools/build/envDefaults
Jonathan Hartc86b00e2016-02-17 22:31:50 -08008. $ONOS_ROOT/tools/test/bin/find-node.sh
Thomas Vachuska1627dc82015-11-13 12:22:14 -08009
Jonathan Hartc86b00e2016-02-17 22:31:50 -080010fail="--fail"
11[ "$1" == "-v" ] && shift && fail=""
12
13node=$(find_node $1)
Thomas Vachuska1627dc82015-11-13 12:22:14 -080014file="${2:-$ONOS_ROOT/tools/test/topos/oe-linear-3.json}"
15url="${3}"
16
Jonathan Hartc86b00e2016-02-17 22:31:50 -080017method="POST"
18[ $file == "delete" ] && method="DELETE"
19
Phil Huang465a9b82016-06-23 23:33:40 +080020# Validate JSON
21if [ $method == "POST" ]; then
22 cat $file | python -m json.tool >> /dev/null || echo "Not valid JSON File"; exit 1
23fi
24
Jonathan Hartc86b00e2016-02-17 22:31:50 -080025curl $fail -sSL --user $ONOS_WEB_USER:$ONOS_WEB_PASS \
26 -X $method -H 'Content-Type:application/json' \
Thomas Vachuska1627dc82015-11-13 12:22:14 -080027 http://$node:8181/onos/v1/network/configuration/${url} -d@$file