API Plan

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

Add a Plan

Parameters Description
addplan Confirmation to Add Plan
plan_name Name of the plan
cplan The type of Plan(XCP,XEN,KVM,OpenVz)
disk_space Amount of disk space for the VPS
guaranteed_ram Amount of ram for the VPS
swapram Amount of swap ram for the VPS (for KVM,XCP and XEN VPS)
burst_ram Amount of burst ram for the VPS(for OpenVz VPS)
bandwidth Network bandwidth in GB(Setting 0 will set bandwidth to unlimited)
network_speed Network speed in kb/s
network_speed2 Network speed in kb/s, same as network_speed
cpu_units The amount of CPU units to be set
cpu_cores The amount of CPU cores to be set
percent_cpu The total amount of CPU processing in percent to be given to a VPS
priority I/O priority for OpenVZ. Valid values are 1-7
ips The amount of ips to auto allocate

Example Code

<?php

    require_once('admin.php');

    $key =  'uketenhrhpunty5lhgwkcuxxxxxxxxxx';

    $pass = 'yrsofc3tg3tre7bjpfppspxxxxxxxxxx';

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

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

    $post = array();
    $post['addplan'] = 1;
    $post['plan_name']     = 'apitest2';
    $post['cplan']         = 'xcp';
    $post['disk_space']    = '5';
    $post['guaranteed_ram']= '512';
    $post['swapram']       = '512';
    $post['burst_ram']     = '';
    $post['bandwidth']     = '0';
    $post['network_speed'] = '512';
    $post['network_speed2']= '512';
    $post['cpu_units']     = '1000';
    $post['cpu_cores']     = '4';
    $post['percent_cpu']   = '50';
    $post['priority']      = '3';
    $post['ips']           = '1';

    $output = $admin->addplan($post);
    print_r($output);
?>

Returns: <syntaxhighlight lang="php"> Array (

   [title] => Add Plan
   [error] => Array
       (
           [cplan] => Please choose the Plan Type
           [plan_name] => Please specify the Name of the plan
           [disk_space] => Please specify the disk space to be allocated
           [guaranteed_ram] => Please specify the RAM memory
           [bandwidth] => Please specify the Bandwidth
           [cpu_cores] => Please specify the Number of Cores
       )
   [timenow] => 1402980477
   [time_taken] => 0.017

)