Use the Edit OS Templates API to edit the OS Templates present on the server. If the OS template is precreated by virtualizor than you can change only media groups. The API response contains list edited OS template.
HTTP Request
https://hostname:4085/index.php?act=ostemplates&delete=OSID
Parameters
Name | Method | Value | Description | Required |
---|---|---|---|---|
act | GET | edittemplate | The action to edit the OS template | Yes |
osid | GET | int | The ID of the OS template which needs to be edited | Yes |
type | POST | text | Provide virtualization type e.g. xen,xcphvm | No |
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 | Provide name of the file | No |
pygrub | POST | int | Should be 0 (no) or 1 (yes), Provide if virtualization type is xen | No |
fstype | POST | int | Should be 0 (no) or 1 (yes), Provide if virtualization type is xen | No |
drive | POST | text | By default the Drive is sda. But if the template requires e.g. xvda mounted then please specify xvda, Provide if virtualization type is xen | No |
template_admin_name | POST | text | Please specify an Admin username for windows if it is other than Administrator, Provide if virtualization type is xenhvm, kvm, vzk, proxk, xcp or xcphvm | No |
noresizefs | POST | int | Should be 0 (no) or 1 (yes), Whether to resize filesystem or not, Provide if virtualization type is xenhvm, kvm, vzk, proxk, xcp or xcphvm | No |
perf_ops | POST | int | Should be 0 (no) or 1 (yes), If 1 operations like changing network settings, root password will be performed, Provide if virtualization type is xenhvm, kvm, vzk, proxk, xcp or xcphvm | No |
hvm_pass | POST | text | Provide hvm password only if hvm is enabled on xen or xcp. Or virtualization type is kvm, proxk, xcphvm, xenhvm, kvm or vzk. Or template is windows or others | No |
mgs | POST | array | Provide array of media groups. | No |
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['osid'] = '';
$post['cplan'] = '';
$post['url'] = '';
$post['filename'] = '';
$post['pygrub'] = '';
$post['fstype'] = '';
$post['drive'] = '';
$post['template_admin_name'] = '';
$post['noresizefs'] = '';
$post['perf_ops'] = '';
$post['hvm_pass'] = '';
$post['mgs'] = array();
$output = $admin->edittemplate($post);
print_r(json_encode($output));
?>
Output
{
"title":"Edit OS Template",
"done":1,
"theos":{
"osid":"870",
"type":"kvm",
"name":"centos-7.6-x86_64",
"filename":"centos-7.6-x86_64.img",
"size":"1325400064",
"pygrub":"0",
"drive":"",
"hvm":"0",
"perf_ops":"1",
"active":"1",
"url":"http:\/\/files.virtualizor.com\/ostemplates.php?osid=870",
"distro":"centos",
"Nvirt":"kvm"
},
"mgs":null,
"timenow":1563253502,
"time_taken":"0.090"
}