Private IP networks now work, and are the default

This commit is contained in:
Michael Vines
2018-09-04 22:21:58 -07:00
parent db9219ccc8
commit e677cda027
6 changed files with 78 additions and 61 deletions

View File

@ -17,7 +17,7 @@ clientMachineType=n1-standard-16
clientAccelerator=
imageName="ubuntu-16-04-cuda-9-2-new"
internalNetwork=false
publicNetwork=false
zone="us-west1-b"
usage() {
@ -42,7 +42,7 @@ Configure a GCE-based testnet
create-specific options:
-n number - Number of validator nodes (default: $validatorNodeCount)
-c number - Number of client nodes (default: $clientNodeCount)
-P - Use GCE internal/private network (default: $internalNetwork)
-P - Use public network IP addresses (default: $publicNetwork)
-z - GCP Zone for the nodes (default: $zone)
-i imageName - Existing image on GCE (default: $imageName)
-g - Enable GPU
@ -72,7 +72,7 @@ while getopts "h?p:Pi:n:c:z:g" opt; do
prefix=$OPTARG
;;
P)
internalNetwork=true
publicNetwork=true
;;
i)
imageName=$OPTARG
@ -97,9 +97,12 @@ done
prepareInstancesAndWriteConfigFile() {
echo "# autogenerated at $(date)" >> "$configFile"
echo "netBasename=$prefix" >> "$configFile"
cat >> "$configFile" <<EOF
# autogenerated at $(date)
netBasename=$prefix
publicNetwork=$publicNetwork
EOF
declare sshPrivateKey="$netConfigDir/id_$prefix"
rm -rf "$sshPrivateKey"{,.pub}
@ -116,10 +119,13 @@ prepareInstancesAndWriteConfigFile() {
declare arrayName="$6"
if $internalNetwork; then
echo "$arrayName+=($privateIp) # $name" >> "$configFile"
else
echo "$arrayName+=($publicIp) # $name" >> "$configFile"
echo "$arrayName+=($publicIp) # $name" >> "$configFile"
if [[ $arrayName = "leaderIp" ]]; then
if $publicNetwork; then
echo "entrypointIp=$publicIp" >> "$configFile"
else
echo "entrypointIp=$privateIp" >> "$configFile"
fi
fi
}