Created
November 13, 2023 14:53
-
-
Save MiniXC/75d1697be455b5f3a9a10e5797ca97f0 to your computer and use it in GitHub Desktop.
update_tpus.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if ! test -f /etc/hosts.bak; then | |
sudo cp /etc/hosts /etc/hosts.bak | |
fi | |
sudo cp /etc/hosts.bak /etc/hosts | |
YAML_INFO=" | |
`gcloud compute tpus tpu-vm list --zone=us-central1-f --format=yaml` | |
`gcloud compute tpus tpu-vm list --zone=europe-west4-a --format=yaml` | |
" | |
NAMES=(`echo "$YAML_INFO" | yq eval ".name" | cut -d "/" -f6 | grep -v "\-\-\-"`) | |
EXTERNAL_IPS=(`echo "$YAML_INFO" | yq eval ".networkEndpoints[0].accessConfig.externalIp" | grep -v "\-\-\-"`) | |
for index in ${!NAMES[*]}; do | |
echo "${EXTERNAL_IPS[$index]} ${NAMES[$index]}" | sudo tee -a /etc/hosts | |
ssh-keygen -R ${NAMES[$index]} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment