Abiquo Documentation Cookies Policy

Our Documentation website uses cookies to improve your experience. Please visit our Cookie Policy page for more information about cookies and how we use them.


Documentation

Skip to end of metadata
Go to start of metadata

 

To manage the virtual machine using the API, first you need to retrieve the virtual machine and find the links for different actions. Remember to see VirtualMachineResource for full details of virtual machine operations using the Abiquo API.

Power on, power off, or pause a VM using the API

To perform a power action on a virtual machine using the API:
  1. Obtain the virtual machine object and its virtual machine state link
    1. See Retrieve a VM with the API
  2. Create a virtualmachinestate object
  3. Send a PUT request to the virtual machine state link

The virtual machine state link is a link in the virtual machine 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 virtual machine.

           {  
               "title":"PAUSED",
               "rel":"state",
               "type":"application/vnd.abiquo.virtualmachinestate+json",
               "href":"https://38testing.bcn.abiquo.com:443/api/cloud/virtualdatacenters/55/virtualappliances/200/virtualmachines/1763/state"
            },

Examples of virtualmachinestate objects

Hard power off

{"state": "OFF"}

Graceful shutdown

{state: "OFF", gracefulShutdown: true}

Power on

{"state": "ON"}

Pause

{"state": "PAUSED"}

Example of VM hard power off via API

To hard power off a VM using the API, perform a request like the one shown below.

 Click here to show or hide the request example

Unable to render {include} The included page could not be found.

The API will return a link where you can monitor the progress of this operation.

Example of failed graceful shutdown

To perform a graceful shutdown, your virtual machine will need to have guest extensions installed on it. After an operation completes, you can view the status of the task by performing a get request on the accepted request link. In this case, the graceful shutdown was not supported and failed. 

 Click here to show or hide the request example
{
   "links":[
      {
         "rel":"self",
         "href":"https://38testing.bcn.abiquo.com:443/api/cloud/virtualdatacenters/55/virtualappliances/200/virtualmachines/1763/tasks/8812ddf4-a372-40af-81ee-5f5d1e53454c"
      },
      {
         "rel":"parent",
         "href":"https://38testing.bcn.abiquo.com:443/api/cloud/virtualdatacenters/55/virtualappliances/200/virtualmachines/1763/tasks"
      },
      {
         "rel":"acknowledge",
         "href":"https://38testing.bcn.abiquo.com:443/api/cloud/virtualdatacenters/55/virtualappliances/200/virtualmachines/1763/tasks/8812ddf4-a372-40af-81ee-5f5d1e53454c/action/ack"
      },
      {
         "title":"cloudadmin",
         "rel":"user",
         "type":"application/vnd.abiquo.user+json",
         "href":"https://38testing.bcn.abiquo.com:443/api/admin/enterprises/74/users/17"
      },
      {
         "title":"ABQ_5e57c34d-5dcb-482b-be0f-a78931f4abd0",
         "rel":"virtualmachine",
         "type":"application/vnd.abiquo.virtualmachine+json",
         "href":"https://38testing.bcn.abiquo.com:443/api/cloud/virtualdatacenters/55/virtualappliances/200/virtualmachines/1763"
      }
   ],
   "taskId":"8812ddf4-a372-40af-81ee-5f5d1e53454c",
   "userId":"17",
   "type":"SHUTDOWN",
   "ownerId":"1763",
   "state":"FINISHED_UNSUCCESSFULLY",
   "creationTimestamp":1458647896,
   "timestamp":1458647897,
   "jobs":{
      "links":[
      ],
      "collection":[
         {
            "links":[
            ],
            "id":"8812ddf4-a372-40af-81ee-5f5d1e53454c.191e44d9-74fa-453a-b7e0-596237618fcf",
            "parentTaskId":"8812ddf4-a372-40af-81ee-5f5d1e53454c",
            "type":"SHUTDOWN",
            "description":"Shutdown task's shutdown on virtual machine with id 1763",
            "state":"FAILED",
            "rollbackState":"ROLLBACK_DONE",
            "creationTimestamp":1458647896,
            "timestamp":1458647897
         }
      ]
   }
}

Reset a VM using the API

To reset a virtual machine using the API, use a POST request to the reset action link.

 Click here to expand...

API example removed: POST_cld_vdcs_X_vapps_X_vms_X_act_reset_AC_acrq_j
You can download the API examples archive from ABI38Confluence-space-export-152334-314.html.zip

  • No labels