Make test tools available in installed ONOS
Part of ONOS-6597
onos-app, onos-netcfg
Change-Id: Ic58156700e357c9564e9bd9fe1173310ec6f0502
diff --git a/tools/package/runtime/bin/_find-node b/tools/package/runtime/bin/_find-node
new file mode 100644
index 0000000..51f6364
--- /dev/null
+++ b/tools/package/runtime/bin/_find-node
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+
+#
+# Copyright 2015-present Open Networking Laboratory
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# -----------------------------------------------------------------------------
+# Utility for converting a number of a node in a cell to the node's address
+# -----------------------------------------------------------------------------
+
+validate_number () {
+ local re="^[0-9]+$"
+ if [[ ! $1 =~ $re ]] ; then
+ return 1
+ fi
+
+ return 0
+}
+
+find_node () {
+ if validate_number $1 ; then
+ # input is a number, try to find if an OC node is defined
+
+ oc_try="OC$1"
+ node=${!oc_try}
+
+ if [ -n "$node" ]; then
+ # node lookup succeeded, return node
+ echo $node
+ else
+ # node lookup failed, return original input
+ echo $1
+ fi
+
+ else
+ echo $1
+ fi
+
+ return 0
+}