blob: 780a90dcc05b26cd841937b27d7ad6b84d171db5 [file] [log] [blame]
tomac77d762014-09-18 19:59:42 -07001#!/bin/bash
Pavlin Radoslavov91413792014-10-15 11:00:32 -07002# -----------------------------------------------------------------------------
tom1a2908c2014-09-23 16:37:39 -07003# ONOS remote command-line client.
Pavlin Radoslavov91413792014-10-15 11:00:32 -07004# -----------------------------------------------------------------------------
tomac77d762014-09-18 19:59:42 -07005
Ayaka Koshibef17f34a2015-09-24 19:31:48 -07006function _usage () {
7cat << _EOF_
8usage:
9 $(basename $0) [-w] [node]
10
11flags:
12- -w : Waits for ONOS instance to reach run-level 100, i.e. to be fully started.
13
14options:
15- [node] : the node to attach to
16
17summary:
18 ONOS remote command-line client.
19
20 The -w flag depends on 'onos-wait-for-start'. If [node] is unspecified, \$OCI
21 is used.
22
23_EOF_
24}
25[ "$1" = "-h" ] && _usage && exit 0
26
Pavlin Radoslavov4b154072014-10-15 10:49:23 -070027[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
28. $ONOS_ROOT/tools/build/envDefaults
Jonathan Hart518e5e72014-10-31 15:28:35 -070029. $ONOS_ROOT/tools/test/bin/find-node.sh
Pavlin Radoslavov4b154072014-10-15 10:49:23 -070030
toma6bc21b2014-09-30 09:39:02 -070031[ "$1" = "-w" ] && shift && onos-wait-for-start $1
32
Jonathan Hart518e5e72014-10-31 15:28:35 -070033[ -n "$1" ] && OCI=$(find_node $1) && shift
Thomas Vachuska12bf4452015-06-26 09:15:38 -070034
Thomas Vachuska3c831fa2015-08-17 18:44:15 -070035if which client 1>/dev/null 2>&1 && [ -z "$ONOS_USE_SSH" ]; then
Thomas Vachuska12bf4452015-06-26 09:15:38 -070036 # Use Karaf client only if we can and are allowed to
37 unset KARAF_HOME
38 client -h $OCI -u karaf "$@" 2>/dev/null
39else
40 # Otherwise use raw ssh; strict checking is off for dev environments only
41 ssh -p 8101 -o StrictHostKeyChecking=no $OCI "$@"
42fi