0
votes

I am running a VM instance on a google cloud compute project.

I would like to fetch information about the instance in a text file so that I can pass it to another developer and he will be able to spin off similar instance on his own google cloud compute project.

In other words, the information I'm looking for includes (among others): the type operating system selected for the instance, the number of GPUs and their type, instance's zone, disk size, disk type (SSD or other), number of CPUs etc...

I'm using gcloud SDK to start or stop the instance. I tried to run gcloud compute instances describe, but the information that I retrieve this way does not include all the information I'm looking for.


There is question with somewhat similar title but the OP of that question is looking for a different info.

Thanks!

1

1 Answers

0
votes

I do have a bash script that you may be useful for your. The scrip[t look on the instance details using the gcloud command and create a file with the name {all-details.txt} including the information that you are looking for.

the only thing is that you need to provide the instance name and the zone since mandatory field for gcloud command:

#!/bin/bash
echo " instance name :$1 "
echo " zone:$2"
sudo gcloud compute instances describe $1 --zone $2 | grep -E 'cpuPlatfor|machineType|guestAccelerators|accelera
torCount|acceleratorType|disks|type' > details1.txt \
&& sudo gcloud compute disks describe $1 --zone $2 | grep -E 'licenses|sourceImage|sizeGb'  > details2.txt \
&& cat details1.txt details2.txt > all-details.txt \
&& rm details1.txt details2.txt

Then you have just to run the bash with the 2 argument like : sudo bash script.sh