Pavlin Radoslavov

Minor refactoring in the ONOS cell configuration:

 * Each cell-specific variable is explicitly listed
   in the cell config file:
   ONOS_CELL, ONOS_NIC, OC1-OC9, OCN, OCI, ONOS_FEATURES

 * Cleanup and bug fixes inside bash_profile:
   - Don't export explicitly OCI and ONOS_CELL, because those
     are now exported in the cell config file
   - unset ONOS_CELL, ONOS_NIC, ONOS_FEATURES (the last two weren't
     unset before)
   - The built-in "cell" function shows OC1 to OC9 instead of OC0-OC9;
     OC0 is never used/setup anywhere else

 * Added two new shell commands:
   - tools/test/bin/onos-lsit-cells : lists existing ONOS cell configurations
     It is the equivalent of the "cells" built-in bash command
   - tools/test/bin/onos-show-cell : shows the configuration of an ONOS cell
     It is the equivalent of the "cell" built-in bash command, but
     it can show also the configuration of any ONOS cell (not only
     the default one).
...@@ -61,15 +61,14 @@ function cell { ...@@ -61,15 +61,14 @@ function cell {
61 if [ -n "$1" ]; then 61 if [ -n "$1" ]; then
62 [ ! -f $ONOS_ROOT/tools/test/cells/$1 ] && \ 62 [ ! -f $ONOS_ROOT/tools/test/cells/$1 ] && \
63 echo "No such cell: $1" >&2 && return 1 63 echo "No such cell: $1" >&2 && return 1
64 + unset ONOS_CELL ONOS_NIC ONOS_FEATURES
64 unset OC1 OC2 OC3 OC4 OC5 OC6 OC7 OC8 OC9 OCN OCI 65 unset OC1 OC2 OC3 OC4 OC5 OC6 OC7 OC8 OC9 OCN OCI
65 . $ONOS_ROOT/tools/test/cells/$1 66 . $ONOS_ROOT/tools/test/cells/$1
66 - export OCI=$OC1
67 - export ONOS_CELL=$1
68 cell 67 cell
69 else 68 else
70 env | egrep "ONOS_CELL" 69 env | egrep "ONOS_CELL"
71 env | egrep "OCI" 70 env | egrep "OCI"
72 - env | egrep "OC[0-9]+" | sort 71 + env | egrep "OC[1-9]+" | sort
73 env | egrep "OCN" 72 env | egrep "OCN"
74 env | egrep "ONOS_" | egrep -v 'ONOS_ROOT|ONOS_CELL' 73 env | egrep "ONOS_" | egrep -v 'ONOS_ROOT|ONOS_CELL'
75 fi 74 fi
......
1 +#!/bin/bash
2 +# -----------------------------------------------------------------------------
3 +# List available ONOS cells configuration.
4 +# -----------------------------------------------------------------------------
5 +
6 +[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7 +. $ONOS_ROOT/tools/build/envDefaults
8 +
9 +# Lists available cells
10 +for cell in $(ls -1 $ONOS_ROOT/tools/test/cells); do
11 + if [ ${cell} = "${ONOS_CELL}" ]; then
12 + cell_id="${cell} *"
13 + else
14 + cell_id="${cell}"
15 + fi
16 + cell_descr="$(grep '^#' $ONOS_ROOT/tools/test/cells/$cell | head -n 1)"
17 + printf "%-12s %s\n" "${cell_id}" "${cell_descr}"
18 +done
1 +#!/bin/bash
2 +# -----------------------------------------------------------------------------
3 +# Print the configuration of an ONOS cell.
4 +# -----------------------------------------------------------------------------
5 +
6 +[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7 +. $ONOS_ROOT/tools/build/envDefaults
8 +
9 +function print_usage {
10 + echo "Print the configuration of an ONOS cell."
11 + echo "If no arguments are specified, it will print the configuration for the default"
12 + echo "ONOS cell as specified in the 'ONOS_CELL' environmental variable."
13 + echo
14 + echo "Optional arguments:"
15 + echo " [cell-name] Print the configuration of 'cell-name'"
16 + echo " [-h | --help] Print this help"
17 +}
18 +
19 +if [ "${1}" = "-h" -o "${1}" = "--help" ]; then
20 + print_usage
21 + exit 0
22 +fi
23 +
24 +if [ -n "${1}" ]; then
25 + cell="${1}"
26 +else
27 + if [ -z "${ONOS_CELL}" ]; then
28 + echo "Environmental variable 'ONOS_CELL' is not defiled"
29 + exit 1
30 + else
31 + cell="${ONOS_CELL}"
32 + fi
33 +fi
34 +
35 +if [ ! -f $ONOS_ROOT/tools/test/cells/${cell} ]; then
36 + echo "No such cell: ${cell}"
37 + exit 1
38 +fi
39 +
40 +# Load the cell setup
41 +. $ONOS_ROOT/tools/test/cells/${cell}
42 +
43 +echo "ONOS_CELL=${ONOS_CELL}"
44 +echo "ONOS_NIC=${ONOS_NIC}"
45 +for n in {0..9}; do
46 + ocn="OC${n}"
47 + if [ -n "${!ocn}" ]; then
48 + echo "$ocn=${!ocn}"
49 + fi
50 +done
51 +echo "OCN=${OCN}"
52 +echo "OCI=${OCI}"
53 +echo "ONOS_FEATURES=${ONOS_FEATURES}"
1 # Local VirtualBox-based single ONOS instance & ONOS mininet box 1 # Local VirtualBox-based single ONOS instance & ONOS mininet box
2 2
3 +export ONOS_CELL="cbench"
4 +
3 export ONOS_NIC=192.168.56.* 5 export ONOS_NIC=192.168.56.*
4 export OC1="192.168.56.103" 6 export OC1="192.168.56.103"
5 export OCN="192.168.56.103" 7 export OCN="192.168.56.103"
8 +export OCI="${OC1}"
6 9
7 export ONOS_FEATURES="webconsole,onos-api,onos-core-trivial,onos-cli,onos-openflow,onos-app-fwd" 10 export ONOS_FEATURES="webconsole,onos-api,onos-core-trivial,onos-cli,onos-openflow,onos-app-fwd"
......
1 # Local VirtualBox-based ONOS instances 1,2 & ONOS mininet box 1 # Local VirtualBox-based ONOS instances 1,2 & ONOS mininet box
2 2
3 +export ONOS_CELL="local"
4 +
3 export ONOS_NIC=192.168.56.* 5 export ONOS_NIC=192.168.56.*
4 export OC1="192.168.56.101" 6 export OC1="192.168.56.101"
5 export OC2="192.168.56.102" 7 export OC2="192.168.56.102"
6 -
7 export OCN="192.168.56.103" 8 export OCN="192.168.56.103"
9 +export OCI="${OC1}"
10 +
11 +export ONOS_FEATURES=""
......
1 # ProxMox-based cell of ONOS instance; no mininet-box 1 # ProxMox-based cell of ONOS instance; no mininet-box
2 2
3 -export ONOS_FEATURES="webconsole,onos-api,onos-core-trivial,onos-cli,onos-openflow,onos-app-fwd,onos-app-mobility,onos-app-tvue,onos-app-proxyarp" 3 +export ONOS_CELL="office"
4 4
5 export ONOS_NIC="10.128.4.*" 5 export ONOS_NIC="10.128.4.*"
6 export OC1="10.128.4.60" 6 export OC1="10.128.4.60"
7 +export OCI="${OC1}"
8 +
9 +export ONOS_FEATURES="webconsole,onos-api,onos-core-trivial,onos-cli,onos-openflow,onos-app-fwd,onos-app-mobility,onos-app-tvue,onos-app-proxyarp"
......
1 # ProxMox-based cell of ONOS instances 1,2 & ONOS mininet box 1 # ProxMox-based cell of ONOS instances 1,2 & ONOS mininet box
2 2
3 +export ONOS_CELL="prox"
4 +
3 export ONOS_NIC="10.1.9.*" 5 export ONOS_NIC="10.1.9.*"
4 export OC1="10.1.9.94" 6 export OC1="10.1.9.94"
5 export OC2="10.1.9.82" 7 export OC2="10.1.9.82"
6 -
7 export OCN="10.1.9.93" 8 export OCN="10.1.9.93"
9 +export OCI="${OC1}"
10 +
11 +export ONOS_FEATURES=""
......
1 # Local VirtualBox-based single ONOS instance & ONOS mininet box 1 # Local VirtualBox-based single ONOS instance & ONOS mininet box
2 2
3 +export ONOS_CELL="single"
4 +
3 export ONOS_NIC=192.168.56.* 5 export ONOS_NIC=192.168.56.*
4 export OC1="192.168.56.101" 6 export OC1="192.168.56.101"
5 export OCN="192.168.56.103" 7 export OCN="192.168.56.103"
8 +export OCI="${OC1}"
9 +
10 +export ONOS_FEATURES=""
......
1 # Local VirtualBox-based ONOS instances 1,2,3 & ONOS mininet box 1 # Local VirtualBox-based ONOS instances 1,2,3 & ONOS mininet box
2 2
3 +export ONOS_CELL="triple"
4 +
3 export ONOS_NIC=192.168.56.* 5 export ONOS_NIC=192.168.56.*
4 export OC1="192.168.56.101" 6 export OC1="192.168.56.101"
5 export OC2="192.168.56.102" 7 export OC2="192.168.56.102"
6 export OC3="192.168.56.104" 8 export OC3="192.168.56.104"
7 -
8 export OCN="192.168.56.103" 9 export OCN="192.168.56.103"
10 +export OCI="${OC1}"
11 +
12 +export ONOS_FEATURES=""
......