Use the Add Template API to add an existing OS template to your server. These templates can be Windows templates or any other custom OS templates which can be used for the creation of Virtual Private Servers. You can also download the OS image by passing the "url" parameter. The API response will contain "done" as "1" after successful addition of the template.
For more information, you can refer this Add OS Template guide.
HTTP Request
https://hostname:4085/index.php?act=edittemplate&osid=OSID
Parameters
Name | Method | Value | Description | Required |
---|---|---|---|---|
act | GET | addtemplate | The action specified to perform operation and will return done as 1 after the template has been added successfully | Yes |
cplan | POST | text | The virtualization type of the server for valid values refer below table | Yes |
url | POST | text | If you want this template to be downloaded from the Internet, please give the URL. Otherwise it will be assumed that the Template exists on the system | No |
filename | POST | text | The filename of the OS template, this value should be of the format 'filepath'\filename if the OS is to be downloaded from the internet, for valid values refer below table | Yes |
noresizefs | POST | 1/0 | If set, the filesystem of the template would be resized | No |
perf_ops | POST | 1/0 | Extra operation that need to be performed while creating a template | No |
mgs | POST | array | The array of the media group ids to which the template should be assigned | No |
extra | POST | text | Extra things to specified before creating a template | No |
fstype | POST | 1/0 | File system type of the template (only for xen vps) | No |
pygrub | POST | 1/0 | If set the pygrub will be enabled (only for xen vps) | No |
Valid Values
Virtualization Type | cplan value | filepath |
---|---|---|
Openvz | openvz | /vz/template/cache/ |
XEN | xen | /var/virtualizor/xen/ |
XEN-HVM | xenhvm | /var/virtualizor/xen/ |
KVM | kvm | /var/virtualizor/kvm/ |
XenServer | xcp | /var/virtualizor/xcp/ |
XenServer-HVM | xcphvm | /var/virtualizor/xcp/ |
LXC | lxc | /var/virtualizor/lxc/ |
Virtuozzo Openvz | vzo | /vz/template/cache/ |
Virtuozzo KVM | vzk | /var/virtualizor/vzk/ |
Proxmox OpenVZ | proxo | /var/virtualizor/proxo/ |
Proxmox KVM | proxk | /var/virtualizor/proxk/ |
Proxmox LXC | proxl | /var/virtualizor/proxl/ |
Sample Code
<?php
require_once('/usr/local/virtualizor/sdk/admin.php');
$key = 'your_api_key';
$pass = 'your_api_pass';
$ip = 'your_server_ip';
$admin = new Virtualizor_Admin_API($ip, $key, $pass);
$post = array();
$post['cplan'] = 'kvm';
$post['filename'] = 'ubuntu-mini.iso';
$output = $admin->addtemplate($post);
print_r(json_encode($output));
?>
Output
{
"title": "Add OS Template",
"done": 1,
"mgs": {
"1": {
"mgid": "1",
"mg_name": "test",
"mg_desc": "test_desc",
"mg_type": "openvz"
}
},
"timenow": 1536079812,
"time_taken": "0.334"
}