0

How can I check (inside Java code) if a VM instance on google compute engine is running or not? Thank you in advance.

Nane Petrosyan
  • 553
  • 1
  • 7
  • 19

1 Answers1

2

You can use this method get and then check status in the response.

NOTE The documentation page includes a way to "Try this API". If you have an existing project containing a VM instance, you can populate the form for your project and instance to see how it works.

See this example:

https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/compute/cmdline/src/main/java/ComputeEngineSample.java

Although it doesn't use instances.get, it does use instances.[insert|list|delete] and it should give you a good template.

DazWilkin
  • 32,823
  • 5
  • 47
  • 88