Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

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:

...

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

Info

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.

Mermaid
fileNamemermaid_1655113551112
themeneutral
version5
{"diagramDefinition":"graph TD\r\n\r\nZ(( ))\r\n\r\nstyle Z fill:#g1g,stroke:#100,stroke-width:20px\r\n\r\nZ-->A(<font color=0052cc>Get enterprise by name and<br/>switch to the enterprise)\r\n\r\nclick A href \"https://wiki.abiquo.com/display/doc/How+to+switch+enterprises+via+API\" _blank\r\n\r\nA -->B(Also keep the<br/>datacenterrepositories link)\r\n \r\nB -->C(<font color=0052cc>Get enterprise<br/>datacenter repositories)\r\n\r\nclick C href \"https://wiki.abiquo.com/api/latest/DatacenterRepositoriesResource.html#list-datacenter-repositories\" _blank\r\n\r\nC-->D(<font color=0052cc>Refresh DC Apps library)\r\n\r\nclick D href \"https://wiki.abiquo.com/api/latest/DatacenterRepositoriesResource.html#refresh-a-datacenter-repository-to-detect-new-virtual-machine-templates\" _blank\r\n\r\nD-->E(<font color=0052cc>Find a template<br/>in a remote repository)\r\n\r\nclick E href \"https://wiki.abiquo.com/api/latest/TemplateDefinitionListsResource.html#list-template-definition-lists\" _blank\r\n\r\nE-->F(<font color=0052cc>Create a template in a DC from<br/>the template definition)\r\n\r\nclick F href \"https://wiki.abiquo.com/api/latest/VirtualMachineTemplatesResource.html#create-a-virtual-machine-template-in-a-datacenter-repository-by-download-promote-or-export]\" _blank\r\n\r\nF-->G(<font color=0052cc>Get a compatible template<br/>from the DC Apps library)\r\n\r\nclick G href \"https://wiki.abiquo.com/api/latest/VirtualMachineTemplatesResource.html#list-virtual-machine-templates-in-a-datacenter-repository\" _blank\r\n\r\nD-->G\r\n\r\nG-->Q((<fontcolour=f3efe6> * ))\r\n\tstyle Q fill:#f3efe6,stroke:#030300,stroke-width:7px,color:#f3efe6"}

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

    Code Block
            {
                "title": "repositories",
                "rel": "datacenterrepositories",
                "type": "application/vnd.abiquo.datacenterrepositories+json",
                "href": "https://example.com:443/api/admin/enterprises/267/datacenterrepositories"
            },
  3. Switch to the enterprise
    1. Reference: How to switch enterprises via API
  4. Add templates to the enterprise's Apps library

    Get the datacenter repositories for the enterprise

    .

    1. From the enterprise entity, use the URL of the datacenter repositories link

      Code Block
              {
                  "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

      Code Block
                      {
                          "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.

      Code Block
              {
                  "title": "virtual machine templates",
                  "rel": "virtualmachinetemplates",
                  "type": "application/vnd.abiquo.virtualmachinetemplates+json",
                  "href": "https://example.com:443/api/admin/enterprises/267/datacenterrepositories/1/virtualmachinetemplates"
              },

  5. Refresh the

    repository by performing

    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

      Code Block
      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
    4. The refresh is an asynchronous task, so wait until it has completed to go on to the next step

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

      expand
    3. cURL

      Code Block
      curl --verbose -X GET https://example.com/api/admin/enterprises/267/datacenterrepositories/1/virtualmachinetemplates?hypervisorTypeName=VMX_04&limit=1&has=Core \
      	-H "Accept: application/vnd.abiquo.virtualmachinetemplates+json; version=4.7;" \
      	-u user:password   
    4. From a compatible template, you will need the edit link

      Code Block
                      {
                          "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
  7. 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

      Code Block
      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
    5. Sample response. Success status code: 200. From the response, search for a suitable template definition

      Expand
      Code Block
                         {
                              "id": 2083,
                              "url": "http://files.template-repository.abiquo.com/m0n0wall/m0n0wall-1.3b18-i386-monolithicFlat.1.5.ovf",
                              "name": "m0n0wall 1.3b18-i386",
                              "description": "m0n0wall is a project aimed at creating a complete, embedded firewall software package that, when used together with an embedded PC, provides \n            all the important features of commercial firewall boxes (including ease of use) at a fraction of the price (free software). https://PUBLIC:IP and use Username: admin, \n            password: abiquo. Configure MANUALLY the private IP of abicloud and it's done.",
                              "productName": "m0n0wall 1.3b18-i386",
                              "iconUrl": "http://files.template-repository.abiquo.com/m0n0wall/m0n0wall_logo.png",
                              "osType": "LINUX_2_6",
                              "ethernetDriverType": "E1000",
                              "links": [
                                  {
                                      "title": "Reseller enterprise",
                                      "rel": "enterprise",
                                      "type": "application/vnd.abiquo.enterprise+json",
                                      "href": "https://example.com:443/api/admin/enterprises/267"
                                  },
                                  {
                                      "title": "Firewall",
                                      "rel": "category",
                                      "type": "application/vnd.abiquo.category+json",
                                      "href": "https://example.com:443/api/config/categories/11"
                                  },
                                  {
                                      "title": "Repository 2.0",
                                      "rel": "templateDefinitionList",
                                      "type": "application/vnd.abiquo.templatedefinitionlist+json",
                                      "href": "https://example.com:443/api/admin/enterprises/267/appslib/templateDefinitionLists/87"
                                  },
                                  {
                                      "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"
                                  }
                              ],
                              "templatedefinitiondisks": [
                                  {
                                      "label": "scsi0:0",
                                      "diskFormatType": "VMDK_FLAT",
                                      "diskFileSize": 27262976,
                                      "hdRequired": 27262976,
                                      "diskControllerType": "SCSI",
                                      "diskController": "lsilogic",
                                      "links": []
                                  }
                              ]
                          },
    6. From the template definition, keep the edit link

      Code Block
                                  {
                                      "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"
                                  }
  8. Create a template from the template definition

    with the following request.

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

      Code Blockcurl
    2. -X POST https://example.com:443/api/admin/enterprises/267/datacenterrepositories/1/virtualmachinetemplates \

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

      Code Block
      {
        "links": [
          {
            "title": "m0n0wall 1.3b18-i386",
           -H 'Accept:application/vnd.abiquo.acceptedrequest+json;version=4.7' \ "rel": "templateDefinition",
            -H 'Content-Type:"type": "application/vnd.abiquo.virtualmachinetemplaterequesttemplatedefinition+json;version=4.7' \",
             -d @templatedefinition.json \"href": "https://example.com/api/admin/enterprises/267/appslib/templateDefinitions/2083/actions/repositoryInstall"
          }
        -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"
      ]
      }
    3. cURL

      Code Block
      {curl -X  "links": [
          {POST https://example.com:443/api/admin/enterprises/267/datacenterrepositories/1/virtualmachinetemplates \ 
            "title": "m0n0wall 1.3b18-i386",
      -H 'Accept:application/vnd.abiquo.acceptedrequest+json;version=4.7' \ 
          "rel": "templateDefinition",
            "type": " -H 'Content-Type:application/vnd.abiquo.templatedefinition+json",abiquo.virtualmachinetemplaterequest+json;version=4.7' \ 
           "href": "https://example.com/api/admin/enterprises/267/appslib/templateDefinitions/2083/actions/repositoryInstall"-d @templatedefinition.json \ 
         }  -u ]
      }user:password --verbose
    4. This request will return a link. You can use the link to track the progress of the task.

      Expand
      Code Block
      {
          "message": "You can keep track of the progress in the link",
          "links": [
              {
                  "title": "status",
                  "rel": "status",
                  "type": "application/vnd.abiquo.task+json",
                  "href": "https://example.com:443/api/admin/enterprises/267/datacenterrepositories/1/virtualmachinetemplates/2251/tasks/de40272f-1e23-45c0-99ae-2255e5bc752f"
              }
          ]
      }
    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