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.
An enterprise with one or more allowed datacenters or public cloud regions
To allow access via API, create an enterprise limit, see Create tenants via API
Also add credentials for the enterprise in public cloud regions, see Obtain public cloud credentials and Add credentials for public cloud
Apps library with a template that is compatible with the VDC
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
Get the link to the enterprise
Get smaller result entity with the enterprises-id-name media type
Specify the enterprise name with the "has" parameter to filter by name text
Reference
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
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 } ] }
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" }
Get allowed locations for the current enterprise
Specify datacenters or publiccloudregions using the media type in the Accept header
Cloud admin can use the "enterprise" parameter to get locations for another enterprise by IDÂ
References:Â
cURL
Sample response. Success status code: 200
Note: This request returns a collection of allowed locationsYou will need the edit, hypervisortype, and datacenterrepository links of the location.
edit link
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".
datacenterrepository link to retrieve templates
Create a virtualdatacenter entity
Reference:Â https://wiki.abiquo.com/api/latest/virtualdatacenter.html
Add the links to the enterprise and the location and the hypervisorType attribute.
Create a virtualdatacenter
Reference:Â https://wiki.abiquo.com/api/latest/VirtualDatacentersResource.html#create-a-virtual-datacenter
cURL
Virtual datacenter entity
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.
Create a virtual appliance
Reference:Â https://wiki.abiquo.com/api/latest/VirtualAppliancesResource.html#create-a-virtual-appliance
cURL
Virtual appliance entity
Sample response. Success status code: 201
You will need the virtualmachines link to create a VM
Get a compatible template from the Apps library
Perform a GET request to the URL from the datacenterrepository link of the location. Get the virtualmachinetemplates link from the datacenterrepository.
Get the VM templates using parameters including:
hypervisorTypeName - for compatibility
limit - for convenience
has - filter template names by this text string
See the above API Reference page for more details.
cURL
Sample response. Success status code: 201
Select the virtualmachinetemplate object you want to use and get the edit link
Troubleshooting: if the request doesn't return any templates, you may need to refresh the datacenter repository. Reference:Â
Create a VM entity
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.
Create a VM
Perform a POST request to the URL of the virtualmachines link from the virtual appliance
cURL
The virtualmachineentity.json file to send with this request is shown in the previous step.Â
Sample response. Success status code: 201
You will need the deploy link to launch the VM
Deploy the VM
Reference:Â https://wiki.abiquo.com/api/latest/VirtualMachinesResource.html#deploy-a-virtual-machine
cURL
Sample response. Success status code: 202
This request returns an acceptedrequest object with a link to track the progress of the deploy.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