Nane Petrosyan
Nane Petrosyan

Reputation: 613

Check Google compute VM instance state

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

Upvotes: 0

Views: 164

Answers (1)

DazWilkin
DazWilkin

Reputation: 40061

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.

Upvotes: 2

Related Questions