From 81391595dca425ae58e2294898f09f11d9a32dbc Mon Sep 17 00:00:00 2001 From: Ashlee Young Date: Tue, 22 Sep 2015 12:49:09 -0700 Subject: bringing src to commit tag 65d551b50e782b0c1ea76c1a9ed1c5a801a5a7e4 Change-Id: Ib2da78962eaef856f418636c31b0f5c84286244f --- .../src/onos/tools/test/bin/onos-archetypes-test | 2 +- .../src/onos/tools/test/bin/onos-check-intent | 2 +- framework/src/onos/tools/test/bin/onos-check-logs | 20 ++++++ framework/src/onos/tools/test/bin/onos-install | 2 +- .../src/onos/tools/test/bin/onos-start-network | 26 +++++++- framework/src/onos/tools/test/bin/onos-topo-cfg | 3 +- framework/src/onos/tools/test/bin/onos-uninstall | 10 +++ framework/src/onos/tools/test/bin/stc | 16 ++++- framework/src/onos/tools/test/cells/office | 3 +- .../src/onos/tools/test/configs/office-dhcp.json | 22 +++++++ .../onos/tools/test/scenarios/bin/curl-with-retry | 23 +++++++ .../test/scenarios/bin/find-link-in-cluster.py | 54 +++++++++++++++ .../test/scenarios/bin/find-topo-infrastructure.py | 34 ++++++++++ .../onos/tools/test/scenarios/bin/query-cluster.py | 37 +++++++++++ .../onos/tools/test/scenarios/bin/query-topo.py | 35 ++++++++++ .../test/scenarios/bin/verify-topo-devices.py | 51 +++++++++++++++ .../onos/tools/test/scenarios/net-link-down-up.xml | 14 ++-- .../src/onos/tools/test/scenarios/net-pingall.xml | 4 +- .../src/onos/tools/test/scenarios/net-rest.xml | 19 +++--- .../src/onos/tools/test/scenarios/net-setup.xml | 6 +- .../src/onos/tools/test/scenarios/net-smoke.xml | 6 +- .../src/onos/tools/test/scenarios/net-topo.xml | 76 ++++++++++++++++++++++ .../onos/tools/test/scenarios/prerequisites.xml | 2 +- framework/src/onos/tools/test/topos/onos.py | 2 +- .../src/onos/tools/test/topos/opticalUtils.py | 74 +++++++++++++++++---- 25 files changed, 501 insertions(+), 42 deletions(-) create mode 100644 framework/src/onos/tools/test/configs/office-dhcp.json create mode 100755 framework/src/onos/tools/test/scenarios/bin/curl-with-retry create mode 100755 framework/src/onos/tools/test/scenarios/bin/find-link-in-cluster.py create mode 100755 framework/src/onos/tools/test/scenarios/bin/find-topo-infrastructure.py create mode 100755 framework/src/onos/tools/test/scenarios/bin/query-cluster.py create mode 100755 framework/src/onos/tools/test/scenarios/bin/query-topo.py create mode 100755 framework/src/onos/tools/test/scenarios/bin/verify-topo-devices.py create mode 100644 framework/src/onos/tools/test/scenarios/net-topo.xml (limited to 'framework/src/onos/tools/test') diff --git a/framework/src/onos/tools/test/bin/onos-archetypes-test b/framework/src/onos/tools/test/bin/onos-archetypes-test index 55f40e76..7ae00332 100755 --- a/framework/src/onos/tools/test/bin/onos-archetypes-test +++ b/framework/src/onos/tools/test/bin/onos-archetypes-test @@ -6,7 +6,7 @@ set -e export AROOT=/tmp/foo -export ARCHETYPE_OPTS="-DarchetypeGroupId=org.onosproject -DarchetypeVersion=1.3.0-SNAPSHOT" +export ARCHETYPE_OPTS="-DarchetypeGroupId=org.onosproject -DarchetypeVersion=1.4.0-SNAPSHOT" mkdir -p $AROOT for an in api bundle cli ui; do diff --git a/framework/src/onos/tools/test/bin/onos-check-intent b/framework/src/onos/tools/test/bin/onos-check-intent index e332dc5b..760afafe 100755 --- a/framework/src/onos/tools/test/bin/onos-check-intent +++ b/framework/src/onos/tools/test/bin/onos-check-intent @@ -13,7 +13,7 @@ target=${1:-$OCI} echo onos-check-intent: $* set -x -for i in {1..10}; do +for i in {1..15}; do onos $target "onos:intents" | tee $aux ( cat $aux | grep "key=$2" | grep "state=$3" ) && cat $aux && exit 0 sleep 1 diff --git a/framework/src/onos/tools/test/bin/onos-check-logs b/framework/src/onos/tools/test/bin/onos-check-logs index ec1013ab..40e3e106 100755 --- a/framework/src/onos/tools/test/bin/onos-check-logs +++ b/framework/src/onos/tools/test/bin/onos-check-logs @@ -3,6 +3,25 @@ # Checks the logs of the remote ONOS instance and makes sure they are clean. # ----------------------------------------------------------------------------- +function __usage() { +cat << _EOM_ + +usage: + $(basename $0) [node] ['old'] + +options: + - [node] : The node whose logs to inspect. The default is \$OCI. + - ['old'] : If 'old' is specified, the logs are simply searched for errors + and exceptions, and they are displayed. + +summary: + Checks the logs of the remote ONOS instance and makes sure they are clean. + +_EOM_ +} + +[ "$1" = "-h" ] && __usage && exit 0 + [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 . $ONOS_ROOT/tools/build/envDefaults @@ -17,6 +36,7 @@ if [ "$2" = "old" ]; then else ssh $remote " + [ "'`uname`'" != "'"Linux"'" ] && alias tac='tail -r' tac $LOG | awk ' BEGIN { off = 0; fail = 0; } / org.apache.karaf.main.lock.SimpleFileLock lock/ { diff --git a/framework/src/onos/tools/test/bin/onos-install b/framework/src/onos/tools/test/bin/onos-install index 0f4cc9dd..7384c2e3 100755 --- a/framework/src/onos/tools/test/bin/onos-install +++ b/framework/src/onos/tools/test/bin/onos-install @@ -43,7 +43,7 @@ ssh $remote " mkdir -p -- $ONOS_INSTALL_DIR/$KARAF_DIST/data/raft # Install the upstart configuration file and setup options for debugging - [ -z "$nostart" ] && sudo cp $ONOS_INSTALL_DIR/debian/onos.conf /etc/init/onos.conf + [ -z "$nostart" ] && sudo cp $ONOS_INSTALL_DIR/init/onos.conf /etc/init/onos.conf echo 'export ONOS_OPTS=debug' > $ONOS_INSTALL_DIR/options # Setup correct user to run onos-service diff --git a/framework/src/onos/tools/test/bin/onos-start-network b/framework/src/onos/tools/test/bin/onos-start-network index 1e162fb4..5412e096 100755 --- a/framework/src/onos/tools/test/bin/onos-start-network +++ b/framework/src/onos/tools/test/bin/onos-start-network @@ -1,17 +1,39 @@ #!/bin/bash # ----------------------------------------------------------------------------- -# Verifies connectivity to each node in ONOS cell. +# Starts a Mininet network topology connected to all nodes in a cell. # ----------------------------------------------------------------------------- +function __usage() { +cat << _EOM_ + +usage: + $(basename $0) [file] + +options: + - [file] : a Mininet topology file. Default is *sol.py* . + +summary: + Starts a Mininet network topology connected to all nodes in a cell. + + Currently, all topology files are assumed to be found in + \$OCN's ~/topos directory. Therefore [file] must be specified as + topos/filename. + +_EOM_ +} + +[ "$1" = "-h" ] && __usage && exit 0 + [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 . $ONOS_ROOT/tools/build/envDefaults SSHCMD="ssh -o PasswordAuthentication=no" SCPCMD="scp -q -o PasswordAuthentication=no" +topo=${1:-topos/sol.py} echo "Copying topology files to mininet vm." $SSHCMD -n $ONOS_USER@$OCN mkdir -p topos $SCPCMD $ONOS_ROOT/tools/test/topos/* $ONOS_USER@$OCN:topos/ echo "Starting Network." -$SSHCMD -t $ONOS_USER@$OCN sudo python topos/sol.py $(env | sort | egrep "OC[0-9]+" | cut -d= -f2) +$SSHCMD -t $ONOS_USER@$OCN sudo python $topo $(env | sort | egrep "OC[0-9]+" | cut -d= -f2) diff --git a/framework/src/onos/tools/test/bin/onos-topo-cfg b/framework/src/onos/tools/test/bin/onos-topo-cfg index 5f40d8e7..489083f7 100755 --- a/framework/src/onos/tools/test/bin/onos-topo-cfg +++ b/framework/src/onos/tools/test/bin/onos-topo-cfg @@ -8,7 +8,8 @@ node="${1:-$OCI}" file="${2:-$ONOS_ROOT/tools/test/topos/oe-linear-3.json}" +url="${3:-config/topology}" curl -sS --fail -L --user $ONOS_WEB_USER:$ONOS_WEB_PASS \ -X POST -H 'Content-Type:application/json' \ - http://$node:8181/onos/v1/config/topology -d@$file + http://$node:8181/onos/v1/${url} -d@$file diff --git a/framework/src/onos/tools/test/bin/onos-uninstall b/framework/src/onos/tools/test/bin/onos-uninstall index c04db7ac..7a8b9a5f 100755 --- a/framework/src/onos/tools/test/bin/onos-uninstall +++ b/framework/src/onos/tools/test/bin/onos-uninstall @@ -10,5 +10,15 @@ remote=$ONOS_USER@${1:-$OCI} ssh $remote " sudo stop onos 1>/dev/null 2>/dev/null + + # Wait for onos to stop up to 5 seconds + for i in \$(seq 1 5); do + [ -z \"\$(ps -ef | grep karaf.jar | grep -v grep)\" ] && break + sleep 1 + done + [ -z \"\$(ps -ef | grep karaf.jar | grep -v grep)\" ] || echo 'ONOS failed to stop.' + + # Remove onos directory and init file sudo rm -fr $ONOS_INSTALL_DIR + [ -f /etc/init/onos.conf ] && sudo rm /etc/init/onos.conf " diff --git a/framework/src/onos/tools/test/bin/stc b/framework/src/onos/tools/test/bin/stc index fe8a5afe..8737cf3f 100755 --- a/framework/src/onos/tools/test/bin/stc +++ b/framework/src/onos/tools/test/bin/stc @@ -3,7 +3,7 @@ # System Test Coordinator #------------------------------------------------------------------------------- -VER=1.3.0-SNAPSHOT +VER=1.4.0-SNAPSHOT JAR=~/.m2/repository/org/onosproject/onlab-stc/$VER/onlab-stc-$VER.jar SCENARIOS=$ONOS_ROOT/tools/test/scenarios @@ -15,9 +15,19 @@ scenario=${1:-smoke} [ ! -f $scenario ] && scenario=$scenario.xml [ ! -f $scenario ] && echo "Scenario $scenario file not found" && exit 1 +# Remove the test name from the list of parameters, if one is specified [ $# -ge 1 ] && shift -[ -t 1 ] && stcColor=true || unset stcColor +# If stcColor is not set, we will enable color if this is an interactive session +[ -t 1 ] && interactive=true || interactive=false +# stc requires that ONOS_USE_SSH=true, but we will store the old value and reset it after +sshSet=$([ -z ${ONOS_USE_SSH+x} ]) && oldSSH=$ONOS_USE_SSH +export ONOS_USE_SSH=true + +# Run stc [ -z "$stcDebug" ] && DEBUG_OPTS="" -java $DEBUG_OPTS -jar $JAR $scenario "$@" +stcColor=${stcColor:-$interactive} java $DEBUG_OPTS -jar $JAR $scenario "$@" + +# Reset the old value of ONOS_USE_SSH +[ $sshSet ] && export ONOS_USE_SSH=oldSSH || unset ONOS_USE_SSH diff --git a/framework/src/onos/tools/test/cells/office b/framework/src/onos/tools/test/cells/office index 2cd933e2..c8dc5997 100644 --- a/framework/src/onos/tools/test/cells/office +++ b/framework/src/onos/tools/test/cells/office @@ -3,5 +3,6 @@ export ONOS_NIC="10.1.10.*" export OC1="10.1.10.223" -export ONOS_APPS="drivers,openflow,fwd,proxyarp,mobility" +unset ONOS_USE_SSH +export ONOS_APPS="drivers,openflow,fwd,proxyarp,mobility,dhcp" diff --git a/framework/src/onos/tools/test/configs/office-dhcp.json b/framework/src/onos/tools/test/configs/office-dhcp.json new file mode 100644 index 00000000..f0cf3fb0 --- /dev/null +++ b/framework/src/onos/tools/test/configs/office-dhcp.json @@ -0,0 +1,22 @@ +{ + "apps": { + "org.onosproject.dhcp" : { + "dhcp" : { + "ip": "10.1.11.50", + "mac": "ca:fe:ca:fe:ca:fe", + "subnet": "255.255.252.0", + "broadcast": "10.1.11.255", + "router": "10.1.8.1", + "domain": "8.8.8.8", + "ttl": "63", + "lease": "300", + "renew": "150", + "rebind": "200", + "delay": "2", + "timeout": "150", + "startip": "10.1.11.51", + "endip": "10.1.11.100" + } + } + } +} diff --git a/framework/src/onos/tools/test/scenarios/bin/curl-with-retry b/framework/src/onos/tools/test/scenarios/bin/curl-with-retry new file mode 100755 index 00000000..c9546aea --- /dev/null +++ b/framework/src/onos/tools/test/scenarios/bin/curl-with-retry @@ -0,0 +1,23 @@ +#!/bin/bash + +aux=/tmp/stc-$$.log +trap "rm -f $aux 2>/dev/null" EXIT + +url=$1 + + +echo curl-with-retry: $* + +set -x +for i in {1..3}; do + curl -f -uonos:rocks ${url} >$aux + if [ $? = 0 ]; then + cat $aux + exit 0 + fi + sleep 1 +done + +cat $aux +exit 1 + diff --git a/framework/src/onos/tools/test/scenarios/bin/find-link-in-cluster.py b/framework/src/onos/tools/test/scenarios/bin/find-link-in-cluster.py new file mode 100755 index 00000000..928531fd --- /dev/null +++ b/framework/src/onos/tools/test/scenarios/bin/find-link-in-cluster.py @@ -0,0 +1,54 @@ +#! /usr/bin/env python + +import requests +import sys + +from requests.auth import HTTPBasicAuth + +if len(sys.argv) != 9: + print "usage: find-link-in-cluster onos-node name cluster-id expected-length src-device-id src-port dst-device-id dst-port" + sys.exit(1) + +node = sys.argv[1] +name = sys.argv[2] +cluster = sys.argv[3] +length = int(sys.argv[4]) +srcDeviceId = sys.argv[5] +srcPort = sys.argv[6] +dstDeviceId = sys.argv[7] +dstPort = sys.argv[8] + + +linksRequest = requests.get('http://' + node + ':8181/onos/v1/topology/clusters/' + + cluster + '/links', + auth=HTTPBasicAuth('onos', 'rocks')) + +if linksRequest.status_code != 200: + print linksRequest.text + sys.exit(1) + +linksJson = linksRequest.json() +linksLength = len(linksJson["links"]) + +if linksLength != length: + print "Expected length {} but got {}".format(length, linksLength) + sys.exit(1) + +for link in linksJson["links"]: + if srcDeviceId == link["src"]["device"] and srcPort == link["src"]["port"]: + if dstDeviceId == link["dst"]["device"] and dstPort == link["dst"]["port"]: + print "@stc " + name + "SrcDevice=" + link["src"]["device"] + print "@stc " + name + "SrcPort=" + link["src"]["port"] + print "@stc " + name + "DstDevice=" + link["dst"]["device"] + print "@stc " + name + "DstPort=" + link["dst"]["port"] + print "@stc " + name + "Type=" + link["type"] + print "@stc " + name + "State=" + link["state"] + sys.exit(0) + +print "Could not find link from {}:{} to {}:{}"\ + .format(srcDeviceId, srcPort, dstDeviceId, dstPort) +sys.exit(1) + + + + diff --git a/framework/src/onos/tools/test/scenarios/bin/find-topo-infrastructure.py b/framework/src/onos/tools/test/scenarios/bin/find-topo-infrastructure.py new file mode 100755 index 00000000..6d1970f7 --- /dev/null +++ b/framework/src/onos/tools/test/scenarios/bin/find-topo-infrastructure.py @@ -0,0 +1,34 @@ +#! /usr/bin/env python + +import requests +import sys +import urllib + +from requests.auth import HTTPBasicAuth + +if len(sys.argv) != 4: + print "usage: find-topo-infrastructure onos-node name connect-point" + sys.exit(1) + +node = sys.argv[1] +name = sys.argv[2] +id = sys.argv[3] + +infrastructureRequest = requests.get('http://' + node + ':8181/onos/v1/topology/infrastructure/' + + urllib.quote_plus(id), + auth=HTTPBasicAuth('onos', 'rocks')) + +if infrastructureRequest.status_code != 200: + print infrastructureRequest.text + sys.exit(1) + +infrastructureJson = infrastructureRequest.json() + +print "@stc " + name + "Infrastructure=" + str(infrastructureJson["infrastructure"]) + +sys.exit(0) + + + + + diff --git a/framework/src/onos/tools/test/scenarios/bin/query-cluster.py b/framework/src/onos/tools/test/scenarios/bin/query-cluster.py new file mode 100755 index 00000000..0cac7ac3 --- /dev/null +++ b/framework/src/onos/tools/test/scenarios/bin/query-cluster.py @@ -0,0 +1,37 @@ +#! /usr/bin/env python + +import requests +import sys +import urllib + +from requests.auth import HTTPBasicAuth + +if len(sys.argv) != 4: + print "usage: query-cluster onos-node name cluster-number" + sys.exit(1) + +node = sys.argv[1] +name = sys.argv[2] +cluster = sys.argv[3] + +topoRequest = requests.get('http://' + node + ':8181/onos/v1/topology/clusters/' + + cluster, + auth=HTTPBasicAuth('onos', 'rocks')) + +if topoRequest.status_code != 200: + print topoRequest.text + sys.exit(1) + +topoJson = topoRequest.json() + +print "@stc " + name + "Id=" + str(topoJson["id"]) +print "@stc " + name + "DeviceCount=" + str(topoJson["deviceCount"]) +print "@stc " + name + "LinkCount=" + str(topoJson["linkCount"]) +print "@stc " + name + "Root=" + topoJson["root"] + +sys.exit(0) + + + + + diff --git a/framework/src/onos/tools/test/scenarios/bin/query-topo.py b/framework/src/onos/tools/test/scenarios/bin/query-topo.py new file mode 100755 index 00000000..9b81b4ee --- /dev/null +++ b/framework/src/onos/tools/test/scenarios/bin/query-topo.py @@ -0,0 +1,35 @@ +#! /usr/bin/env python + +import requests +import sys +import urllib + +from requests.auth import HTTPBasicAuth + +if len(sys.argv) != 3: + print "usage: query-topo onos-node name" + sys.exit(1) + +node = sys.argv[1] +name = sys.argv[2] + +topoRequest = requests.get('http://' + node + ':8181/onos/v1/topology/', + auth=HTTPBasicAuth('onos', 'rocks')) + +if topoRequest.status_code != 200: + print topoRequest.text + sys.exit(1) + +topoJson = topoRequest.json() + +print "@stc " + name + "Time=" + str(topoJson["time"]) +print "@stc " + name + "Devices=" + str(topoJson["devices"]) +print "@stc " + name + "Links=" + str(topoJson["links"]) +print "@stc " + name + "Clusters=" + str(topoJson["clusters"]) + +sys.exit(0) + + + + + diff --git a/framework/src/onos/tools/test/scenarios/bin/verify-topo-devices.py b/framework/src/onos/tools/test/scenarios/bin/verify-topo-devices.py new file mode 100755 index 00000000..be834b9b --- /dev/null +++ b/framework/src/onos/tools/test/scenarios/bin/verify-topo-devices.py @@ -0,0 +1,51 @@ +#! /usr/bin/env python + +import requests +import sys +import urllib + +from requests.auth import HTTPBasicAuth + +if len(sys.argv) != 5: + print "usage: verify-topo-links onos-node cluster-id first-index last-index" + sys.exit(1) + +node = sys.argv[1] +cluster = sys.argv[2] +first = int(sys.argv[3]) +last = int(sys.argv[4]) + +found = 0 + +topoRequest = requests.get('http://' + node + ':8181/onos/v1/topology/clusters/' + + cluster + + "/devices", + auth=HTTPBasicAuth('onos', 'rocks')) + +if topoRequest.status_code != 200: + print topoRequest.text + sys.exit(1) + +topoJson = topoRequest.json() + +for deviceIndex in range(first, last+1): + lookingFor = "of:" + format(deviceIndex, '016x') + print lookingFor + for arrayIndex in range(0, len(topoJson["devices"])): + device = topoJson["devices"][arrayIndex] + if device == lookingFor: + found = found + 1 + print "Match found for " + device + break + + +if found == last - first: + sys.exit(0) + +print "Found " + str(found) + " matches, need " + str(last - first) +sys.exit(2) + + + + + diff --git a/framework/src/onos/tools/test/scenarios/net-link-down-up.xml b/framework/src/onos/tools/test/scenarios/net-link-down-up.xml index 8bcbfa7f..eb4727bd 100644 --- a/framework/src/onos/tools/test/scenarios/net-link-down-up.xml +++ b/framework/src/onos/tools/test/scenarios/net-link-down-up.xml @@ -20,7 +20,9 @@ exec="onos-mininet sendAndExpect h1 ping -c1 h4 --expect \ 0% packet loss"/> - + @@ -28,11 +30,15 @@ exec="onos-mininet sendAndExpect h1 ping -c1 -w1 h4 --expect 100% packet loss"/> - + - + - \ No newline at end of file + diff --git a/framework/src/onos/tools/test/scenarios/net-pingall.xml b/framework/src/onos/tools/test/scenarios/net-pingall.xml index 8968e0dc..87c13227 100644 --- a/framework/src/onos/tools/test/scenarios/net-pingall.xml +++ b/framework/src/onos/tools/test/scenarios/net-pingall.xml @@ -23,7 +23,7 @@ + exec="onos-mininet sendAndExpect py net.pingAll(1) --expect received"/> @@ -34,4 +34,4 @@ - \ No newline at end of file + diff --git a/framework/src/onos/tools/test/scenarios/net-rest.xml b/framework/src/onos/tools/test/scenarios/net-rest.xml index fc7b1d08..ab7804df 100644 --- a/framework/src/onos/tools/test/scenarios/net-rest.xml +++ b/framework/src/onos/tools/test/scenarios/net-rest.xml @@ -101,10 +101,10 @@ + exec="curl-with-retry ${xyLocation}"/> + exec="curl-with-retry ${yxLocation}"/> + exec="test ${dev4outFlowPort} -ge 1 -a ${dev4outFlowPort} -le 5"/> + - - - + exec="curl-with-retry ${xyLocation}" env="!"/> + exec="curl-with-retry ${yxLocation}" env="!"/> diff --git a/framework/src/onos/tools/test/scenarios/net-setup.xml b/framework/src/onos/tools/test/scenarios/net-setup.xml index e179ec5a..13252d0f 100644 --- a/framework/src/onos/tools/test/scenarios/net-setup.xml +++ b/framework/src/onos/tools/test/scenarios/net-setup.xml @@ -17,9 +17,9 @@ - - + + @@ -43,4 +43,4 @@ - \ No newline at end of file + diff --git a/framework/src/onos/tools/test/scenarios/net-smoke.xml b/framework/src/onos/tools/test/scenarios/net-smoke.xml index 53a5729c..91131c62 100644 --- a/framework/src/onos/tools/test/scenarios/net-smoke.xml +++ b/framework/src/onos/tools/test/scenarios/net-smoke.xml @@ -35,10 +35,14 @@ + + + + ~Net-Create-Flows, + ~Net-topo"/> diff --git a/framework/src/onos/tools/test/scenarios/net-topo.xml b/framework/src/onos/tools/test/scenarios/net-topo.xml new file mode 100644 index 00000000..e8e23997 --- /dev/null +++ b/framework/src/onos/tools/test/scenarios/net-topo.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/framework/src/onos/tools/test/scenarios/prerequisites.xml b/framework/src/onos/tools/test/scenarios/prerequisites.xml index 650aa411..2c541d5b 100644 --- a/framework/src/onos/tools/test/scenarios/prerequisites.xml +++ b/framework/src/onos/tools/test/scenarios/prerequisites.xml @@ -15,7 +15,7 @@ --> - + diff --git a/framework/src/onos/tools/test/topos/onos.py b/framework/src/onos/tools/test/topos/onos.py index 3e5bff7c..ae6045e3 100755 --- a/framework/src/onos/tools/test/topos/onos.py +++ b/framework/src/onos/tools/test/topos/onos.py @@ -62,7 +62,7 @@ class ONOS( Controller ): def start( self ): if self.inNamespace: - instanceOpts = ( '-furl mvn:org.onosproject/onos-features/1.3.0-SNAPSHOT/xml/features ' + instanceOpts = ( '-furl mvn:org.onosproject/onos-features/1.4.0-SNAPSHOT/xml/features ' '-s 8101' ) if self.ip is not None: instanceOpts += (' -a %s' % self.IP() ) diff --git a/framework/src/onos/tools/test/topos/opticalUtils.py b/framework/src/onos/tools/test/topos/opticalUtils.py index bef9deca..a1ae834b 100644 --- a/framework/src/onos/tools/test/topos/opticalUtils.py +++ b/framework/src/onos/tools/test/topos/opticalUtils.py @@ -70,9 +70,6 @@ from mininet.cli import CLI SLEEP_TIME = 2 TIMEOUT = 60 -REST_USER = 'onos' -REST_PW = 'rocks' - class OpticalSwitch(Switch): """ For now, same as Switch class. @@ -152,6 +149,17 @@ class LINCSwitch(OpticalSwitch): error('Please set ONOS_ROOT environment variable!\n') else: os.environ[ 'ONOS_ROOT' ] = onosDir + ### REST USER/PASS ### + try: + restUser = os.environ[ 'ONOS_WEB_USER' ] + restPass = os.environ[ 'ONOS_WEB_PASS' ] + except: + error('***WARNING: $ONOS_WEB_USER and $ONOS_WEB_PASS aren\'t set!\n') + error('***WARNING: Setting (probably) sane WEB user/pass values\n') + restUser = 'onos' + restPass = 'rocks' + os.environ[ 'ONOS_WEB_USER' ] = restUser + os.environ[ 'ONOS_WEB_PASS' ] = restPass ### LINC-directory lincDir = findDir.__func__('linc-oe', user) if not lincDir: @@ -283,7 +291,7 @@ class LINCSwitch(OpticalSwitch): json.dump(crossConnectJSON, fd, indent=4, separators=(',', ': ')) info('*** Pushing crossConnect.json to ONOS\n') output = quietRun('%s/tools/test/bin/onos-topo-cfg %s\ - Topology.json' % (self.onosDir, self.controllers[ 0 ].ip), shell=True) + Topology.json network/configuration/' % (self.onosDir, self.controllers[ 0 ].ip), shell=True) def stop_oe(self): ''' @@ -366,16 +374,17 @@ class LINCSwitch(OpticalSwitch): LINCSwitch.opticalJSON[ 'links' ] = linkConfig info('*** Writing Topology.json file\n') + topoJSON = LINCSwitch.makeTopoJSON() with open('Topology.json', 'w') as outfile: - json.dump(LINCSwitch.opticalJSON, outfile, indent=4, separators=(',', ': ')) + json.dump(topoJSON, outfile, indent=4, separators=(',', ': ')) info('*** Converting Topology.json to linc-oe format (TopoConfig.json) file (no oecfg) \n') - topoConfigJson = {}; - dpIdToName = {}; + topoConfigJson = {} + dpIdToName = {} - topoConfigJson["switchConfig"] = LINCSwitch.getSwitchConfig(dpIdToName); - topoConfigJson["linkConfig"] = LINCSwitch.getLinkConfig(dpIdToName); + topoConfigJson["switchConfig"] = LINCSwitch.getSwitchConfig(dpIdToName) + topoConfigJson["linkConfig"] = LINCSwitch.getLinkConfig(dpIdToName) #Writing to TopoConfig.json with open( 'TopoConfig.json', 'w' ) as outfile: @@ -433,7 +442,7 @@ class LINCSwitch(OpticalSwitch): time = 0 # Set up password authentication pw_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm() - pw_mgr.add_password(None, url, REST_USER, REST_PW) + pw_mgr.add_password(None, url, LINCSwitch.restUser, LINCSwitch.restPass) handler = urllib2.HTTPBasicAuthHandler(pw_mgr) opener = urllib2.build_opener(handler) opener.open(url) @@ -462,7 +471,8 @@ class LINCSwitch(OpticalSwitch): info('*** Pushing Topology.json to ONOS\n') for index in range(len(LINCSwitch.controllers)): - output = quietRun('%s/tools/test/bin/onos-topo-cfg %s Topology.json &' % (LINCSwitch.onosDir, LINCSwitch.controllers[ index ].ip), shell=True) + output = quietRun('%s/tools/test/bin/onos-topo-cfg %s Topology.json network/configuration/ &'\ + % (LINCSwitch.onosDir, LINCSwitch.controllers[ index ].ip), shell=True) # successful output contains the two characters '{}' # if there is more output than this, there is an issue if output.strip('{}'): @@ -477,6 +487,48 @@ class LINCSwitch(OpticalSwitch): nodeDpid += (id[i:(i + 2):]) + ":" return nodeDpid[0:-1]; + @staticmethod + def makeTopoJSON(): + """ + Builds ONOS network conifg system compatible dicts to be written as Topology.json file. + """ + topology = {} + links = {} + devices = {} + ports = {} + + for switch in LINCSwitch.opticalJSON[ 'devices' ]: + # build device entries - keyed on uri (DPID) and config key 'basic' + devDict = {} + devDict[ 'driver' ] = switch[ 'hw' ] + devDict[ 'mfr' ] = switch[ 'mfr' ] + devDict[ 'mac' ] = switch[ 'mac' ] + devDict[ 'type' ] = switch[ 'type' ] + devDict.update(switch[ 'annotations' ]) + + devSubj = switch[ 'uri' ] + devices[ devSubj ] = { 'basic': devDict } + + # build port entries - keyed on "uri/port" and config key 'optical' + for port in switch[ 'ports' ]: + portSubj = devSubj + '/' + str(port[ 'port' ]) + ports[ portSubj ] = { 'optical': port } + + # build link entries - keyed on "uri/port-uri/port" and config key 'basic' + for link in LINCSwitch.opticalJSON[ 'links' ]: + linkDict = {} + linkDict[ 'type' ] = link[ 'type' ] + linkDict.update(link[ 'annotations' ]) + + linkSubj = link[ 'src' ] + '-' + link[ 'dst' ] + links[ linkSubj ] = { 'basic': linkDict } + + topology[ 'links' ] = links + topology[ 'devices' ] = devices + topology[ 'ports' ] = ports + + return topology + @staticmethod def getSwitchConfig (dpIdToName): switchConfig = []; -- cgit 1.2.3-korg