API Create VPS

From Virtualizor Wiki
Jump to: navigation, search

Create a VPS

Parameters Description
rootpass The root password for the VPS
virt The Virtualization Technology ( kvm / openvz / xen / xcp )
plid The plan id for the VPS
hostname The hostname the VPS
space The disk space for the VPS
ram The ram for the VPS
bandwidth The network bandwidth for the VPS
network_speed The network_speed for the VPS
cores The number of cores allotted to the VPS
osreinstall_limit The number of times the user can reinstall the OS
mgs Media groups ids (optional)
mac The MAC Address for the VPS (Only for Xen and KVM)
priority The IO priority for the VPS (Only for OpenVZ)
cpu The CPU weight for the VPS
burst The burst RAM for the VPS (Only for OpenVZ)
cpu_percent The CPU Percent time for the VPS (Only for OpenVZ and Xen)
osid The id of the Operating System
iso The ISO name
stid Storage ID on which the VPS is to be created. (Not needed if using Primary storage)
cpu The CPU weight for the VPS
tuntap Flag to enable tuntap (0 or 1) (Only for OpenVZ)
vnc Flag to enable vnc(0 or 1) (Only for KVM and Xen)
vncpass The vnc password (Only for KVM and Xen)
swapram The amount of SWAP for the VPS (Only for KVM and Xen)
shadow The amount of shadow memory for the VPS (Only Xen HVM)
virtio Flag to enable VIRTIO (0 or 1)(Only for KVM)
nic_type The NIC type (default or e1000) (Only for KVM and Xen)
vif_type The VIF type (netfront or ioemu) (Only for KVM and Xen HVM)
hvm Flag to enable hvm(0 or 1)(Only for Xen HVM)
band_suspend Flag to suspend the VPS network (0 or 1)
boot The boot order (dca or cda) (Only for KVM and Xen HVM)
ips The IP Address(s) for the VPS (Array)
noemail Flag to disable email notification to VPS client only (0 or 1)
admin_managed Flag to enable Managed By Admin (0 or 1)
addvps Set value to 1 to create vps


Example Code

<?php

    require_once('admin.php');

    $key =  'uketenhrhpunty5lhgwkcuxxxxxxxxxx';

    $pass = 'yrsofc3tg3tre7bjpfppspxxxxxxxxxx';

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

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

    //Add the below block of code for creating VPS on Slave Server

    /*
    $empty = array();
    //To fetch data, pass empty arrays
    $data = $admin->addvs($empty, $empty);
    $cookies[$data['globals']['cookie_name'].'_server'] = 1; //Slave Serid
    */

    $post = array();
    $post['serid'] = 0;
    $post['virt'] = 'kvm';
    $post['user_email'] = 'test@test.com';
    $post['user_pass'] = 'test123';
    $post['plid'] = 0;
    $post['osid'] = 88;
    $post['iso'] = 0;
    $post['hostname'] = 'test12345.com';
    $post['rootpass'] = 'test123';
    $post['ips'] = array('192.168.111.49');
    $post['stid'] = 1;
    $post['space'] = 5;
    $post['ram'] = 1024;
    $post['swapram'] = 1024;
    $post['bandwidth'] = 0;
    $post['network_speed'] = 0;
    $post['cpu'] = 1000;
    $post['cores'] = 4;
    $post['cpu_percent'] = 100.00;
    $post['vnc'] = 1;
    $post['vncpass'] = 'test123';
    $post['sec_iso'] = 0;
    $post['kvm_cache'] = 0;
    $post['io_mode'] = 0;
    $post['vnc_keymap'] = 'en-us';
    $post['nic_type'] = 'default';
    $post['osreinstall_limit'] = 0; 
    $post['admin_managed'] = 0;
    $post['addvps'] = 1;

    $output = $admin->addvs($post);
    
    //Use this call instead if creating VPS on Slave Server
    //$output = $admin->addvs($post, $cookies);

    print_r($output);
?>

Returns:

Array
(
    [title] => Add Virtual Server
    [error] => Array
        (
        )
    [vs_info] => Array
        (
            [pass] => test123
            [plid] => 0
            [hostname] => test12345.com
            [space] => 5
            [ram] => 1024
            [bandwidth] => 0
            [network_speed] => 0
            [cores] => 4
            [uid] => 55
            [io] => 0
            [burst] => 0
            [cpu_percent] => 100
            [swap] => 1024
            [acpi] => 1
            [apic] => 1
            [pae] => 1
            [vnc] => 1
            [shadow] => 0
            [hvm] => 0
            [iso] => 
            [boot] => cda
            [band_suspend] => 0
            [tuntap] => 0
            [ppp] => 0
            [mac_status] => 0
            [osreinstall_limit] => 0
            [mg] => Array
                (
                )
            [webuzo] => 0
            [kvm_cache] => 0
            [io_mode] => 0
            [vnc_keymap] => en-us
            [mac] => 
            [osid] => 88
            [cpu] => 1000
            [sec_iso] => 
            [vncpass] => test123
            [nic_type] => default
            [vps_name] => 1028
            [ubc] => 
            [vpsid] => 1010
            [ips] => Array
                (
                    [0] => 192.168.11.4
                )
            [ipv6] => Array
                (
                )
            [admin_managed] => 0
        )
)