API Slave Server

From Virtualizor Wiki
Jump to: navigation, search
NOTE
This is OLD API Documentation. Click on the following link for New API Documentation
Admin API

Add a Slave server

Parameters Description
addserver Confirmation to Add Server
server_name Name of the Slave Server
ip The IP of the slave server
pass The API pass of Slave Server
sgid The Server group Id in which the Slave server is to be added
locked If TRUE, no new VPS will be created on this server
internal_ip Set Internal IP for Cloud Server(s). (Optional)

Example Code

<?php

    require_once('admin.php');

    $key =  'uketenhrhpunty5lhgwkcuxxxxxxxxxx';

    $pass = 'yrsofc3tg3tre7bjpfppspxxxxxxxxxx';

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

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

    $post = array();
    $post['addserver'] = 1;
    $post['server_name'] = 'testapi';
    $post['ip'] = '127.0.99.20';
    $post['pass'] = '4gsdgfdfs1sd1f3dfsd';
    $post['sgid'] = 0;
    $post['locked'] = TRUE;
    $post['internal_ip'] = '';

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

Returns: <syntaxhighlight lang="php"> Array (

   [title] => Add Server
   [saved] => 1
   [servergroups] => Array
       (
           [0] => Array
               (
                   [sgid] => 0
                   [sg_name] => Default
                   [sg_desc] => Default Group
                   [sg_select] => 0
               )
           [2] => Array
               (
                   [sgid] => 2
                   [sg_name] => Group 1 [ US East ]
                   [sg_desc] => Group 1 [ US East ] description
                   [sg_select] => 0
               )
       )
   [timenow] => 1402984383
   [time_taken] => 1.295

)