Add Server

Virtualizor support Central Management of many Nodes / Servers so that you can access and create VPS from the Master server only. You can slave an existing Virtualizor Server and deslave it any time. The master interacts with the slave only when necessary. The slave just becomes a extra resource for the master. The Virtualization Type will be detected by the Master itself. Also the MASTER can be OF ANY VIRTUALIZATION type i.e. OpenVZ, Xen or Linux KVM. The Add Server API allows you to add slave server to the master server. The API response will return “saved” as “true” after the server is successfully added.

The Slave server must have Virtualizor installed.

For more information, please refer this Server Clustering guide.

HTTP Request

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

Parameters

NameMethodValueDescriptionRequired
actGETaddserverThe action to add the server to a clusterYes
server_namePOSTtextThe server name that will be given while addingYes
ipPOSTtextIP address of the server to be addedYes
passPOSTtextThe API password of the serverYes
sgidPOSTIntThe server group to which the server will be addedYes
lockedPOST1/0The flag value to decide whether the server will be locked or notNo
internal_ipPOSTtextThe internal ip will be assigned to the serverNo

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['server_name'] = 'Slave_server';
    $post['ip'] = 'slave_ip';
    $post['pass'] = 'slave_api_pass';
    $post['sgid'] = 0;

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

    print_r(json_encode($output));
?>

Output

{
    "title": "Add Server",
    "saved": "true",
    "servergroups": {
        "0": {
            "sgid": "0",
            "sg_name": "sg_test",
            "sg_reseller_name": "sg_region",
            "sg_desc": "This is just desc",
            "sg_select": "0"
        },
        "15": {
            "sgid": "15",
            "sg_name": "testlocal",
            "sg_reseller_name": "Local_test",
            "sg_desc": "",
            "sg_select": "0"
        }
    },
    "timenow": "1474850356",
    "time_taken": "1.827"
}
Was this helpful to you?