create-forward-objective.sh
896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# /bin/sh
if [ "$#" -ne 6 ]
then
echo usage: create-forward-objective.sh onos device src-mac dst-mac src-port dst-port
exit 1
fi
onos=$1
device=$2
srcMac=$3
dstMac=$4
srcPort=$5
dstPort=$6
curl -u onos:rocks -X POST --header "Content-Type: application/json" --header "Accept: application/json" -d "{
\"priority\": 100,
\"isPermanent\": \"false\",
\"timeout\": 100,
\"flag\": \"VERSATILE\",
\"operation\": \"ADD\",
\"selector\": {
\"criteria\": [
{\"type\": \"ETH_TYPE\", \"ethType\": 2048},
{\"type\": \"IN_PORT\", \"port\": \"$srcPort\"},
{\"type\": \"ETH_DST\", \"mac\": \"$dstMac\"},
{\"type\": \"ETH_SRC\", \"mac\": \"$srcMac\"}
]
},
\"treatment\":
{
\"instructions\":
[
{\"type\":\"OUTPUT\",\"port\":$dstPort}
],
\"deferred\":[]
}
}" http://${onos}:8181/onos/v1/flowobjectives/$device/forward
echo