Server Groups are possible only in case of a Cluster setup of Virtualizor Servers. The Add Server Groups API allows you to create server groups as per the locations of the servers. The API response will contain "done" as "1" after successful creation of the server groups.
These Server groups allow you to differentiate between multiple servers which can be very useful during the billing process. For example, Lets say you have 10 Servers in the USA and 5 in Europe. You can create two groups which can be used in the Billing Module for creating seperate orders.
For more information, please refer this Server Groups guide.
HTTP Request
https://hostname:4085/index.php?act=addsg
Parameters
Name | Method | Value | Description | Required |
---|---|---|---|---|
act | GET | addsg | The action specified to perform operation and return "done" as "1" after the server group has been added successfully | Yes |
addsg | POST | 1/0 | Flag to add Server Group | Yes |
sg_name | POST | text | Server Group Name | Yes |
sg_reseller_name | POST | text | The name that will be shown to resellers | No |
sg_desc | POST | text | Description of the Group | No |
sg_select | POST | 1/0 | Server Selection (0 for Least Utilized and 1 for First Available) | No |
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['addsg'] = 1;
$post['sg_name'] = 'test_sg';
$post['sg_reseller_name'] = 'US';
$post['sg_desc'] = 'This is just test';
$post['sg_select'] = 0;
$output = $admin->addsg($post);
print_r(json_encode($output));
?>
Output
{
"title": "Add Server Group / Regions",
"done": 4, //Server group ID
"timenow": 1535486540,
"time_taken": "0.214"
}