Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Create a VM with the UI and the API

  2. Get a VM and deploy it

  3. Get a group of VMs with the API

...

Requirements

You will need to be familiar with your browser tools. We used Google Chrome.

...

  1. Log in to Abiquo and open your browser console to the Network tab

  2. Record browser actions

  3. Create a VM in the UI. The UI will send a POST request to the API

  4. In the browser console, find the POST request

    1. Tips when using Chrome:

      1. To display the Method column to easily identify the POST request, right-click on the header row to display the header options list, then select Method.

      2. To copy the request directly from the UI, right-click on the request URL and select Copy as cURL and delete UI cache details from the URL before you run it

  5. From Headers, Response Headers find the location. This is the VM link where you will send requests to modify the VM 

  6. From the Payload, click view source, and right-click and copy, then format with a JSON formatter. This is the VM object that you can modify and use in the next request to create a VM

Screenshot from Chrome: the POST request to create a VM is selected.

...

Screenshot from Chrome - the POST request to create a VM is selected.Image Added





Analyze the post request

...

To manage the VM, you will send requests to VM links, so you should now save some links from the VM object. It is also useful to know the ID of the VM in the API.

From the VM object,:

  • Get the link with a rel key that has a value of edit. Also note that in the example the VM has an id of 305.

    Code Block
    ...
    {  
       "links":[
    ...
        {
          "title": "vmapihowto2",
          "rel": "edit",
          "type": "application/vnd.abiquo.virtualmachine+json",
          "href": "https://mjsabiquo.lab.abiquo.com:443/api/cloud/virtualdatacenters/12/virtualappliances/4/virtualmachines/305"
        },
    ...

  • Also get the link with a rel key that has a value of deploy.

    Code Block
    ...
        {
          "title": "virtual machine deploy",
          "rel": "deploy",
          "type": "application/vnd.abiquo.acceptedrequest+json",
          "href": "https://mjsabiquo.lab.abiquo.com:443/api/cloud/virtualdatacenters/12/virtualappliances/4/virtualmachines/305/action/deploy"
        },
    ...


...