To perform a power action (except for reset) on a VM using the API:
Send a PUT request to the VM state link
The VM state link is a link in the VM object with the "rel" attribute set to state. The "title" attribute contains the current state. You can send a PUT request of a virtualmachine state object to the link (in the "href" attribute) to change the state of the VM.
{ "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/2/virtualmachines/6/state", "type": "application/vnd.abiquo.virtualmachinestate+json", "rel": "state", "title": "ON" }, |
Hard power off
{"state": "OFF"} |
Graceful shutdown
{"state": "OFF", "gracefulShutdown": true} |
Power on
{"state": "ON"} |
Pause
{"state": "PAUSED"} |
Azure has two power off states - powered off and deallocated.
The API will return a link where you can monitor the progress of this operation.
To perform a graceful shutdown, your VM will need to have guest extensions installed on it. After an operation completes, you can view the status of the task by going to the link in the accepted request link of the response. In this case, the graceful shutdown was not supported and failed.
|
To reset a VM using the API, use a POST request to the reset action link.
cURL:
Success status code: 202 Request payload: --none-- Response payload:
|