Get Virtualizor

List Servergroups

Use the List Servergroups API to list information about the server groups. The API response contains the list of the server groups, which are listed according to their IDs. To filter the list, you can specify "sg_name" which is the server group name.

Server Groups are possible only in case of a Cluster setup of Virtualizor Servers. 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 separate orders.

For more information, please refer this Server Groups guide.

HTTP Request

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

Parameters

NameMethodValueDescriptionRequired
actGETservergroupsThe action specified to list the server groupsYes
sg_namePOSTtextFilter the list using servergroup's nameNo

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['sg_name'] = 'test_sg';

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

    print_r(json_encode($output));
?>

Output

{
	"title": "Server Groups / Regions",
	"servergroups": {
		"0": {
			"sgid": 0,
			"sg_name": "Default",
			"sg_reseller_name": "Default",
			"sg_desc": "Default Group",
			"sg_select": 0,
			"totalservers": 1,
			"servers": [
				"localhost"
			]
		},
		"2": {
			"sgid": "2",
			"sg_name": "test_sg",
			"sg_reseller_name": "US",
			"sg_desc": "Test Group",
			"sg_select": "0",
			"sg_ha": "1",
			"totalservers": 1,
			"servers": [
				"test"
			]
		}
	},
	"timenow": 1535543450,
	"time_taken": "0.225"
}
    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list