Committed by
Thomas Vachuska
Make STC intent operations use intent IDs
Change-Id: Ib2eb4e66bd0243b2263c737fb074dbf3c34aa7fe
Showing
5 changed files
with
78 additions
and
20 deletions
tools/test/bin/find-intent.py
0 → 100755
1 | +#! /usr/bin/env python | ||
2 | + | ||
3 | +import requests | ||
4 | + | ||
5 | +from requests.auth import HTTPBasicAuth | ||
6 | + | ||
7 | +r = requests.get('http://192.168.56.101:8181/onos/v1/flows', auth=HTTPBasicAuth('onos', 'rocks')) | ||
8 | +deviceId = "of:0000000000000001" | ||
9 | +port = 4 | ||
10 | +flowsJson = r.json() | ||
11 | + | ||
12 | +for flow in flowsJson["flows"]: | ||
13 | + if deviceId == flow["deviceId"]: | ||
14 | + if flow["treatment"]["instructions"][0]["port"] == port: | ||
15 | + print flow | ||
16 | + | ||
17 | + | ||
18 | + | ||
19 | + |
... | @@ -10,10 +10,12 @@ aux=/tmp/stc-$$.log | ... | @@ -10,10 +10,12 @@ aux=/tmp/stc-$$.log |
10 | trap "rm -f $aux 2>/dev/null" EXIT | 10 | trap "rm -f $aux 2>/dev/null" EXIT |
11 | target=${1:-$OCI} | 11 | target=${1:-$OCI} |
12 | 12 | ||
13 | +echo onos-check-intent: $* | ||
14 | + | ||
13 | set -x | 15 | set -x |
14 | for i in 1 2 3; do | 16 | for i in 1 2 3; do |
15 | - onos $target "onos:intents" >> $aux | 17 | + onos $target "onos:intents" > $aux |
16 | - grep "state=$2" $aux && cat $aux && exit 0 | 18 | + ( cat $aux | grep "id=$2" | grep "state=$3" ) && cat $aux && exit 0 |
17 | sleep 1 | 19 | sleep 1 |
18 | done | 20 | done |
19 | 21 | ... | ... |
tools/test/bin/onos-create-intent
0 → 100755
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 | + |
... | @@ -25,19 +25,20 @@ | ... | @@ -25,19 +25,20 @@ |
25 | exec="onos-mininet sendAndExpect h4 ping -c1 h1 --expect ."/> | 25 | exec="onos-mininet sendAndExpect h4 ping -c1 h1 --expect ."/> |
26 | 26 | ||
27 | <step name="Create-Intent" requires="^" | 27 | <step name="Create-Intent" requires="^" |
28 | - exec="onos ${OC1} add-host-intent 00:00:00:00:00:01/-1 00:00:00:00:00:04/-1"/> | 28 | + exec="onos-create-intent ${OC1} hostToHost host 00:00:00:00:00:01/-1 00:00:00:00:00:04/-1"/> |
29 | - <step name="Validate-Intent-Installed" exec="onos-check-intent ${OC1} INSTALLED" | 29 | + <step name="Validate-Intent-Installed" exec="onos-check-intent ${OC1} ${hostToHostId} INSTALLED" |
30 | requires="Create-Intent" /> | 30 | requires="Create-Intent" /> |
31 | 31 | ||
32 | <import file="${ONOS_SCENARIOS}/net-link-down-up.xml" namespace="Host-Intent"/> | 32 | <import file="${ONOS_SCENARIOS}/net-link-down-up.xml" namespace="Host-Intent"/> |
33 | <dependency name="Host-Intent.Net-Link-Down-Up" requires="Validate-Intent-Installed"/> | 33 | <dependency name="Host-Intent.Net-Link-Down-Up" requires="Validate-Intent-Installed"/> |
34 | - <step name="Validate-Intent-Installed-Still" exec="onos-check-intent ${OC1} INSTALLED" | 34 | + |
35 | + <step name="Validate-Intent-Installed-Still" exec="onos-check-intent ${OC1} ${hostToHostId} INSTALLED" | ||
35 | requires="Host-Intent.Link-1-Down" /> | 36 | requires="Host-Intent.Link-1-Down" /> |
36 | 37 | ||
37 | - <step name="Validate-Intent-Failed" exec="onos-check-intent ${OC1} FAILED" | 38 | + <step name="Validate-Intent-Failed" exec="onos-check-intent ${OC1} ${hostToHostId} FAILED" |
38 | requires="Host-Intent.Link-2-Down" /> | 39 | requires="Host-Intent.Link-2-Down" /> |
39 | 40 | ||
40 | - <step name="Validate-Intent-Installed-Again" exec="onos-check-intent ${OC1} INSTALLED" | 41 | + <step name="Validate-Intent-Installed-Again" exec="onos-check-intent ${OC1} ${hostToHostId} INSTALLED" |
41 | requires="Host-Intent.Link-1-Up" /> | 42 | requires="Host-Intent.Link-1-Up" /> |
42 | <dependency name="Host-Intent.Ping-4" requires="Validate-Intent-Installed-Again" /> | 43 | <dependency name="Host-Intent.Ping-4" requires="Validate-Intent-Installed-Again" /> |
43 | 44 | ... | ... |
... | @@ -25,28 +25,32 @@ | ... | @@ -25,28 +25,32 @@ |
25 | exec="onos-mininet sendAndExpect h4 ping -c1 h1 --expect ."/> | 25 | exec="onos-mininet sendAndExpect h4 ping -c1 h1 --expect ."/> |
26 | 26 | ||
27 | <step name="P2P-Create-Intent-1-To-4" requires="^" | 27 | <step name="P2P-Create-Intent-1-To-4" requires="^" |
28 | - exec="onos ${OC1} add-point-intent of:0000000000000001/1 of:0000000000000004/1"/> | 28 | + exec="onos-create-intent ${OC1} oneToFour point of:0000000000000001/1 of:0000000000000004/1"/> |
29 | <step name="P2P-Create-Intent-4-To-1" requires="^" | 29 | <step name="P2P-Create-Intent-4-To-1" requires="^" |
30 | - exec="onos ${OC1} add-point-intent of:0000000000000004/1 of:0000000000000001/1"/> | 30 | + exec="onos-create-intent ${OC1} fourToOne point of:0000000000000004/1 of:0000000000000001/1"/> |
31 | - <step name="P2P-Validate-Point-Intents-Installed" exec="onos-check-intent ${OC1} INSTALLED" | 31 | + |
32 | - requires="P2P-Create-Intent-4-To-1" /> | 32 | + <step name="P2P-Validate-Point-Intents-Installed1" exec="onos-check-intent ${OC1} ${fourToOneId} INSTALLED" |
33 | + requires="^" /> | ||
34 | + <step name="P2P-Validate-Point-Intents-Installed2" exec="onos-check-intent ${OC1} ${oneToFourId} INSTALLED" | ||
35 | + requires="^" /> | ||
33 | 36 | ||
34 | <import file="${ONOS_SCENARIOS}/net-link-down-up.xml" namespace="Point-To-Point-Intent"/> | 37 | <import file="${ONOS_SCENARIOS}/net-link-down-up.xml" namespace="Point-To-Point-Intent"/> |
35 | - <dependency name="Point-To-Point-Intent.Net-Link-Down-Up" requires="P2P-Validate-Point-Intents-Installed"/> | 38 | + <dependency name="Point-To-Point-Intent.Net-Link-Down-Up" requires="P2P-Validate-Point-Intents-Installed2"/> |
36 | - <step name="P2P-Validate-Intent-Installed-Still" exec="onos-check-intent ${OC1} INSTALLED" | 39 | + <step name="P2P-Validate-Intent-Installed-Still" exec="onos-check-intent ${OC1} ${fourToOneId} INSTALLED" |
37 | requires="Point-To-Point-Intent.Link-1-Down" /> | 40 | requires="Point-To-Point-Intent.Link-1-Down" /> |
38 | 41 | ||
39 | - <step name="P2P-Validate-Intent-Failed" exec="onos-check-intent ${OC1} FAILED" | 42 | + <step name="P2P-Validate-Intent-Failed" exec="onos-check-intent ${OC1} ${fourToOneId} FAILED" |
43 | + requires="Point-To-Point-Intent.Link-2-Down" /> | ||
44 | + <step name="P2P-Validate-Intent-Failed2" exec="onos-check-intent ${OC1} ${oneToFourId} FAILED" | ||
40 | requires="Point-To-Point-Intent.Link-2-Down" /> | 45 | requires="Point-To-Point-Intent.Link-2-Down" /> |
41 | 46 | ||
42 | - <step name="P2P-Validate-Intent-Installed-Again" exec="onos-check-intent ${OC1} INSTALLED" | 47 | + <step name="P2P-Validate-Intent-Installed-Again" exec="onos-check-intent ${OC1} ${fourToOneId} INSTALLED" |
43 | requires="Point-To-Point-Intent.Link-1-Up" /> | 48 | requires="Point-To-Point-Intent.Link-1-Up" /> |
44 | <dependency name="Point-To-Point-Intent.Ping-4" requires="P2P-Validate-Intent-Installed-Again" /> | 49 | <dependency name="Point-To-Point-Intent.Ping-4" requires="P2P-Validate-Intent-Installed-Again" /> |
45 | 50 | ||
46 | - <step name="P2P-Remove-Intent" requires="~Point-To-Point-Intent.Net-Link-Down-Up" | 51 | + <step name="P2P-Remove-Intent-4-to-1" requires="~Point-To-Point-Intent.Net-Link-Down-Up" |
47 | - exec="onos ${OC1} remove-intent -p"/> | 52 | + exec="onos ${OC1} remove-intent -p org.onosproject.cli ${fourToOneId}"/> |
48 | - | 53 | + <step name="P2P-Remove-Intent-1-to-4" requires="^" |
49 | - | 54 | + exec="onos ${OC1} remove-intent -p org.onosproject.cli ${oneToFourId}"/> |
50 | - | ||
51 | </group> | 55 | </group> |
52 | </scenario> | 56 | </scenario> | ... | ... |
-
Please register or login to post a comment