Get Virtualizor

Sync OS Templates

Use the Sync OS Templates API to synchronize the OS Templates accross all the available servers. The API response contains list of all the oses, OS templates and media groups of the server.

HTTP Request

https://hostname:4085/index.php?act=edittemplate&osid=OSID

Parameters

NameMethodValueDescriptionRequired
actGETostemplatesThe action specified to synchronize OS templatesYes
sync_osPOSTtextSpecify OS IDs seperated by commas.Yes
seridsPOSTtextSpecify server IDs seperated by commas.Yes
force_syncPOSTintSpecify whether to forcefully sync OS templates should be 1 (yes) or 0 (no)No

Sample Code

<?php

    require_once('/virt/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['sync_os'] = ''; 
    $post['serids'] = ''; 
    $post['force_sync'] = ''; 

    $output = $admin->syncostemplate($post);

    print_r(json_encode($output));
?>

Output

{
  "title":"OS Templates",
   "done":"sync_os",
   "oses":{
      "1":{
         "osid":"1",
         "type":"openvz",
         "name":"centos-4-x86",
         "filename":"centos-4-x86.tar.gz",
         "size":"158628685",
         "pygrub":"0",
         "drive":"",
         "hvm":"0",
         "perf_ops":"0",
         "active":"1",
         "url":"http:\/\/files.virtualizor.com\/ostemplates.php?osid=1",
         "distro":"centos",
         "Nvirt":"openvz"
      }
      },
   "oslist":{
      "openvz":{
         "webuzo":{
            "822":{
               "osid":"822",
               "type":"openvz",
               "name":"webuzo-centos-7.5-x86_64",
               "filename":"webuzo-centos-7.5-x86_64.tar.gz",
               "size":"361545006",
               "pygrub":"0",
               "drive":"",
               "hvm":"0",
               "perf_ops":"0",
               "active":"1",
               "url":"http:\/\/files.virtualizor.com\/ostemplates.php?osid=822",
               "distro":"webuzo",
               "Nvirt":"openvz"
            }
         }
      },
      "kvm":{
         "centos":{
            "870":{
               "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"
            }
         }
      }
   },
   "ostemplates":{
      "822":{
         "osid":"822",
         "type":"openvz",
         "name":"webuzo-centos-7.5-x86_64",
         "filename":"webuzo-centos-7.5-x86_64.tar.gz",
         "size":"361545006",
         "pygrub":"0",
         "drive":"",
         "hvm":"0",
         "perf_ops":"0",
         "active":"1",
         "url":"http:\/\/files.virtualizor.com\/ostemplates.php?osid=822",
         "distro":"webuzo",
         "Nvirt":"openvz"
      },
      "870":{
         "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"
      }
   },
   "installed":{
      "362":"1",
      "870":"3"
   },
   "mgs":null,
   "timenow":1563254317,
   "time_taken":"0.089"
}
    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list