API Add Template

From Virtualizor Wiki
Jump to: navigation, search
This is OLD API Documentation. Click on the following link for New API Documentation
Admin API

Add an OS template

 URL: index.php?act=addtemplate
Parameters Type Description
addtemplate POST Flag to add an OS template (This has to be 1)
template POST Template Type (centos, fedora, suse, debian, ubuntu, scientific, others)
url POST The url to the template if it is to be downloaded
filename POST The filename of the template if it already exists int the /var/virtualizor/ folder
mgs POST Assign to Media Group if any (Optional)
cplan POST The virtualization type (openv/kvm/xen/xenhvm)
drive POST The name of the disk drive (eg: xvda)(Only for Xen-PV)
extra POST Additional configuration options (Only for KVM and Xen)
pygrub POST Enable booting via pygrub (Only for Xen-PV)
noresizefs POST Prevent the template from being resized while creating a VPS from it (Only for KVM and Xen-HVM)
perf_ops POST Perform operation such as resize filesystem and set root password and network settings etc. (Only for KVM and Xen-HVM)

Example Code



    $key =  'uketenhrhpunty5lhgwkcuxxxxxxxxxx';

    $pass = 'yrsofc3tg3tre7bjpfppspxxxxxxxxxx';

    $ip = 'xxx.xxx.xxx.xxx';

    $admin = new Virtualizor_Admin_API($ip, $key, $pass);

    $post = array();
    $post['addtemplate'] = 1;
    $post['template'] = 'centos';
    $post['url'] = 'http://files.example.com/template.iso';
    $post['filename'] = 'template_name';
    $post['mgs'] = 'mediagroup_name';
    $post['cplan'] = 'openvz';
    $post['drive'] = '';
    $post['extra'] = '';
    $post['hvm_pass'] = '';
    $post['noresizefs'] = '';
    $post['perf_ops'] = '';
    $post['virt_dd'] = 'openvz';
    $output = $admin->addtemplate($post);


    [title] => Add Template
    [done] => 1
    [timenow] => 1348126304
    [time_taken] => 0.012