Use stratum in Trellis P4 STC scenario
Change-Id: I6e9b34c449ebaca51e8fd1673a470e564195e69e
diff --git a/tools/test/bin/onos-push-bmv2 b/tools/test/bin/onos-push-bmv2-py
similarity index 81%
rename from tools/test/bin/onos-push-bmv2
rename to tools/test/bin/onos-push-bmv2-py
index d72f41e..8e8a870 100755
--- a/tools/test/bin/onos-push-bmv2
+++ b/tools/test/bin/onos-push-bmv2-py
@@ -3,6 +3,8 @@
# Remotely pushes bmv2 custom mininet script to a remote mininet test machine.
# -----------------------------------------------------------------------------
+set -e
+
[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
. $ONOS_ROOT/tools/build/envDefaults
@@ -10,6 +12,8 @@
user=$ONOS_WEB_USER
pass=$ONOS_WEB_PASS
-ssh $ONOS_USER@$node "sudo rm -rf ~/bmv2-mininet"
-ssh $ONOS_USER@$node "mkdir ~/bmv2-mininet"
-scp -qr $ONOS_ROOT/tools/dev/mininet/bmv2.py $ONOS_USER@[$node]:~/bmv2-mininet/
+ssh -tt $ONOS_USER@$node "
+ mkdir -p /tmp/bmv2_py
+ sudo rm -rf /tmp/bmv2_py/*
+"
+scp -qr $ONOS_ROOT/tools/dev/mininet/bmv2.py $ONOS_USER@[$node]:/tmp/bmv2_py
diff --git a/tools/test/scenarios/bin/mininet-p4-trellis b/tools/test/scenarios/bin/mininet-p4-trellis
index aeb9ef6..b5a3593 100755
--- a/tools/test/scenarios/bin/mininet-p4-trellis
+++ b/tools/test/scenarios/bin/mininet-p4-trellis
@@ -1,21 +1,34 @@
#!/bin/bash
-remote=$ONOS_USER@$OCN
-remote_scp=$ONOS_USER@[$OCN]
-mininet="ssh -t -t $remote screen -L -S mininet"
+# -----------------------------------------------------------------------------
+# Starts mininet in the network machine with the Trellis P4 topology
+# -----------------------------------------------------------------------------
-CONTROLLERS="$OC1"
+set -e
+set -x
-echo >/tmp/invoke_trellis_p4 "export ONOS_WEB_USER=$ONOS_WEB_USER && export ONOS_WEB_PASS=$ONOS_WEB_PASS && cd routing/trellis && sudo -E env PYTHONPATH=$PYTHONPATH:/home/sdn/bmv2-mininet ./trellisp4.py --onos-ip '$CONTROLLERS'"
-chmod +x /tmp/invoke_trellis_p4
-scp /tmp/invoke_trellis_p4 $remote_scp:
+[[ ! -d "$ONOS_ROOT" ]] && echo "ONOS_ROOT is not defined" >&2 && exit 1
+. $ONOS_ROOT/tools/build/envDefaults
-ssh $remote "rm -f $log; echo logfile flush 1 > ~/.screenrc"
- (
- $mininet ./invoke_trellis_p4
- scp $remote_scp:$log /tmp/mininet.log
- ssh $remote rm -f $log
- ) &
+remote="$ONOS_USER@$OCN"
+log="screenlog.0"
+trellisp4Sh="/tmp/start_trellisp4.sh"
+stratumRoot="/home/sdn/stratum"
+
+ssh -tt ${remote} "
+ rm -f $log && echo logfile flush 1 > ~/.screenrc && \
+ echo \"cd ~/routing/trellis && \
+ sudo -E env PYTHONPATH=/tmp/bmv2_py STRATUM_ROOT=${stratumRoot} \
+ ONOS_WEB_USER=$ONOS_WEB_USER ONOS_WEB_PASS=$ONOS_WEB_PASS \
+ python trellisp4.py --onos-ip $OC1 --agent stratum\" \
+ > ${trellisp4Sh} && chmod +x ${trellisp4Sh}
+"
+
+(
+ ssh -t -t ${remote} "screen -L -S mininet sudo ${trellisp4Sh}"
+ scp ${ONOS_USER}@[${OCN}]:$log /tmp/mininet.log
+ ssh ${remote} rm -f $log
+) &
diff --git a/tools/test/scenarios/net-setup-trellis-p4.xml b/tools/test/scenarios/net-setup-trellis-p4.xml
index fae54f8..0818668 100644
--- a/tools/test/scenarios/net-setup-trellis-p4.xml
+++ b/tools/test/scenarios/net-setup-trellis-p4.xml
@@ -18,7 +18,7 @@
<group name="Trellis-Net-P4-Setup">
<step name="Trellis-Net-P4-Setup.Push-Routing" exec="onos-push-routing ${OCN}"/>
- <step name="Trellis-Net-P4-Setup.Push-Bmv2" exec="onos-push-bmv2 ${OCN}"/>
+ <step name="Trellis-Net-P4-Setup.Push-Bmv2" exec="onos-push-bmv2-py ${OCN}"/>
<!-- Stop/cleanup mininet -->
<step name="Trellis-Net-P4-Setup.Stop-Mininet-If-Needed" env="~" exec="onos-mininet stop"/>