Introduction
This page describes how to create a tenant (enterprise) and some users, and how to download a template to the Apps library using the API.
You will need the following resources.
- Datacenter or public cloud region
Your user role must include the following privileges.
- ENTERPRISE_ADMINISTER_ALL
- MANAGE_ENTERPRISES
APPLIB_ALLOW_MODIFY
The following pages describe the enterprise UI and Apps library functionality.
Summary diagram
The steps in this diagram link to the API reference guide resources and data entities sections.
Detailed steps
Get the enterprise
Get enterprises by name or get the enterprise ID and the enterprise
Reference:
- cURL
Keep the datacenterrepositories link
{ "title": "repositories", "rel": "datacenterrepositories", "type": "application/vnd.abiquo.datacenterrepositories+json", "href": "https://example.com:443/api/admin/enterprises/267/datacenterrepositories" },
- Switch to the enterprise
- Reference: How to switch enterprises via API
- Add templates to the enterprise's Apps library
Get the datacenter repositories for the enterprise. From the enterprise entity, use the URL of the datacenter repositories link
{ "title": "repositories", "rel": "datacenterrepositories", "type": "application/vnd.abiquo.datacenterrepositories+json", "href": "https://example.com:443/api/admin/enterprises/267/datacenterrepositories" },
Reference: https://wiki.abiquo.com/api/latest/DatacenterRepositoriesResource.html#list-datacenter-repositories
From each datacenter repository, you will need the refresh link
{ "title": "refresh", "rel": "refresh", "type": "application/vnd.abiquo.acceptedrequest+json", "href": "https://example.com:443/api/admin/enterprises/267/datacenterrepositories/1/actions/refresh" },
And the "virtualmachinetemplates" link.
{ "title": "virtual machine templates", "rel": "virtualmachinetemplates", "type": "application/vnd.abiquo.virtualmachinetemplates+json", "href": "https://example.com:443/api/admin/enterprises/267/datacenterrepositories/1/virtualmachinetemplates" },
Refresh the repository by performing a PUT request to the refresh link. Reference: https://wiki.abiquo.com/api/latest/DatacenterRepositoriesResource.html#refresh-a-datacenter-repository-to-detect-new-virtual-machine-templates
curl --verbose -X PUT https://example.com:443/api/admin/enterprises/267/datacenterrepositories/1/actions/refresh \ -H "Accept: application/vnd.abiquo.acceptedrequest+json; version=4.7;" \ -u user:password
The refresh is an asynchronous task, so wait until it has completed to go on to the next step
If a compatible template already exists, you can retrieve it now using the templates link and parameters. Reference: https://wiki.abiquo.com/api/latest/VirtualMachineTemplatesResource.html#list-virtual-machine-templates-in-a-datacenter-repository
From a compatible template, you will need the edit link
{ "title": "Core", "rel": "edit", "type": "application/vnd.abiquo.virtualmachinetemplate+json", "href": "https://example.com:443/api/admin/enterprises/267/datacenterrepositories/1/virtualmachinetemplates/3" },
- If there are no templates, you can download one from a remote repository. There is a default remote repository registered in Abiquo
To get a list of the templates available in the remote repository, use the Get template definition lists request. Reference: https://wiki.abiquo.com/api/latest/TemplateDefinitionListsResource.html#list-template-definition-lists
curl --verbose -X GET https://example.com/api/admin/enterprises/267/appslib/templateDefinitionLists \ -H "Accept: application/vnd.abiquo.templatedefinitionslists+json; version=4.7;" \ -u user:password
Sample response. Success status code: 200. From the response, search for a suitable template definition
From the template definition, keep the edit link
{ "title": "m0n0wall 1.3b18-i386", "rel": "edit", "type": "application/vnd.abiquo.templatedefinition+json", "href": "https://example.com:443/api/admin/enterprises/267/appslib/templateDefinitions/2083" }
Create a template from the template definition with the following request. Reference: https://wiki.abiquo.com/api/latest/VirtualMachineTemplatesResource.html#create-a-virtual-machine-template-in-a-datacenter-repository-by-download-promote-or-export
curl -X POST https://example.com:443/api/admin/enterprises/267/datacenterrepositories/1/virtualmachinetemplates \ -H 'Accept:application/vnd.abiquo.acceptedrequest+json;version=4.7' \ -H 'Content-Type:application/vnd.abiquo.virtualmachinetemplaterequest+json;version=4.7' \ -d @templatedefinition.json \ -u user:password --verbose
The templatedefinition.json file should contain the edit link to the template definition with the value of the "rel" attribute changed to "templatedefinition"
{ "links": [ { "title": "m0n0wall 1.3b18-i386", "rel": "templateDefinition", "type": "application/vnd.abiquo.templatedefinition+json", "href": "https://example.com/api/admin/enterprises/267/appslib/templateDefinitions/2083/actions/repositoryInstall" } ] }
This request will return a link. You can use the link to track the progress of the task.
The template ID is returned in the accepted request in the task link.
You can then use the VM template to create a VM.