Appliance Manager Template API Upload and Download
Abiquo uploads templates using the Appliance Manager (AM) Remote Service. To enable API template upload, Abiquo exposes a resource from the private AM API. The authentication for the use of this resource is performed through the Abiquo API.
This section describes how to upload:
- a standard template to the Appliance Manager using the Appliance Manager API
- an OVA file to the Appliance Manager using the Appliance Manager API
Template Files
To upload a standard template you will need:
- diskFile
- one virtual machine disk file, e.g. .vmdk file
- diskInfo
- JSON or XML representation of the template metadata
- diskFile
- OVA format with a filename extension of ".ova"
- can contain multiple disks
- no need to provide template metadata, e.g. disk capacity, because this is in the OVF descriptor file
Preparatory Steps
Step 1. Retrieve the appliance manager base URI
curl -X GET https://myabiquo/api/admin/datacenters/1/remoteservices
{ "id": 3, "links": [ { "href": "https://myabiquo:443/api/admin/remoteservices/3", "rel": "edit", "title": "APPLIANCEMANAGER", "type": "application/vnd.abiquo.remoteservice+json" }, { "href": "https://myabiquo:443/api/admin/remoteservices/3/action/check", "rel": "check", "title": "check", "type": "" }, { "href": "https://myabiquo:443/api/admin/datacenters/1", "rel": "datacenter", "title": "BCDC", "type": "application/vnd.abiquo.datacenter+json" } ], "status": 1, "type": "APPLIANCE_MANAGER", "uri": "https://myabiquo:443/am", "uuid": "Abiquo" },
Step 2. For a standard template, specify the template meta-data in JSON or XML
Sample JSON template
{ "name":"a new template", "description":"this is a test", "categoryName":"simpaticos", "diskFileFormat":"VMDK_FLAT", "requiredCpu":1, "requiredHDInMB":2, "requiredRamInMB":256 }
Sample XML template
<template> <name>theDiskName</name> <description>theDiskDescription</description> <categoryName>Test others</categoryName> <diskFileFormat>VHD_FLAT</diskFileFormat> <requiredCpu>1</requiredCpu> <requiredRamInMB>512</requiredRamInMB> <requiredHDInMB>10</requiredHDInMB> <!-- optional attributes --> <iconUrl /> <loginPassword /> <loginUser /> <diskControllerType /> <ethernetDriverType /> <osType /> <osVersion /> </template>
TIP: use qemu-img to determine the diskFileFormat and requiredHDInMB (=capacity for compressed formats)
Upload Standard Template Example
The following example shows how to upload a single disk file named 'disk.vmdk' and metadata stored in file 'template.json' for the enterprise with id '1'
$ curl --verbose -uadmin:xabiquo -F "diskInfo=@template.json" -F "diskFile=@disk.vmdk" http://10.60.1.223/am/erepos/1/templates > POST /am/erepos/1/templates HTTP/1.1 > Content-Length: 643854480 > Expect: 100-continue > Content-Type: multipart/form-data; boundary=----------------------------be5dd7d6950d > < HTTP/1.1 100 Continue < HTTP/1.1 201 Creado < Location: http://10.60.1.223/am/erepos/1/templates/1/10.60.1.223/1fc06416-6696-4b55-9d7c-d58bc51aaf5a/disk.vmdk < Content-Length: 0
In the returned 'Location' header there is a link to reference the template that was created.
Check the Upload
Get the metadata:
$ curl --verbose -uadmin:xabiquo -X GET "http://10.60.1.223/am/erepos/1/templates/1/10.60.1.223/1fc06416-6696-4b55-9d7c-d58bc51aaf5a/disk.vmdk"
Get the template content:
$ curl --verbose -uadmin:xabiquo -X GET "http://10.60.1.223/am/files/1/10.60.1.223/1fc06416-6696-4b55-9d7c-d58bc51aaf5a/disk.vmdk"
Identify Your Template in the API
The relative path (1/10.60.1.223/1fc06416-6696-4b55-9d7c-d58bc51aaf5a/disk.vmdk) should be used to identify the virtual machine template you created in the abiquo API
curl --verbose -uadmin:xabiquo http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates | xmlprint | grep -C 5 /1/10.60.1.223/1fc06416-6696-4b55-9d7c-d58bc51aaf5a/disk.vmdk
<virtualmachinetemplate> .... <link title="a new template" rel="edit" type="application/vnd.abiquo.virtualmachinetemplate+xml" href="http://localhost:80/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/32" /> <link rel="template" href="http://10.60.1.223:80/am/erepos/1/templates/1/10.60.1.223/1fc06416-6696-4b55-9d7c-d58bc51aaf5a/disk.vmdk" /> <link rel="diskfile" href="http://10.60.1.223:80/am/files/1/10.60.1.223/1fc06416-6696-4b55-9d7c-d58bc51aaf5a/disk.vmdk" /> ... </virtualmachinetemplate>
Upload OVA Template Example
To upload an OVA template, start by reading the above sections that describe the #Template Files and the #Preparatory Steps.
The following example shows how to upload an OVA file, which may have multiple VM disk files. Include the template and disk details in the OVF descriptor file inside the OVA. Do not supply a diskInfo file for the template because this information is included in the OVA file. Supply the OVA file with the filename extension of ".ova".
Use the same link as for standard template upload.
$ curl --verbose -uadmin:xabiquo -F "diskFile=@disk.ova" -X POST https://myabiquo:443/am/erepos/8/templates > POST /am/erepos/8/templates HTTP/1.1 > Authorization: Basic YWRtaW46eGFiaXF1bw== > User-Agent: curl/7.35.0 > Host: myabiquo > Accept: */* > Content-Length: 27279568 > Expect: 100-continue > Content-Type: multipart/form-data; boundary=------------------------934b0504be069532 > < HTTP/1.1 100 Continue < HTTP/1.1 201 Created < Date: Mon, 28 Sep 2015 15:11:38 GMT < Location: https://myabiquo/am/erepos/8/templates/8/myabiquo/b689db73-769f-467e-867d-5913a1f5c281-m0n0wall.ova/m0n0wall/ < Content-Length: 0 < Content-Type: text/plain < * Connection #0 to host myabiquo left intact < Content-Length: 0
In the response 'Location' header there is a link to reference the template that was created.
Copyright © 2006-2022, Abiquo Holdings SL. All rights reserved