Use Create VM API to create new VPS on your server.
This function is for cloud user
Parameters
Parameters | Type | Value | Description |
---|---|---|---|
act | GET | create | The action will create vps instance for a particular user |
virt | POST | virt | The virtualization to be specified relevant to which the vps will be created. |
sgid | POST | Int | The server group where the vps will created and assigned. |
rootpass | POST | rootpass | The root password that will be set for the vps |
hostname | POST | hostname | Hostname for the vps will be set |
space | POST | Int | This will set the disk space for the vps. Also it will assign the disk space comparing with the space the individual user has declared |
ram | POST | Int | This will set the RAM for the vps. Also it will assign the RAM comparing with the RAM the individual user has declared |
burst | POST | Int | This is similar to swap ram and will use the disk space to create swap.(For OpenVZ) |
swapram | POST | Int | This will use the disk space to create swap.(FOR KVM, Xen, XenServer) |
bandwidth | POST | Int | This will assign the bandwidth to the vps and will also check available bandwidth that is assigned to the user |
uid | POST | Int | The user id under whom the vps will be created |
cpu | POST | Int | The cpu weight that has been assigned to the user |
cpu_percent | Int | The cpu share in % that will be assigned to the vps. | |
cores | POST | Int | Number of CPU cores that will be used by the vps.Assigned at the time of creation. |
ips | POST | Int | Number of ipv4 addresses that will be assigned to the vps |
ips_int | POST | Int | Number of internal ip addresses that will be assigned to the vps |
ipv6 | POST | Int | Number of ipv6 addresses that will be assigned to the vps |
ipv6_subnet | POST | Int | Number of ipv6 subnet that will be assigned to the vps |
vnc | POST | 1/0 | IF set then vnc will be set for the vps. |
vncpass | POST | vncpass | VNC password will be set automatically |
shadow | POST | Int | Used for Xen HVM. This sets the shadow memory for the vps. |
iso | POST | iso | Create vps using iso present on the server |
boot | POST | boot | Sets the boot order in the vps |
tuntap | POST | Int | If set then tuntap will be enabled.(For OpenVZ) |
io | POST | Int | If set then io priority for the vps will be enabled.(For OpenVZ) |
band_suspend | POST | 1/0 | If set then vps will be suspended if the bandwidth limit is exceeded. |
osreinstall_limit | POST | Int | This sets the value for limit for OS reinstallation. |
osid | POST | Int | This will assign the osid to the vps for installing OS template. |
mg | POST | mg | IF this is set then the OS template belonging to the media group will be displayed |
nic | POST | string | Provide Virtual Network Interface Type |
ssh_options | POST | Int | Provide one of these ssh_options: add_ssh_keys, generate_keys, use_ssh_keys, we have provided detailed information about these options below |
sshkey | POST | Int | Provide public ssh key |
private_key | POST | Int | Provide private key (compulsory if generate_keys is passed in ssh_options) |
existing_key | POST | array | Provide an array of public key (compulsory if use_ssh_keys is passed in ssh_options) |
bios | POST | String | Provide bios seabios/uefi (Default is seabios) will be applied only while booting with iso.(KVM ONLY) |
addvs | POST | 1 | IF set then the vps will be created. |
ssh options
There are three types of ssh_options which are described below:
1. add_ssh_keys : Pass your own public ssh key in post to add that ssh key in your vps.
2. generate_keys : If you want to create new pair of keys then you will first need to generate using the following link:
https://www.virtualizor.com/docs/enduser-api/generate-keys/
Once you have made the pair you will need to pass it to the ADDVS calls using following variables :
$post[sshkey'] = 'PUBLIC_KEY';
$post['private_key '] = 'PRIVATE_KEY';
3. use_ssh_keys :If you want to use existing key then first you will need to get list of sshkey using the following link:
https://www.virtualizor.com/docs/enduser-api/list-ssh-keys/
Once you have made the pair you will need to pass it to the ADDVS calls using following variables :
$post[existing_key'][] = 'PUBLIC_KEY 1';
$post['existing_key '][] = 'PUBLIC_KEY 2';
PHP
<?php
require_once('/usr/local/virtualizor/sdk/enduser.php');
$key = 'your_api_key';
$pass = 'your_api_pass';
$ip = 'host_ip';
$admin = new Virtualizor_Enduser_API($ip, $key, $pass);
$post = array();
$post['virt'] = 'kvm';
$post['sgid'] = 0;
$post['rootpass'] ='test123';
$post['hostname'] = 'testcloud' ;
$post['space'] = 2 ;
$post['ram'] = 1024;
$post['swapram'] = 1024;
$post['bandwidth'] = 0;
$post['uid'] = 368;
$post['cores'] = 2;
$post['ips'] = 1;
$post['vnc'] = 1;
$post['vncpass'] = 'testvnc';
$post['band_suspend'] = 1;
$post['osreinstall_limit'] = 0;
$post['osid'] = 272;
$post['addvs'] = 1;
$output = $admin->create($post);
print_r(json_encode($output));
?>
Output
{
"uid": "372",
"act": "create",
"timezone": 1,
"timenow": "October 2, 2016, 2:09 am",
"vpsid": "3588",
"username": "test@test.com",
"user_type": "2",
"preferences": {
"fname": "test",
"lname": "test",
"theme": "default",
"language": "english",
"timezone": 1
},
"url": "index.php?",
"rdns": {
"pdnsid": "12"
},
"pdns": {
"pdnsid": "12"
},
"support_link": "http://softaculous.com",
"disable_login_logo": 1,
"title": "Launch Instance",
"resources": {
"num_vs": 99999,
"num_users": 15,
"space": 46,
"ram": 1024,
"burst": 1024,
"bandwidth": 1000000,
"num_ipv4": 49,
"num_ipv6_subnet": 0,
"num_ipv6": "0",
"cores": "8",
"num_cores": 9996,
"network_speed": "0",
"upload_speed": "0",
"allowed_virts": {
"kvm": "kvm"
},
"cloud_allow_virtio": 1
},
"usage": {
"num_cores": 4
},
"users": {
"372": {
"uid": "372",
"email": "test@test.com"
}
},
"ostemplates": {
"272": {
"osid": "272",
"type": "kvm",
"name": "centos-6.5-x86_64",
"filename": "centos-6.5-x86_64.img",
"size": "1074855936",
"pygrub": "0",
"drive": "",
"hvm": "0",
"perf_ops": "1",
"active": "1",
"url": "http://files.virtualizor.com/ostemplates.php?osid=272",
"distro": "centos",
"Nvirt": "kvm"
},
"334": {
"osid": "334",
"type": "kvm",
"name": "centos-7.0-x86_64",
"filename": "centos-7.0-x86_64.img",
"size": "1291845632",
"pygrub": "0",
"drive": "",
"hvm": "0",
"perf_ops": "1",
"active": "1",
"url": "http://files.virtualizor.com/ostemplates.php?osid=334",
"distro": "centos",
"Nvirt": "kvm",
"mg": [16]
},
"347": {
"osid": "347",
"type": "kvm",
"name": "centos-6.6-x86_64",
"filename": "centos-6.6-x86_64.img",
"size": "1074855936",
"pygrub": "0",
"drive": "",
"hvm": "0",
"perf_ops": "1",
"active": "1",
"url": "http://files.virtualizor.com/ostemplates.php?osid=347",
"distro": "centos",
"Nvirt": "kvm"
},
"381": {
"osid": "381",
"type": "kvm",
"name": "centos-7.1-x86_64",
"filename": "centos-7.1-x86_64.img",
"size": "1074855936",
"pygrub": "0",
"drive": "",
"hvm": "0",
"perf_ops": "1",
"active": "1",
"url": "http://files.virtualizor.com/ostemplates.php?osid=381",
"distro": "centos",
"Nvirt": "kvm"
},
"399": {
"osid": "399",
"type": "kvm",
"name": "debian-8.0-x86_64",
"filename": "debian-8.0-x86_64.img",
"size": "1073741824",
"pygrub": "0",
"drive": "",
"hvm": "0",
"perf_ops": "1",
"active": "1",
"url": "http://files.virtualizor.com/ostemplates.php?osid=399",
"distro": "debian",
"Nvirt": "kvm"
},
},
"isos": {
"debian-8.0.0-amd64-netinst.iso": {
"iso": "debian-8.0.0-amd64-netinst.iso",
"mg": [17],
"name": "debian-8.0.0-amd64-netinst.iso",
"filename": "debian-8.0.0-amd64-netinst.iso",
"size": 257949696,
"distro": "debian"
},
"latest-virtio-win.iso": {
"iso": "latest-virtio-win.iso",
"mg": "",
"name": "latest-virtio-win.iso",
"filename": "latest-virtio-win.iso",
"size": 56606720,
"distro": "test"
},
},
"servergroups": [{
"sgid": 0,
"sg_name": "test",
"sg_reseller_name": "region",
"sg_desc": "This is just desc",
"sg_select": 0,
"virts": {
"kvm": "kvm",
"openvz": "openvz"
}
}],
"done": {
"done": "3589",
"msg": "The Virtual Server has been created",
"goto": "act=listvs"
},
"done_msg": "The Virtual Server has been created",
"newvs": {
"type": "kvm",
"sgid": 0,
"rootpass": "test123",
"hostname": "test_api",
"space": 4,
"ram": 1024,
"burst": 0,
"swapram": 1024,
"bandwidth": 0,
"uid": 372,
"cores": 4,
"num_ipv4": 1,
"num_ipv6": 0,
"num_ipv6_subnet": 0,
"vnc": 1,
"vncpass": "kt6lormd",
"shadow": 0,
"iso": "",
"boot": "cda",
"band_suspend": 1,
"tuntap": 0,
"osreinstall_limit": 0,
"mg": "",
"osid": 347,
"virtio": 0,
"node_select": 1,
"server_group": 0,
"num_ips": 1,
"num_ips6": 0,
"num_ips6_subnet": 0,
"addvps": 1,
"vpsid": "3589",
"ips": ["10.10.100.6"],
"ips6": [],
"ipv6_subnet": []
},
"res_limit": {
"num_vs": "100000",
"num_users": "15",
"space": "50",
"ram": "2048",
"bandwidth": "1000000",
"num_ipv4": "50",
"num_ipv6_subnet": "0",
"num_ipv6": "0",
"num_cores": "10000",
"cores": "8"
},
"virts": {
"openvz": "openvz",
"xen": "xen",
"xenhvm": "xenhvm",
"kvm": "kvm",
"xcp": "xcp",
"xcphvm": "xcphvm",
"lxc": "lxc"
},
"virt_lang": {
"openvz": "OpenVZ",
"xen": "Xen",
"xenhvm": "Xen HVM",
"kvm": "KVM",
"xcp": "XCP",
"xcphvm": "XCP HVM",
"lxc": "LXC"
},
"time_taken": "3.119"
}