Get Virtualizor

Create VM

Use Create VM API to create new VPS on your server.

This function is for cloud user

HTTP Request

https://hostname:4083/index.php?act=create

Parameters

ParametersTypeValueDescription
actGETcreateThe action will create vps instance for a particular user
virtPOSTvirtThe virtualization to be specified relevant to which the vps will be created.
sgidPOSTIntThe server group where the vps will created and assigned.
rootpassPOSTrootpassThe root password that will be set for the vps
hostnamePOSThostnameHostname for the vps will be set
spacePOSTIntThis will set the disk space for the vps. Also it will assign the disk space comparing with the space the individual user has declared
ramPOSTIntThis will set the RAM for the vps. Also it will assign the RAM comparing with the RAM the individual user has declared
burstPOSTIntThis is similar to swap ram and will use the disk space to create swap.(For OpenVZ)
swapramPOSTIntThis will use the disk space to create swap.(FOR KVM, Xen, XenServer)
bandwidthPOSTIntThis will assign the bandwidth to the vps and will also check available bandwidth that is assigned to the user
uidPOSTIntThe user id under whom the vps will be created
cpuPOSTIntThe cpu weight that has been assigned to the user
cpu_percentIntThe cpu share in % that will be assigned to the vps.
coresPOSTIntNumber of CPU cores that will be used by the vps.Assigned at the time of creation.
ipsPOSTIntNumber of ipv4 addresses that will be assigned to the vps
ips_intPOSTIntNumber of internal ip addresses that will be assigned to the vps
ipv6POSTIntNumber of ipv6 addresses that will be assigned to the vps
ipv6_subnetPOSTIntNumber of ipv6 subnet that will be assigned to the vps
vncPOST1/0IF set then vnc will be set for the vps.
vncpassPOSTvncpassVNC password will be set automatically
shadowPOSTIntUsed for Xen HVM. This sets the shadow memory for the vps.
isoPOSTisoCreate vps using iso present on the server
bootPOSTbootSets the boot order in the vps
tuntapPOSTIntIf set then tuntap will be enabled.(For OpenVZ)
ioPOSTIntIf set then io priority for the vps will be enabled.(For OpenVZ)
band_suspendPOST1/0If set then vps will be suspended if the bandwidth limit is exceeded.
osreinstall_limitPOSTIntThis sets the value for limit for OS reinstallation.
osidPOSTIntThis will assign the osid to the vps for installing OS template.
mgPOSTmgIF this is set then the OS template belonging to the media group will be displayed
nicPOSTstringProvide Virtual Network Interface Type
ssh_optionsPOSTIntProvide one of these ssh_options: add_ssh_keys,
generate_keys, use_ssh_keys, we have provided detailed information about these options below
sshkeyPOSTIntProvide public ssh key
private_keyPOSTIntProvide private key (compulsory if generate_keys is passed in ssh_options)
existing_key POSTarrayProvide an array of public key (compulsory if use_ssh_keys is passed in ssh_options)
biosPOSTStringProvide bios seabios/uefi (Default is seabios)
will be applied only while booting with iso.(KVM ONLY)
addvsPOST1IF 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';

Sample Code

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));
?>

Curl

curl -k -X POST -d "addvs=1&virt=kvm&rootpass=test123&hostname=test_api&
space=4&ram=1024&swap=1024&bandwidth=0&uid=372&cpu=1024&
cores=4&ips=1&vnc=1&osid=347"
-L "https://hostname:4083/index.php?act=create&
api=json&apikey=your_api_key&apipass=your_api_pass"

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"
}
    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list