Skip to main content

System hosts

Add a new host

Request Structure:

http://<cluster>:<port>/api/system/hosts/set

Post data:

access_token = <access_token>
ip = 1.2.3.4
hostname = docluster.com

The response from the server:

{
 "msg": {
  "1.2.3.4": [
   "ducluster.com"
  ]
 },
 "status": "success",
 "error": ""
}

Errors:

-hostname already added
-wrong IP or hostname format

Example:

import requests
import json

api_url = "http://<IP>:<PORT>/api/"
access_token = 'BLABLALBA'

path = 'system/hosts/set'
data = {
        'ip': '1.2.3.4',
        'hostname': 'clastercp.com'
}

def send(path, data):
    data['access_token'] = access_token
    send = requests.post(url=api_url + path, data=data)
    print(send.text)
    
send(path, data)

 

Delete host from hosts

Request Structure:

http://<cluster>:<port>/api/system/hosts/delete

Post data:

access_token = <access_token>
ip = 1.2.3.4
hostname = docluster.com

The response from the server:

{
 "msg": {},
 "status": "success",
 "error": ""
}

Errors:

-wrong IP or hostname format
-ip not definite in hosts

Example:

import requests
import json

api_url = "http://<IP>:<PORT>/api/"
access_token = 'BLABLALBA'

path = 'system/hosts/delete'
data = {
        'ip': '1.2.3.4',
  		'hostanme': 'docluster.com'
}

def send(path, data):
    data['access_token'] = access_token
    send = requests.post(url=api_url + path, data=data)
    print(send.text)
    
send(path, data)

 

Get all hosts

Request Structure:

http://<cluster>:<port>/api/system/users/get

Post data:

access_token = <access_token>

The response from the server:

{
 "msg": {
  "1.2.3.1": [
   "node-1",
   "node-1.docluster.com"
  ],
  "1.2.3.2": [
   "node-2",
   "node-2.docluster.com"
  ],
  "1.2.3.3": [
   "node-3",
   "node-3.docluster.com"
  ],
  "1.2.3.4": [
   "node-4",
   "node-4.docluster.com"
  ],
  "1.2.3.5": [
   "node-5",
   "node-5.docluster.com"
  ]
 },
 "status": "success",
 "error": ""
}

Errors:

Example:

import requests
import json

api_url = "http://<IP>:<PORT>/api/"
access_token = 'BLABLALBA'

path = 'system/hosts/get'
data = {}

def send(path, data):
    data['access_token'] = access_token
    send = requests.post(url=api_url + path, data=data)
    print(send.text)
    
send(path, data)