Ray Milkey | bba7138 | 2015-08-26 13:09:23 -0700 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | #! usage: onos-create-intent target-onos-instance name point deviceId1 deviceId2 |
| 3 | #! onos-create-intent target-onos-instance name host hostId1 hostId2 |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | # Installs a new intent using the ONOS CLI |
| 6 | # ----------------------------------------------------------------------------- |
| 7 | |
| 8 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| 9 | . $ONOS_ROOT/tools/build/envDefaults |
| 10 | |
| 11 | aux=/tmp/stc-$$.log |
| 12 | trap "rm -f $aux 2>/dev/null" EXIT |
| 13 | target=$1 |
| 14 | name=$2 |
| 15 | type=$3 |
| 16 | arg1=$4 |
| 17 | arg2=$5 |
| 18 | |
| 19 | set -x |
| 20 | |
| 21 | onos $target "onos:add-${type}-intent" "${arg1}" "${arg2}" >> $aux |
| 22 | result=$? |
| 23 | cat $aux |
| 24 | |
| 25 | if [ $result -eq 0 ]; then |
| 26 | id=$(cat $aux | sed -e "1d" | sed -e "s/^[a-zA-Z]*{//" | sed -e "s/,.*$//" | sed -e "s/^...//") |
| 27 | echo @stc ${name}Id=${id} |
| 28 | fi |
| 29 | |
| 30 | |
| 31 | exit $result |
| 32 | |