Replace a template disk with the AM API
This page describes how to replace a template disk directly in the repository file system and supply the correct template details for the new disk.
Requirements
This request requires direct access to the Appliance Manager API
Make a backup of your template folder before you begin
If you are replacing a disk that was created from an instance of a captured VM,
before you upload your new disk, add an Abiquo OVF file to the original VM template folder .
You may be able to copy the OVF file of another template and modify it
The Appliance Manager API does not validate the request
To avoid damage your file system, provide the correct path to your disk file!!
Example use case
Here is an example use case
Upload or download a template
Use it to create a VMÂ
Update the template. Abiquo supports changes to:
file content
size
format
capacity
controller
Update the disk using the Appliance manager API.
When the user next deploys the VM, the platform will copy the updated disk
Create a data object
You will need a JSON file to describe the disk.
The steps below describe how to obtain the values of {TEMPLATE_URL}
, {DISK_URL}
, and {FOLDER_PATH}
from the Abiquo UI.
You must set the correct requiredHDInMB
for the deployed disk in Abiquo before you deploy the VM.
Try to complete the other disk data as best you can.
{
"virtualMachineTemplateUrl":"{TEMPLATE_URL}",
"diskUrl":"{DISK_URL}",
"currentPath":"{FOLDER_PATH}",
"diskController": "lsilogic",
"diskControllerType": "SCSI",
"diskFileFormat":"VMDK_STREAM_OPTIMIZED",
"diskFilePath": "",
"label": "Hard disk 1",
"requiredHDInMB":120,
"sequence":0
}
Â
Log in to Abiquo and open developer tools in your browser
Go to Network and record requests
Select and edit the template.
Select the disk in the UIFrom the developer tools console, select the request to get the disks.
Here you will find the:Template URL and disk URL
Current path on the repository file system
Find the disk edit link href value and path in dev tools
Complete the JSON object with the data from your API. For example, from the values above
{ "virtualMachineTemplateUrl":"https://mjsabiquo.lab.example.com/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/72", "diskUrl":"https://mjsabiquo.lab.example.com/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/72/disks/74", "currentPath":"1/bundle/e05785d2-b49a-4034-9bb9-3440e1693589-4ba3b6e1-6f06-47d9-8703-9e9/daf2f2fb-d3d0-4263-a466-d1b27a0d6864-new+dsl+disk.vmdk", "diskController": "lsilogic", "diskControllerType": "SCSI", "diskFileFormat":"VMDK_STREAM_OPTIMIZED", "diskFilePath": "", "label": "Hard disk 1", "requiredHDInMB":120, "sequence":0 }
Save it to a file called
diskReplace.json
Obtain the URL
To create the URL for the request, you will need:
The URL to reach the Remote Services server with the AM remote service.
Thers_url
is the URL of the AM, without any/api
path. For example,https://mjsremoteservices.lab.example.com
.The folder part the path attribute
The basic URL format is as follows
{rs_url}/am/erepos/{enterpriseId}/templates/{folderPath}
So for the above example, this will be
Â
Â
Obtain an authorization token
If you wish to use token authentication, which is more secure and required for 2FA, do these steps.
To obtain an authorization token, send a GET
request to the API login
resource.
Use basic authentication and get the token from the X-Abiquo-Token
header.
curl --verbose -X GET "https://mjsabiquo.lab.example.com:443/api/login" -u adminuser:password -k
If you are using 2FA, you can get the 2FA verification code in the usual way (by email or from Google Authenticator).
Log in again and send the 2FA verification code.
Now you can get the token from the X-Abiquo-Token
header of the response.
In your API requests, use the token in a header with the following format.
In this example we have shortened the token.
In the workflow below, we represent the token with {api_token}
.
For more details, see Authentication.
Replace the file
We recommend that you use double quotation marks around all the parameters, including the file parameters for diskInfo
and diskFile
.
Replace newdisk.vmdk
 with the name of your disk file on the local file system.
Example request:
Use double quotation marks around all the parameters, including the file parameters for diskInfo
and diskFile
, especially if the disk file name contains spaces!
Success status code:Â 201 Created
Â
Copyright © 2006-2024, Abiquo Holdings SL. All rights reserved