How to add a VM template in a datacenter via API

Introduction

This page describes how to refresh the datacenter repository and load templates from a remote repository, such as the default Abiquo remote repository.

When you refresh the repository, the platform will detect VM templates that you have manually added to the repository filesystem. See Importing templates into the catalogue#ManualUpload

This tutorial does not describe how to upload an OVA or disk file from your local system in Abiquo. The easiest way to do this is to use the UI, which will call the Appliance manage remote service to load the package or disk, and automatically process an OVA file. See Add VM Templates to the Apps Library

To use the API, see Appliance manager template API upload and download. You can also Upload and replace template disks via API

 

You will need the following resources.

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

  1. Get the enterprise by name and switch to the enterprise

    1. Reference: How to switch enterprises via API

  2. Also keep the datacenterrepositories link of the enterprise

    { "title": "repositories", "rel": "datacenterrepositories", "type": "application/vnd.abiquo.datacenterrepositories+json", "href": "https://example.com:443/api/admin/enterprises/267/datacenterrepositories" },

     

  3. Get the datacenter repositories for the enterprise

    1. 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" },
    2. Reference: https://wiki.abiquo.com/api/latest/DatacenterRepositoriesResource.html#list-datacenter-repositories

    3. 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.

       

  4. Refresh the datacenter repository to update the Apps library

    1. Perform a PUT request to the refresh link. 

    2. Reference: https://wiki.abiquo.com/api/latest/DatacenterRepositoriesResource.html#refresh-a-datacenter-repository-to-detect-new-virtual-machine-templates

    3. cURL

    4. The refresh is an asynchronous task, so wait until it has completed to go on to the next step

  5. Retrieve a compatible template

    1. If a compatible template already exists, you can retrieve it now using the templates link and parameters. 

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

    3. cURL

    4. From a compatible template, you will need the edit link

  6. Or download a template from a remote repository. 

    1. There is a default remote repository registered in Abiquo. 

    2. To get a list of the templates available in the remote repository, use the Get template definition lists request. 

    3. Reference: https://wiki.abiquo.com/api/latest/TemplateDefinitionListsResource.html#list-template-definition-lists

    4. cURL

    5. Sample response. Success status code: 200. From the response, search for a suitable template definition

    6. From the template definition, keep the edit link

  7. Create a template from the template definition

    1. Reference: https://wiki.abiquo.com/api/latest/VirtualMachineTemplatesResource.html#create-a-virtual-machine-template-in-a-datacenter-repository-by-download-promote-or-export

    2. The templatedefinition.json file should contain the edit link to the template definition with the value of the "rel" attribute changed to "templatedefinition"

    3. cURL

    4. This request will return a link. You can use the link to track the progress of the task.

    5. The template ID is returned in the accepted request in the task link.

You can then use the VM template to create a VM. See How to create virtual datacenters and VMs via API 

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