blob: 50e87e10d59243b639c64bd2a31d1e551297fc6b [file] [log] [blame]
Carmelo Casconef11513d2018-01-16 00:31:14 -08001#!/usr/bin/env bash
2
3BUILD_DIR=~/p4tools
4
5export BMV2_PATH=${BUILD_DIR}/bmv2
6export P4RUNTIME_PATH=${BUILD_DIR}/p4runtime
7
8bm-cli () {
9 if [ -z "$1" ]; then
Carmelo Casconeb4e61e92018-05-14 18:15:33 -070010 echo "No argument supplied. Usage: bm-cli <MININET SWITCH NAME>"
Carmelo Casconef11513d2018-01-16 00:31:14 -080011 return
12 fi
13 tport=$(head -n 1 /tmp/bmv2-$1-thrift-port)
14 echo "Starting CLI for BMv2 instance $1 (Thrift port $tport)..."
15 sudo ${BMV2_PATH}/tools/runtime_CLI.py --thrift-port ${tport} ${@:2}
16}
17
18bm-dbg () {
19 if [ -z "$1" ]; then
Carmelo Casconeb4e61e92018-05-14 18:15:33 -070020 echo "No argument supplied. Usage: bm-dbg <MININET SWITCH NAME>"
Carmelo Casconef11513d2018-01-16 00:31:14 -080021 return
22 fi
23 tport=$(head -n 1 /tmp/bmv2-$1-thrift-port)
24 echo "Starting debugger for BMv2 instance $1 (Thrift port $tport)..."
Carmelo Casconeb4e61e92018-05-14 18:15:33 -070025 sudo bm_p4dbg --thrift-port ${tport} --socket ipc:///tmp/bmv2-$1-debug.ipc ${@:2}
Carmelo Casconef11513d2018-01-16 00:31:14 -080026}
27
28bm-nmsg () {
29 if [ -z "$1" ]; then
Carmelo Casconeb4e61e92018-05-14 18:15:33 -070030 echo "No argument supplied. Usage: bm-nmsg <MININET SWITCH NAME>"
Carmelo Casconef11513d2018-01-16 00:31:14 -080031 return
32 fi
33 tport=$(head -n 1 /tmp/bmv2-$1-thrift-port)
34 echo "Starting nanomsg event listener for BMv2 instance $1 (Thrift port $tport)..."
35 sudo ${BMV2_PATH}/tools/nanomsg_client.py --thrift-port ${tport} ${@:2}
36}
37
38bm-log () {
39 if [ -z "$1" ]; then
Carmelo Casconeb4e61e92018-05-14 18:15:33 -070040 echo "No argument supplied. Usage: bm-log <MININET SWITCH NAME>"
Carmelo Casconef11513d2018-01-16 00:31:14 -080041 return
42 fi
43 echo "Showing log for BMv2 instance $1..."
44 echo "---"
45 tail -f /tmp/bmv2-$1-log
46}
47
48bm-sysrepo-reset () {
49 echo "Resetting sysrepo data store..."
50 sudo rm -rf /etc/sysrepo/data/*
51 sudo ${P4RUNTIME_PATH}/proto/sysrepo/install_yangs.sh
52}