Making REST API port as a command-line option for various admin commands.

Also cleaning up usage for consistency.

Change-Id: I1d8a10c063cab5992033b97d6efa60bba030ed9e
diff --git a/tools/package/bin/onos-form-cluster b/tools/package/bin/onos-form-cluster
index e677873..4e3645c 100755
--- a/tools/package/bin/onos-form-cluster
+++ b/tools/package/bin/onos-form-cluster
@@ -1,24 +1,47 @@
 #!/bin/bash
+
+#
+# Copyright 2015-present Open Networking Foundation
+#
+# 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.
+#
+
 # -----------------------------------------------------------------------------
 # Forms ONOS cluster using REST API of each separate instance.
 # -----------------------------------------------------------------------------
 function usage() {
-    echo "usage: $(basename $0)[-x] [-u user] [-p password] [-s partitionSize] ip1 ip2..." && exit 1
+    echo "usage: $(basename $0)[-x] [-P port] [-u user] [-p password] [-s partitionSize] ip1 ip2..." && exit 1
 }
 
+ONOS_WEB_USER=${ONOS_WEB_USER:-onos}  # ONOS WEB User defaults to 'onos'
+ONOS_WEB_PASS=${ONOS_WEB_PASS:-rocks} # ONOS WEB Password defaults to 'rocks'
+ONOS_WEB_PORT=${ONOS_WEB_PORT:-8181}  # REST API port defaults to '8181'
+
+port=${ONOS_WEB_PORT}
+user=${ONOS_WEB_USER}
+password=${ONOS_WEB_PASS}
+
 # Scan arguments for user/password or other options...
-while getopts u:p:s: o; do
+while getopts P:u:p:s: o; do
     case "$o" in
+        P) port=$OPTARG;;
         u) user=$OPTARG;;
         p) password=$OPTARG;;
         s) partitionsize=$OPTARG;;
         *) usage;;
     esac
 done
-ONOS_WEB_USER=${ONOS_WEB_USER:-onos} # ONOS WEB User defaults to 'onos'
-ONOS_WEB_PASS=${ONOS_WEB_PASS:-rocks} # ONOS WEB Password defaults to 'rocks'
-user=${user:-$ONOS_WEB_USER}
-password=${password:-$ONOS_WEB_PASS}
+
 let OPC=$OPTIND-1
 shift $OPC
 
@@ -45,6 +68,6 @@
 
 for node in $ip $nodes; do
     echo "Forming cluster on $node..."
-    curl --user $user:$password -X POST \
-        http://$node:8181/onos/v1/cluster/configuration -d @$aux
+    curl --fail -sSL --user $user:$password -X POST \
+        http://$node:$port/onos/v1/cluster/configuration -d @$aux
 done