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 enterprisesYou 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
curl -X GET https://abiquoapi.bcn.abiquo.com:443/api/cloud/locations?has=Abiquo \ -H 'Accept:application/vnd.abiquo.datacenters+json; version=4.7' \ -u user:password --verbose
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
{ "title": "Abiquo-DC", "rel": "edit", "type": "application/vnd.abiquo.datacenter+json", "href": "https://abiquoapi.bcn.abiquo.com:443/api/admin/datacenters/1" },
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".
{ "title": "VMware vCenter", "rel": "hypervisortype", "type": "application/vnd.abiquo.hypervisortype+json", "href": "https://abiquoapi.bcn.abiquo.com:443/api/config/hypervisortypes/VMX_04" }
datacenterrepository link to retrieve templates
{ "title": "repository", "rel": "datacenterrepository", "type": "application/vnd.abiquo.datacenterrepository+json", "href": "https://abiquoapi.bcn.abiquo.com:443/api/admin/enterprises/15/datacenterrepositories/1" },
- 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
curl -X POST https://abiquoapi.bcn.abiquo.com/api/cloud/virtualdatacenters \ -H 'Accept:application/vnd.abiquo.asynctask+json; version=4.7' \ -H 'Content-Type:application/vnd.abiquo.virtualdatacenter+json; version=4.7' \ -d @virtualdatacentercreate.json \ -u user:password --verbose
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.
{ "title": "vdc_test_create", "rel": "owner", "type": "application/vnd.abiquo.virtualdatacenter+json", "href": "https://abiquoapi.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2075" },
- Create a virtual appliance
- Reference: https://wiki.abiquo.com/api/latest/VirtualAppliancesResource.html#create-a-virtual-appliance
cURL
curl -X POST https://abiquoapi.bcn.abiquo.com/api/cloud/virtualdatacenters/2075/virtualappliances \ -H 'Accept:application/vnd.abiquo.virtualappliance+json; version=4.7' \ -H 'Content-Type:application/vnd.abiquo.virtualappliance+json; version=4.7' \ -d @virtualappliancecreate.json \ -u user:password --verbose
Virtual appliance entity
{ "name":"vapp_test_create" }
Sample response. Success status code: 201
You will need the virtualmachines link to create a VM
{ "title": "virtual machines", "rel": "virtualmachines", "type": "application/vnd.abiquo.virtualmachines+json", "href": "https://abiquoapi.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2075/virtualappliances/2596/virtualmachines" },
- Get a compatible template from the Apps library
- Reference: https://wiki.abiquo.com/api/latest/VirtualMachineTemplatesResource.html#list-virtual-machine-templates-in-a-datacenter-repository
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
cURL
curl --verbose -X GET "https://abiquoapi.bcn.abiquo.com/api/admin/enterprises/15/datacenterrepositories/1/virtualmachinetemplates?hypervisorTypeName=VMX_04&limit=1&has=Core" \ -H "Accept: application/vnd.abiquo.virtualmachinetemplates+json; version=4.7;" \ -u user:password
Sample response. Success status code: 201
Select the virtualmachinetemplate object you want to use and get the edit link
{ "title": "Core", "rel": "edit", "type": "application/vnd.abiquo.virtualmachinetemplate+json", "href": "https://abiquoapi.bcn.abiquo.com:443/api/admin/enterprises/15/datacenterrepositories/1/virtualmachinetemplates/3" },
- 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.
{ "label":"Core_VM", "links":[ { "title":"Core", "rel":"virtualmachinetemplate", "type":"application/vnd.abiquo.virtualmachinetemplate+json", "href":"https://abiquoapi.bcn.abiquo.com:443/api/admin/enterprises/15/datacenterrepositories/1/virtualmachinetemplates/3" } ], "vdrpEnabled":true }
- Create a VM
- Perform a POST request to the URL of the virtualmachines link from the virtual appliance
cURL
curl -X POST https://abiquoapi.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2075/virtualappliances/2596/virtualmachines \ -H 'Accept:application/vnd.abiquo.virtualmachine+json; version=4.7' \ -H 'Content-Type:application/vnd.abiquo.virtualmachine+json; version=4.7' \ -d @virtualmachineentity.json \ -u user:password --verbose
- 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
{ "title": "virtual machine deploy", "rel": "deploy", "type": "application/vnd.abiquo.acceptedrequest+json", "href": "https://abiquoapi.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2075/virtualappliances/2596/virtualmachines/16644/action/deploy" },
- Deploy the VM
- Reference: https://wiki.abiquo.com/api/latest/VirtualMachinesResource.html#deploy-a-virtual-machine
cURL
curl -X POST https://abiquoapi.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2075/virtualappliances/2596/virtualmachines/16644/action/deploy \ -H 'Accept:application/vnd.abiquo.acceptedrequest+json;version=4.7' \ -u user:password --verbose
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.