From aa07bdfbaab8af8518196762099c63823a22a3c4 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Thu, 6 Sep 2018 10:28:26 -0700 Subject: [PATCH] Optionally suppress delete confirmation --- net/gce.sh | 10 +++++++--- scripts/gcloud.sh | 11 +++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/net/gce.sh b/net/gce.sh index 06157f19c..af307a75c 100755 --- a/net/gce.sh +++ b/net/gce.sh @@ -20,6 +20,7 @@ imageName="ubuntu-16-04-cuda-9-2-new" publicNetwork=false zone="us-west1-b" leaderAddress= +yes=false usage() { exitcode=0 @@ -53,7 +54,7 @@ Configure a GCE-based testnet none delete-specific options: - none + -y - Skip delete confirmation, assume yes EOF exit $exitcode @@ -65,7 +66,7 @@ command=$1 shift [[ $command = create || $command = config || $command = delete ]] || usage "Invalid command: $command" -while getopts "h?p:Pi:n:c:z:ga:" opt; do +while getopts "h?p:Pi:n:c:z:ga:y" opt; do case $opt in h | \?) usage @@ -80,6 +81,9 @@ while getopts "h?p:Pi:n:c:z:ga:" opt; do i) imageName=$OPTARG ;; + y) + yes=true + ;; n) validatorNodeCount=$OPTARG ;; @@ -180,7 +184,7 @@ delete) echo "No instances found matching '^$prefix-'" exit 0 fi - gcloud_DeleteInstances + gcloud_DeleteInstances "$yes" rm -f "$configFile" ;; diff --git a/scripts/gcloud.sh b/scripts/gcloud.sh index 571ed2ede..b452108ee 100644 --- a/scripts/gcloud.sh +++ b/scripts/gcloud.sh @@ -149,11 +149,18 @@ gcloud_CreateInstances() { } # -# gcloud_DeleteInstances +# gcloud_DeleteInstances [yes] # # Deletes all the instances listed in the `instances` array # +# If yes = "true", skip the delete confirmation +# gcloud_DeleteInstances() { + declare maybeQuiet= + if [[ $1 = true ]]; then + maybeQuiet=--quiet + fi + if [[ ${#instances[0]} -eq 0 ]]; then echo No instances to delete return @@ -167,7 +174,7 @@ gcloud_DeleteInstances() { ( set -x - gcloud beta compute instances delete --zone "$zone" "${names[@]}" + gcloud beta compute instances delete --zone "$zone" $maybeQuiet "${names[@]}" ) }