blob: 08635decdb17a93e06ed57eb4460c45dc92cbd45 [file] [log] [blame]
#!/bin/bash
#
# Copyright 2015-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.
#
# -----------------------------------------------------------------------------
# ONOS network configuration uploader.
# -----------------------------------------------------------------------------
function usage() {
echo "usage: onos-netcfg [-v] [-P port] [-u user] [-p password] node file|DELETE [url]"
exit 1
}
. $(dirname $0)/_rest-port
. $(dirname $0)/_find-node
. $(dirname $0)/_check-json
node=$(find_node $1)
file="${2}"
url="${3}"
export URL="http://$node:$port/onos/v1/network/configuration/${url}"
export curl="curl ${fail} -sSL --user $user:$password --noproxy ${node} "
[ "$node" == "" -o "$file" == "" ] && usage;
method="POST"
[ $(echo $file | awk '{print tolower($0)}') == "delete" ] && method="DELETE"
if [ $method == "POST" ]; then
checkJson $file
$curl -X POST -H 'Content-Type:application/json' $URL -d@$file
elif [ $method == "DELETE" ]; then
$curl -X DELETE $URL
fi