Versions Compared

Key

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

...

  • The UI sent the POST request to the virtualmachines link of the virtual appliance. The link contains the IDs of the virtual datacenter and virtual appliance.

    Code Block
    https://mjsabiquoabiquo.lab.abiquoexample.com:443/api/cloud/virtualdatacenters/12/virtualappliances/4/virtualmachines

    • You can use this link to create another VM

    • In this case, the ID values are 12 and 4.

  • The Request Payload contains the basic VM object with a name and a link to a VM template, and an option to enable remote access to the VM.

    Code Block
    {
       "name":"vmapihowto",
       "links":[
          {
             "title":"yVM",
             "rel":"virtualmachinetemplate",
             "type":"application/vnd.abiquo.virtualmachinetemplate+json",
             "href":"https://mjsabiquoabiquo.lab.abiquoexample.com:443/api/admin/enterprises/1/datacenterrepositories/2/virtualmachinetemplates/145"
          }
       ],
       "vdrpEnabled":true
    }  


    • You can copy this object and modify it to create another VM

  • After the POST request is successful, the Location link, which you can obtain from the Request headers is the URL of the VM in the API.

    Code Block
     https://mjsabiquoabiquo.lab.abiquoexample.com:443/api/cloud/virtualdatacenters/12/virtualappliances/4/virtualmachines/304


    • You can use this link to manage the VM in the API

    • The last element of the URL is the ID of the VM, which has a value of 304.

...

  1. Create a POST request to the virtualmachines link

  2. Add headers to describe your JSON data objects 

    1. The Content-Type header refers to the VM object you are sending. 

    2. The Accept header refers to the API response you will receive

  3. Add your authentication (see the Authentication section above)

  4. As request data, you can add the VM entity from the previous step and change the name attribute, e.g., change  vmapihowto to vmapihowto2

  5. You can use a tool such as jq to format the API response

    Code Block
    curl -X POST 'https://mjsabiquoabiquo.lab.abiquoexample.com/api/cloud/virtualdatacenters/12/virtualappliances/4/virtualmachines' \
    -H 'Accept: application/vnd.abiquo.virtualmachine+json;version=6.1' \
    -H 'Authorization: Token XXXXXX' \
    -H 'Content-Type: application/vnd.abiquo.virtualmachine+json;version=6.1' \
    --data-raw '{"name":"vmapihowto2","links":[{"title":"yVM","rel":"virtualmachinetemplate","type":"application/vnd.abiquo.virtualmachinetemplate+json","href":"https://mjsabiquoabiquo.lab.abiquoexample.com:443/api/admin/enterprises/1/datacenterrepositories/2/virtualmachinetemplates/145"}],"vdrpEnabled":true}' \
    --insecure --verbose | jq .


  6. Send the POST request 

...

  • 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://mjsabiquoabiquo.lab.abiquoexample.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://mjsabiquoabiquo.lab.abiquoexample.com:443/api/cloud/virtualdatacenters/12/virtualappliances/4/virtualmachines/305/action/deploy"
        },
    ...


...

Code Block
curl --verbose 'https://mjsabiquoabiquo.lab.abiquoexample.com:443/api/cloud/virtualdatacenters/12/virtualappliances/4/virtualmachines/305' \
	-H 'Accept: application/vnd.abiquo.virtualmachine+json; version=6.1' \
	-u user:password -k | jq .

...

Code Block
√ ~ % curl --verbose 'https://mjsabiquoabiquo.lab.abiquoexample.com:443/api/cloud/virtualdatacenters/12/virtualappliances/4/virtualmachines/305' \ 
        -H 'Accept: application/vnd.abiquo.virtualmachine+json; version=6.1' \
        -u user:password -k | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:-- 
> GET /api/cloud/virtualdatacenters/12/virtualappliances/4/virtualmachines/305 HTTP/1.1
> Host: mjsabiquoabiquo.lab.abiquoexample.com
> Authorization: Basic XXXXXXXXX
> User-Agent: curl/7.82.0
> Accept: application/vnd.abiquo.virtualmachine+json; version=6.1
> 
{ [5 bytes data]
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 200
< Date: Tue, 06 Jun 2023 09:44:33 GMT
< Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips
< Set-Cookie: ABQSESSIONID=5894817455706476983; Max-Age=1800; Expires=Tue, 06-Jun-2023 10:14:33 GMT; Path=/; Secure; HttpOnly; SameSite=strict
< X-Abiquo-TracerContext: 7a0c3949-f905-4eea-a071-12b783ed180e
< X-Abiquo-Token: XXXXXXXXXXXX
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: 0
< Strict-Transport-Security: max-age=31536000 ; includeSubDomains
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: DENY
< X-Content-Type-Options: nosniff
< Content-Type: application/vnd.abiquo.virtualmachine+json; version=6.1
< Transfer-Encoding: chunked
< 
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0{ [5 bytes data]
100  9452    0  9452    0     0  14513      0 --:--:-- --:--:-- --:--:-- 14496
* Connection #0 to host mjsabiquoabiquo.lab.abiquoexample.com left intact
{
  "id": 305,
  "uuid": "eb613c22-ffa1-4498-827a-ccaf37385c2e",
  "description": "A virtual machine",
  "coresPerSocket": 1,
  "idState": 1,
  "idType": 0,
  "type": "MANAGED",
  "highDisponibility": 0,
  "monitored": false,
  "protected": false,
  "variables": {},
  "backuppolicies": [],
  "generateGuestInitialPassword": false,
  "natrules": [],
  "vdrpEnabled": true,
  "vdrpPort": 0,
  "password": "6t51rgZ9",
  "deallocated": false,
  "name": "vmapihowto2",
  "ram": 48,
  "cpu": 1,
  "state": "NOT_ALLOCATED",
  "creationTimestamp": 1686042455000,
  "birthTimestamp": 1686042455000,
  "links": [
    {
      "title": "Abiquo",
      "rel": "enterprise",
      "type": "application/vnd.abiquo.enterprise+json",
      "href": "https://mjsabiquoabiquo.lab.abiquoexample.com:443/api/admin/enterprises/1"
    },
    {
      "title": "vmapihowto2",
      "rel": "edit",
      "type": "application/vnd.abiquo.virtualmachine+json",
      "href": "https://mjsabiquoabiquo.lab.abiquoexample.com:443/api/cloud/virtualdatacenters/12/virtualappliances/4/virtualmachines/305"
    },
   ...
   {
      "title": "yVM",
      "rel": "virtualmachinetemplate",
      "type": "application/vnd.abiquo.virtualmachinetemplate+json",
      "href": "https://mjsabiquoabiquo.lab.abiquoexample.com:443/api/admin/enterprises/1/datacenterrepositories/2/virtualmachinetemplates/145"
    },
    {
      "title": "Others",
      "rel": "category",
      "type": "application/vnd.abiquo.category+json",
      "href": "https://mjsabiquoabiquo.lab.abiquoexample.com:443/api/config/categories/1"
    }
  ],
  "usageStatistics": []
}

...

Code Block
√ ~ % curl --verbose 'https://mjsabiquoabiquo.lab.abiquoexample.com:443/api/cloud/virtualdatacenters/12/virtualappliances/4/virtualmachines' \    
        -H 'Accept: application/vnd.abiquo.virtualmachines+json; version=6.1' \
        -u user:password -k | jq .

...

Code Block
{
  "totalSize": 2,
  "links": [
    {
      "rel": "first",
      "href": "https://mjsabiquoabiquo.lab.abiquoexample.com:443/api/cloud/virtualdatacenters/12/virtualappliances/4/virtualmachines?limit=25&by=name&asc=true"
    },
    {
      "rel": "last",
      "href": "https://mjsabiquoabiquo.lab.abiquoexample.com:443/api/cloud/virtualdatacenters/12/virtualappliances/4/virtualmachines?startwith=0&limit=25&by=name&asc=true"
    }
  ],
  "collection": [
    {
      "id": 304,
      "uuid": "1979e77f-32b1-430d-9b92-9f6347dbd416",
      "description": "A virtual machine",
      "coresPerSocket": 1,
      "idState": 1,
      "idType": 0,
      "type": "MANAGED",
      "highDisponibility": 0,
      "monitored": false,
      "protected": false,
      "variables": {},
      "backuppolicies": [],
      "generateGuestInitialPassword": false,
      "natrules": [],
      "vdrpEnabled": true,
      "vdrpPort": 0,
      "password": "uvlgwyFx",
      "deallocated": false,
      "name": "vmapihowto",
      "ram": 48,
      "cpu": 1,
      "state": "NOT_ALLOCATED",
      "creationTimestamp": 1686039246000,
      "birthTimestamp": 1686039246000,
      "links": [
        {
          "title": "Abiquo",
          "rel": "enterprise",
          "type": "application/vnd.abiquo.enterprise+json",
          "href": "https://mjsabiquoabiquo.lab.abiquoexample.com:443/api/admin/enterprises/1"
        },
        {
          "title": "vmapihowto",
          "rel": "edit",
          "type": "application/vnd.abiquo.virtualmachine+json",
          "href": "https://mjsabiquoabiquo.lab.abiquoexample.com:443/api/cloud/virtualdatacenters/12/virtualappliances/4/virtualmachines/304"
        },
        ...
      ],
      "usageStatistics": []
    },
    {
      "id": 305,
      "uuid": "eb613c22-ffa1-4498-827a-ccaf37385c2e",
      "description": "A virtual machine",
      "coresPerSocket": 1,
      "idState": 1,
      "idType": 0,
      "type": "MANAGED",
      "highDisponibility": 0,
      "monitored": false,
      "protected": false,
      "variables": {},
      "backuppolicies": [],
      "generateGuestInitialPassword": false,
      "natrules": [],
      "vdrpEnabled": true,
      "vdrpPort": 0,
      "password": "6t51rgZ9",
      "deallocated": false,
      "name": "vmapihowto2",
      "ram": 48,
      "cpu": 1,
      "state": "NOT_ALLOCATED",
      "creationTimestamp": 1686042455000,
      "birthTimestamp": 1686042455000,
      "links": [
        {
          "title": "Abiquo",
          "rel": "enterprise",
          "type": "application/vnd.abiquo.enterprise+json",
          "href": "https://mjsabiquoabiquo.lab.abiquoexample.com:443/api/admin/enterprises/1"
        },
        {
          "title": "vmapihowto2",
          "rel": "edit",
          "type": "application/vnd.abiquo.virtualmachine+json",
          "href": "https://mjsabiquoabiquo.lab.abiquoexample.com:443/api/cloud/virtualdatacenters/12/virtualappliances/4/virtualmachines/305"
        },
        ...
        }
      ],
      "usageStatistics": []
    }
  ]
}
 

...

Code Block
curl --verbose -X POST 'https://mjsabiquoabiquo.lab.abiquoexample.com:443/api/cloud/virtualdatacenters/12/virtualappliances/4/virtualmachines/305/action/deploy' \
-u user:password -k

...

Code Block
{
   "message":"You can keep track of the progress in the link",
   "links":[
      {
         "title":"status",
         "rel":"status",
         "type":"application/vnd.abiquo.task+json",
         "href":"https://mjsabiquoabiquo.lab.abiquoexample.com:443/api/cloud/virtualdatacenters/12/virtualappliances/4/virtualmachines/305/tasks/d18178fd-6a95-494c-8257-adda5c53f26f"
      }
   ]
}

...