blob: ee96f2257560bda9e898ce5c19cccb7536adc593 [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
10 echo "No argument supplied. Usage: bm-cli <BMV2 DEVICE ID>"
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
18bm-dbg () {
19 if [ -z "$1" ]; then
20 echo "No argument supplied. Usage: bm-dbg <BMV2 DEVICE ID>"
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)..."
25 sudo ${BMV2_PATH}/tools/p4dbg.py --thrift-port ${tport} ${@:2}
26}
27
28bm-nmsg () {
29 if [ -z "$1" ]; then
30 echo "No argument supplied. Usage: bm-nmsg <BMV2 DEVICE ID>"
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
38bm-log () {
39 if [ -z "$1" ]; then
40 echo "No argument supplied. Usage: bm-log <BMV2 DEVICE ID>"
41 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}