Edit OS Templates

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

NameMethodValueDescriptionRequired
actGETedittemplateThe action to edit the OS templateYes
osidGETintThe ID of the OS template which needs to be editedYes
typePOSTtextProvide virtualization type e.g. xen,xcphvmNo
urlPOSTtextIf 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
filenamePOSTtextProvide name of the fileNo
pygrubPOSTintShould be 0 (no) or 1 (yes), Provide if virtualization type is xenNo
fstypePOSTintShould be 0 (no) or 1 (yes), Provide if virtualization type is xenNo
drivePOSTtextBy default the Drive is sda. But if the template requires e.g. xvda mounted then please specify xvda, Provide if virtualization type is xenNo
template_admin_namePOSTtextPlease specify an Admin username for windows if it is other than Administrator, Provide if virtualization type is xenhvm, kvm, vzk, proxk, xcp or xcphvmNo
noresizefsPOSTintShould be 0 (no) or 1 (yes), Whether to resize filesystem or not, Provide if virtualization type is xenhvm, kvm, vzk, proxk, xcp or xcphvmNo
perf_opsPOSTintShould 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 xcphvmNo
hvm_passPOSTtextProvide 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 othersNo
mgsPOSTarrayProvide 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"
}
Was this helpful to you?