Create VPS

The Create VPS API allows you to create virtual private servers on your server. A Virtual Private Server is an instance of your physical server that appears to the user as a dedicated server. Virtualizor supports OpenVZ, Xen PV, Xen HVM, XenServer, Linux KVM, LXC, Proxmox, Virtuozzo and OpenVZ 7 virtualization. You can specify all the configurations like the virtualization type, size, RAM etc that you want for the VPS.

The storage uuid needed for VPS creation can be obtained from the List Storage API.

The API response will contain “vpsinfo” as the details of the newly created VPS on success.

HTTP Request

https://hostname:4085/index.php?act=addvs

Parameters

NameMethodValueDescriptionRequired
actGETaddvsThe action specified to retrieve data after adding the vpsYes
virtPOSTtextThe Virtualization Technology has to be specified here, refer below table for valid valuesYes
user_emailPOSTtextAdd User EmailYes
user_passPOSTtextAdd a passwordYes
hostnamePOSTtextThe hostname the VPSYes
rootpassPOSTtextThe root password for the VPSYes
slave_serverPOSTIntThe slave server ID on which vps is to be createdNo
osidPOSTIntThe ID of the Operating SystemYes
ipsPOSTarrayThe IP Address(s) for the VPSYes
spacePOSTarrayThe disk space for the VPS. In case of Multiple Disk you can specify the array as given in the example. Otherwise just value for single disk VPS is enoughYes
ramPOSTIntThe ram value in MBs for the VPSYes
bandwidthPOSTIntThe network bandwidth for the VPS: 0 (Zero) for unlimitedYes
coresPOSTIntThe number of cores allotted to the VPSYes
plidPOSTIntThe plan ID for the VPSNo
network_speedPOSTIntThe network_speed for the VPS in KB/sNo
mgsPOSTIntMedia groups IDsNo
priorityPOSTIntThe IO priority for the VPS (Only for Virtuozzo OpenVZ and Virtuozzo KVM)No
cpuPOSTIntThe CPU weight for the VPSNo
burstPOSTIntThe burst RAM for the VPS (Only for OpenVZ and Proxmox)No
cpu_percentPOSTIntThe CPU Percent time for the VPS (Only for OpenVZ and Proxmox)No
isoPOSTtextThe ISO nameNo
stidPOSTIntStorage ID on which the VPS is to be created. (Not needed if using Primary storage)No
vncPOSTIntFlag to enable vnc(0 or 1) (Only for KVM and Xen)No
vncpassPOSTtextThe vnc password (Only for KVM and Xen)No
swapramPOSTIntThe amount of SWAP for the VPS (Only for KVM, Xen, Proxmox KVM and XCP)No
shadowPOSTIntThe amount of shadow memory for the VPS (Only Xen HVM)No
hvmPOSTIntFlag to enable hvm(0 or 1)(Only for Xen HVM)No
bootPOSTtextThe boot order (dca or cda) (Only for KVM and Xen HVM)No
num_ips6POSTIntThe Number of Ipv6 Address given to the vpsNo
num_ips6_subnetPOSTIntThe Number of IPV6 Subnet to be assigned to the vpsNo
noemailPOSTIntFlag to disable email notification to VPS client only (0 or 1)No
fnamePOSTtextAdd user first nameNo
lnamePOSTtextAdd user last nameNo
uidPOSTIntSelects a unique ID of the user to which the vps will be assignedNo
dnsplidPOSTIntAdd a dns Plan to the vps. User which has selected dns plan only can use thisNo
addvpsPOST1If set the vps will be createdNo
band_suspendPOST1/0Flag to suspend the VPS networkNo
tuntapPOSTIntFlag to enable tuntap (0 or 1) (Only for OpenVZ)No
vif_typePOSTtextThe VIF type (netfront or ioemu) (Only for KVM and Xen HVM)No
nic_typePOSTtextThe NIC type (default or e1000) (Only for KVM and Xen)No
ips_intPOSTarraySet the internal ip for the vpsNo
virtioPOST1/0Flag to enable VIRTIO (0 or 1)(Only for KVM)No
kvm_cachePOSTtextThe type disk-cache mechanism can be writeback, writethrough, directsync or default (Only for KVM and Proxmox KVM)No
upload_speedPOSTIntThis will set the upload speed of the vps in KB/sNo
dnsPOSTarrayThis will assign the dns nameserver that the vps should useNo
control_panelPOSTtextThis option will install selected web control panel in the VPS types of control panel are cpanel/webuzo/plesk/webmin/inteworx/ispconfig/cwp/vestaNo
recipePOSTIntThis will execute the selected recipe after creation of VPSNo
cpupinPOSTarrayPin the particular CPU Cores to this VPS (Only for KVM, Virtuozzo KVM,Virtuozzo OpenVz, XEN)No
cpu_modePOSTtextRefer Values from below tableNo
topology_socketsPOSTIntSpecify the number of CPU Sockets to be assigned to the VPS (Only for KVM, Proxmox KVM, XCP)No
topology_coresPOSTIntSpecify the number of CPU cores to be assigned to the VPS (Only for KVM, Proxmox KVM, XCP)No
topology_threadsPOSTIntSpecify the number of CPU Threads to be assigned to the VPS (Only for KVM, Proxmox KVM, XCP)No
io_modePOSTtextSets the I/O policy for the VPS can be native/threads (Only for KVM)No
kvm_vgaPOST1/0Enables VGA for the VPS (Only for KVM)No
accelerationPOST1/0If VGA is enabled then this option will enable 2D and 3D acceleration will be for the VPSNo
disable_ebtablesPOST1/0Disable ebtables for the VPSNo
rdpPOST1/0Enable Remote Desktop Connection (For Windows VPS)No
vnc_keymapPOSTtextAllows to select keymap can be ‘en-us’, ‘de-ch’, ‘ar’, ‘da’, ‘et’, ‘fo’, ‘fr-be’, ‘fr-ch’, ‘hu’, ‘it’, ‘lt’, ‘mk’, ‘nl’, ‘no’, ‘pt’, ‘ru’, ‘sv’, ‘tr’, ‘de’, ‘en-gb’, ‘es’, ‘fi’, ‘fr’, ‘fr-ca’, ‘hr’, ‘is’, ‘ja’, ‘lv’, ‘nl-be’, ‘pl’, ‘pt-br’, ‘sl’, ‘th’No
osreinstall_limitPOSTIntIf you want to limit the number of OS re-installs per month.Eg. 0 – is unlimitedNo
admin_managedPOST1/0If checked, VPS can not be managed from Enduser panelNo
disable_nw_configPOST1/0If checked, Virtualizor will not configure/re-write network when a VPS is rebooted. However, during creation of the VPS, the network file will be writtenNo

Virtualization Type Values

(xen | xenhvm | xcp | xcphvm | openvz | kvm | lxc | vzo | vzk | proxo | proxk | proxl)

CPU Mode values for KVM

( host-model | host-passthrough )

CPU Mode values for Proxmox KVM

( host-model | host-passthrough | 486 | athlon | pentium | pentium2 | pentium3 | coreduo | core2duo | kvm32 | qemu32 | qemu64 | phenom | Conroe | Penryn | Nehalem | SandyBridge | IvyBridge | Haswell | Broadwell | Opteron_G1 | Opteron_G2 | Opteron_G3 | Opteron_G4 | Opteron_G5 )

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['serid'] = 0;
    $post['slave_server'] = 1; // Pass the slave server ID if you want to create VPS on the Slave Server
    $post['virt'] = 'kvm';
    $post['uid'] = 0;
    $post['user_email'] = 'test@test.com';
    $post['user_pass'] = 'test123';
    $post['fname'] = '';
    $post['lname'] = '';
    $post['plid'] = 0;
    $post['osid'] = 88;
    $post['hostname'] = 'test12345.com';
    $post['rootpass'] = 'test123';
    $post['ips'] = array('192.168.111.49');
    $post['num_ips6'] = 0;
    $post['num_ips6_subnet'] = 0;
    $post['stid'] = 1;
    $post['space'] = array(0=>array(
                            'size' => 2,
                            'st_uuid'=>'ngavdbegidnbme2d'),
                        1=>array(
                            'size'=>2,
                            'st_uuid'=>'ngavdbegidnbme2d')); //For VPS with Multi-Disk
    $post['ram'] = 1024;
    $post['swapram'] = 0;
    $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['kvm_cache'] = 0;
    $post['io_mode'] = 0;
    $post['vnc_keymap'] = 'en-us';
    $post['nic_type'] = 'default';
    $post['osreinstall_limit'] = 0;

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

    print_r(json_encode($output));
?>

Output

{
  "title": "Add Virtual Server",
  "error": [],
  "vs_info": {
    "uuid": "1iq2vt2ih9ankjuo",
    "pass": "test123",
    "plid": 0,
    "hostname": "test12345.com",
    "space": 4,
    "ram": 1024,
    "bandwidth": 0,
    "network_speed": 0,
    "upload_speed": -1,
    "cores": 4,
    "cpupin": -1,
    "uid": "58",
    "io": 0,
    "burst": 0,
    "cpu_percent": 100,
    "swap": 1024,
    "acpi": 1,
    "apic": 1,
    "pae": 1,
    "vnc": 1,
    "vncport": 0,
    "shadow": 0,
    "virt": "kvm",
    "hvm": 0,
    "iso": "",
    "boot": "cda",
    "band_suspend": 0,
    "speed_cap_down": 0,
    "speed_cap_up": 0,
    "tuntap": 0,
    "ppp": 0,
    "mac_status": 0,
    "osreinstall_limit": 0,
    "mg": [],
    "kvm_cache": "0",
    "io_mode": "0",
    "vnc_keymap": "en-us",
    "virtio": 0,
    "numa": 0,
    "cpu_mode": "",
    "admin_managed": 0,
    "rdp": 0,
    "disable_nw_config": 0,
    "topology_sockets": 0,
    "topology_cores": 0,
    "topology_threads": 0,
    "openvz_features": "",
    "bpid": 0,
    "install_xentools": 0,
    "sec_iso": "",
    "mac": "",
    "osid": 270,
    "cpu": 1000,
    "kvm_vga": 0,
    "acceleration": 0,
    "vncpass": "test123",
    "disable_ebtables": 0,
    "webuzo": 0,
    "nic_type": "default",
    "vif_type": "netfront",
    "vps_name": "v1004",
    "ubc": "",
    "vpsid": "46",
    "disks": [
      {
        "primary": 1,
        "path": "/dev/vg/vsv1004-drhuczo0bfzvsdmi-1iq2vt2ih9ankjuo",
        "st_uuid": "ngavdbegidnbme2d",
        "type": "block",
        "size": "2",
        "size_unit": "",
        "vpsid": "46",
        "rescue": 0,
        "target_name": "",
        "format": "raw",
        "disk_uuid": "drhuczo0bfzvsdmi",
        "num": 0
      },
      {
        "primary": 0,
        "path": "/dev/vg/vsv1004-dzvpdxvr1ozesum0-1iq2vt2ih9ankjuo",
        "st_uuid": "ngavdbegidnbme2d",
        "type": "block",
        "size": "2",
        "size_unit": "",
        "vpsid": "46",
        "rescue": 0,
        "target_name": "",
        "format": "raw",
        "disk_uuid": "dzvpdxvr1ozesum0",
        "num": 1
      }
    ],
    "ips": [
      "8.8.8.65"
    ],
    "ipv6": [],
    "ipv6_subnet": [],
    "ips_int": []
  },
  "globals": {
    "cookie_name": "SIMCookies7614"
  }
}
Was this helpful to you?