How to create virtual datacenters and VMs via API

Introduction

This page describes how to create a virtual datacenter and deploy a VM.

This tutorial is suitable for a test environment only and it does not use proper authentication.

You will need the following resources.

Your user role must include the following privileges.

  • A user privilege, e.g. MANAGE_USERS, to retrieve enterprises

  • VDC_MANAGE

  • VDC_MANAGE_VAPP

  • VAPP_DEPLOY_UNDEPLOY

The following pages contain reference information for this tutorial:

Summary diagram

The steps in this diagram link to the API reference guide resources and data entities sections.

 

Detailed steps

  1. Get the link to the enterprise

    1. Get smaller result entity with the enterprises-id-name media type

    2. Specify the enterprise name with the "has" parameter to filter by name text

    3. Reference

      1. https://wiki.abiquo.com/api/latest/EnterprisesResource.html#list-enterprise-identifiers-and-names

    4. cURL

      curl -X GET https://abiquoapi.bcn.abiquo.com:443/api/admin/enterprises?has=video \ -H 'Accept:application/vnd.abiquo.enterprises-id-name+json; version=4.7' \ -u user:password --verbose



    5. Sample response. Success response code: 200
      Note: this request returns a collection of enterprises

      { "totalSize": 1, "links": [ { "rel": "first", "href": "https://abiquoapi.bcn.abiquo.com:443/api/admin/enterprises?limit=25&has=video" }, { "rel": "last", "href": "https://abiquoapi.bcn.abiquo.com:443/api/admin/enterprises?startwith=0&limit=25&has=video" } ], "collection": [ { "id": 15, "name": "Video_enterprise", "vmsSoft": 0, "vmsHard": 0, "vlansSoft": 0, "vlansHard": 0, "publicIpsSoft": 0, "publicIpsHard": 0, "links": [ { "title": "Video_enterprise", "rel": "edit", "type": "application/vnd.abiquo.enterprise+json", "href": "https://abiquoapi.bcn.abiquo.com:443/api/admin/enterprises/15" } ], "ramSoft": 0, "ramHard": 0, "cpuSoft": 0, "cpuHard": 0 } ] }



    6. You will need the edit link of the enterprise

      { "title": "Video_enterprise", "rel": "edit", "type": "application/vnd.abiquo.enterprise+json", "href": "https://abiquoapi.bcn.abiquo.com:443/api/admin/enterprises/15" }



  2. Get allowed locations for the current enterprise

    1. Specify datacenters or publiccloudregions using the media type in the Accept header

    2. Cloud admin can use the "enterprise" parameter to get locations for another enterprise by ID 

    3. References: 

      1. https://wiki.abiquo.com/api/latest/AllowedLocationsResource.html#list-location-of-allowed-datacenters

      2. https://wiki.abiquo.com/api/latest/AllowedLocationsResource.html#list-location-of-allowed-public-cloud-regions

    4. cURL



    5. Sample response. Success status code: 200
      Note: This request returns a collection of allowed locations



    6. You will need the edit, hypervisortype, and datacenterrepository links of the location.

      1. edit link



      2. hypervisortype link for the hypervisor you would like to use in the virtual datacenter. The code of the hypervisor type is at the end of the link, for example, for VMware vCenter, the name is "VMX_04".



      3. datacenterrepository link to retrieve templates



  3. Create a virtualdatacenter entity

    1. Reference: https://wiki.abiquo.com/api/latest/virtualdatacenter.html

    2. Add the links to the enterprise and the location and the hypervisorType attribute.

  4. Create a virtualdatacenter

    1. Reference: https://wiki.abiquo.com/api/latest/VirtualDatacentersResource.html#create-a-virtual-datacenter

    2. cURL



    3. Virtual datacenter entity



    4. Sample response


      The "owner" link references the virtualdatacenter, so you can use it obtain the virtualdatacenter entity and you will also need it to create a virtual appliance.



  5. Create a virtual appliance

    1. Reference: https://wiki.abiquo.com/api/latest/VirtualAppliancesResource.html#create-a-virtual-appliance

    2. cURL



    3. Virtual appliance entity



    4. Sample response. Success status code: 201



    5. You will need the virtualmachines link to create a VM



  6. Get a compatible template from the Apps library

    1. Reference: https://wiki.abiquo.com/api/latest/VirtualMachineTemplatesResource.html#list-virtual-machine-templates-in-a-datacenter-repository

    2. Perform a GET request to the URL from the datacenterrepository link of the location. Get the virtualmachinetemplates link from the datacenterrepository.

    3. Get the VM templates using parameters including:

      1. hypervisorTypeName - for compatibility

      2. limit - for convenience

      3. has - filter template names by this text string

      See the above API Reference page for more details.

    4. cURL



    5. Sample response. Success status code: 201



    6. Select the virtualmachinetemplate object you want to use and get the edit link



    7. Troubleshooting: if the request doesn't return any templates, you may need to refresh the datacenter repository. Reference: 


  7. Create a VM entity

    1. The link to specify the template is the only required attribute. In this case, we are also setting the friendly name of the VM and enabling remote access.



  8. Create a VM

    1. Perform a POST request to the URL of the virtualmachines link from the virtual appliance

    2. cURL



    3. The virtualmachineentity.json file to send with this request is shown in the previous step. 

    4. Sample response. Success status code: 201



    5. You will need the deploy link to launch the VM



  9. Deploy the VM

    1. Reference: https://wiki.abiquo.com/api/latest/VirtualMachinesResource.html#deploy-a-virtual-machine

    2. cURL



    3. Sample response. Success status code: 202
      This request returns an acceptedrequest object with a link to track the progress of the deploy.



    4. Alternatively, you can deploy all the VMs in the virtual appliance using the deploy link from the virtual appliance.

Your VM should now be deployed and powered on. Congratulations! You have completed this tutorial.



Copyright © 2006-2024, Abiquo Holdings SL. All rights reserved