当前位置: 动力学知识库 > 问答 > 编程问答 >

cloud - gcloud compute command to know current zone of machine

问题描述:

I need help in google cloud , I am doing 1 application using google cloud. in google cloud I have 1 instance of windows and google cloud sdk on that. I need one command which will return zone name of that instance.

Note -

I don't need zone list.

I need only that zone name where my instance is running.

thank you in advance.

网友答案:

tl;dr:

gcloud compute instances list <your instance name> --format 'csv[no-heading](zone)'

. . .

This is doing two things. The

gcloud compute instances list your-instance-name

part lists all instances with that name, e.g.

NAME                ZONE           MACHINE_TYPE  PREEMPTIBLE INTERNAL_IP    EXTERNAL_IP    STATUS
your-instance-name  europe-west1-c n1-standard-1             1.000.000.001 100.000.000.01 RUNNING

And the

--format 'csv[no-heading](zone)'  

part reformats the output to be a table with with headers and only the zone column. See https://cloud.google.com/sdk/gcloud/reference/topic/formats (or gcloud help topic formats) for more information about formatting output.

分享给朋友:
您可能感兴趣的文章:
随机阅读: