Carmelo Cascone | f11513d | 2018-01-16 00:31:14 -0800 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | BUILD_DIR=~/p4tools |
| 4 | |
| 5 | export BMV2_PATH=${BUILD_DIR}/bmv2 |
| 6 | export P4RUNTIME_PATH=${BUILD_DIR}/p4runtime |
| 7 | |
| 8 | bm-cli () { |
| 9 | if [ -z "$1" ]; then |
Carmelo Cascone | b4e61e9 | 2018-05-14 18:15:33 -0700 | [diff] [blame] | 10 | echo "No argument supplied. Usage: bm-cli <MININET SWITCH NAME>" |
Carmelo Cascone | f11513d | 2018-01-16 00:31:14 -0800 | [diff] [blame] | 11 | 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 | |
| 18 | bm-dbg () { |
| 19 | if [ -z "$1" ]; then |
Carmelo Cascone | b4e61e9 | 2018-05-14 18:15:33 -0700 | [diff] [blame] | 20 | echo "No argument supplied. Usage: bm-dbg <MININET SWITCH NAME>" |
Carmelo Cascone | f11513d | 2018-01-16 00:31:14 -0800 | [diff] [blame] | 21 | 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 Cascone | b4e61e9 | 2018-05-14 18:15:33 -0700 | [diff] [blame] | 25 | sudo bm_p4dbg --thrift-port ${tport} --socket ipc:///tmp/bmv2-$1-debug.ipc ${@:2} |
Carmelo Cascone | f11513d | 2018-01-16 00:31:14 -0800 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | bm-nmsg () { |
| 29 | if [ -z "$1" ]; then |
Carmelo Cascone | b4e61e9 | 2018-05-14 18:15:33 -0700 | [diff] [blame] | 30 | echo "No argument supplied. Usage: bm-nmsg <MININET SWITCH NAME>" |
Carmelo Cascone | f11513d | 2018-01-16 00:31:14 -0800 | [diff] [blame] | 31 | 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 | |
| 38 | bm-log () { |
| 39 | if [ -z "$1" ]; then |
Carmelo Cascone | b4e61e9 | 2018-05-14 18:15:33 -0700 | [diff] [blame] | 40 | echo "No argument supplied. Usage: bm-log <MININET SWITCH NAME>" |
Carmelo Cascone | f11513d | 2018-01-16 00:31:14 -0800 | [diff] [blame] | 41 | return |
| 42 | fi |
| 43 | echo "Showing log for BMv2 instance $1..." |
| 44 | echo "---" |
| 45 | tail -f /tmp/bmv2-$1-log |
| 46 | } |
| 47 | |
| 48 | bm-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 | } |