Pavlin Radoslavov

Update the "onos-service" command:

 - add a mechanism to print the usage.
 - If the target is "--cell", the service command is executed on each
   node in the current ONOS cell.

Usage:     onos-service <TARGET> [COMMAND]
           onos-service [-h | --help]
Options:
    TARGET          The target of the command
    COMMAND         The command to execute. Default value is 'status'
    [-h | --help]   Print this help

TARGET:  <hostname | --cell>
      hostname        Execute on the specified host name
        --cell        Execute on the current ONOS cell

COMMAND: [start|stop|restart|status]
...@@ -6,4 +6,39 @@ ...@@ -6,4 +6,39 @@
6 [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 6 [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7 . $ONOS_ROOT/tools/build/envDefaults 7 . $ONOS_ROOT/tools/build/envDefaults
8 8
9 -ssh $ONOS_USER@${1:-$OCI} "sudo service onos ${2:-status}" 9 +function print_usage {
10 + command_name=`basename $0`
11 + echo "Remotely administer the ONOS service on a single node or the current ONOS cell."
12 + echo
13 + echo "Usage: $command_name <TARGET> [COMMAND]"
14 + echo " $command_name [-h | --help]"
15 + echo "Options:"
16 + echo " TARGET The target of the command"
17 + echo " COMMAND The command to execute. Default value is 'status'"
18 + echo " [-h | --help] Print this help"
19 + echo ""
20 + echo "TARGET: <hostname | --cell>"
21 + echo " hostname Execute on the specified host name"
22 + echo " --cell Execute on the current ONOS cell"
23 + echo ""
24 + echo "COMMAND: [start|stop|restart|status]"
25 + echo ""
26 +}
27 +
28 +# Print usage
29 +if [ "${1}" = "-h" -o "${1}" = "--help" ]; then
30 + print_usage
31 + exit 0
32 +fi
33 +
34 +# Select the target
35 +if [ "${1}" = "--cell" ]; then
36 + nodes=$(env | sort | egrep "OC[0-9]+" | cut -d= -f2)
37 +else
38 + nodes=${1:-$OCI}
39 +fi
40 +
41 +# Execute the remote commands
42 +for node in $nodes; do
43 + ssh $ONOS_USER@${node} "sudo service onos ${2:-status}"
44 +done
......