Use gcloud_DeleteInstances
This commit is contained in:
parent
d26f135159
commit
9d53208d68
|
@ -184,7 +184,7 @@ findVms() {
|
||||||
declare class="$1"
|
declare class="$1"
|
||||||
declare filter="$2"
|
declare filter="$2"
|
||||||
|
|
||||||
gcloud_FindInstances "$filter"
|
gcloud_FindInstances "$filter" show
|
||||||
vmlist+=("${instances[@]/#/$class:}")
|
vmlist+=("${instances[@]/#/$class:}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ delete_unreachable_validators() {
|
||||||
# Validators are managed by a Compute Engine Instance Group, so deleting
|
# Validators are managed by a Compute Engine Instance Group, so deleting
|
||||||
# one will just cause a new one to be spawned.
|
# one will just cause a new one to be spawned.
|
||||||
echo "Warning: $vmName is unreachable, deleting it"
|
echo "Warning: $vmName is unreachable, deleting it"
|
||||||
gcloud compute instances delete "$vmName" --zone "$vmZone"
|
gcloud_DeleteInstances "$vmName"
|
||||||
fi
|
fi
|
||||||
echo "validator checked in ${SECONDS} seconds"
|
echo "validator checked in ${SECONDS} seconds"
|
||||||
) >> "log-$vmName.txt" 2>&1 &
|
) >> "log-$vmName.txt" 2>&1 &
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
# "name:zone:public IP:private IP"
|
# "name:zone:public IP:private IP"
|
||||||
#
|
#
|
||||||
# filter - The instances to filter on
|
# filter - The instances to filter on
|
||||||
|
# options - If set to the string "show", the list of instances will be echoed
|
||||||
|
# to stdout
|
||||||
#
|
#
|
||||||
# examples:
|
# examples:
|
||||||
# $ gcloud_FindInstances "name=exact-machine-name"
|
# $ gcloud_FindInstances "name=exact-machine-name"
|
||||||
|
@ -21,14 +23,18 @@
|
||||||
#
|
#
|
||||||
gcloud_FindInstances() {
|
gcloud_FindInstances() {
|
||||||
declare filter="$1"
|
declare filter="$1"
|
||||||
#gcloud compute instances list --filter="$filter"
|
declare options="$2"
|
||||||
instances=()
|
instances=()
|
||||||
while read -r name zone publicIp privateIp status; do
|
while read -r name zone publicIp privateIp status; do
|
||||||
if [[ $status != RUNNING ]]; then
|
if [[ $status != RUNNING ]]; then
|
||||||
echo "Warning: $name is not RUNNING, ignoring it."
|
echo "Warning: $name is not RUNNING, ignoring it."
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
instances+=("$name:$zone:$publicIp:$privateIp")
|
if [[ $options = show ]]; then
|
||||||
|
printf "%-20s | zone=%-10s publicIp=%-16s privateIp=%s" "$name" "$zone" "$publicIp" "$privateIp"
|
||||||
|
fi
|
||||||
|
|
||||||
|
instances+=("$name:$zone:$publicIp:$privateIp")
|
||||||
done < <(gcloud compute instances list \
|
done < <(gcloud compute instances list \
|
||||||
--filter="$filter" \
|
--filter="$filter" \
|
||||||
--format 'value(name,zone,networkInterfaces[0].accessConfigs[0].natIP,networkInterfaces[0].networkIP,status)')
|
--format 'value(name,zone,networkInterfaces[0].accessConfigs[0].natIP,networkInterfaces[0].networkIP,status)')
|
||||||
|
|
Loading…
Reference in New Issue