system

System users

Сreate a new user

Request Structure:

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

Post data:

access_token = <access_token>
username = testuser
password = testpass

The response from the server:

{
 "msg": {
  "testuser": {
   "password": "179ad45c6ce2cb97cf1029e212046e81"
  }
 },
 "status": "success",
 "error": ""
}

Errors:

-user already exists
-username and password must not be empty

Example:

import requests
import json

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

path = 'system/users/add'
data = {
        'username': 'testuser',
        'password': 'testpass'
}

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 user

Request Structure:

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

Post data:

access_token = <access_token>
username = testuser

The response from the server:

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

Errors:

-user does not exist
-Can not delete last user

Example:

import requests
import json

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

path = 'system/users/delete'
data = {
        'username': 'testuser'
}

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

 

Set new user data

Request Structure:

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

Post data:

access_token = <access_token>
username = testuser
password = newtestpass
email = testuser@clastercp.com

The response from the server:

{
 "msg": {
  "testuser": {
   "password": "37b032c83f249979fc5db9b0b391ef4a",
   "email": "testuser@clastercp.com"
  }
 },
 "status": "success",
 "error": ""
}

Errors:

-user does not exist

Example:

import requests
import json

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

path = 'system/users/set'
data = {
        'username': 'testuser',
        'password': 'newtestpass',
        'email': 'testuser@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)

 

Get user data

Request Structure:

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

Post data:

access_token = <access_token>
username = testuser

The response from the server:

{
 "msg": {
  "testuser": {
   "password": "37b032c83f249979fc5db9b0b391ef4a",
   "email": "testuser@clastercp.com"
  }
 },
 "status": "success",
 "error": ""
}

Errors:

-user does not exist

Example:

import requests
import json

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

path = 'system/users/get'
data = {
        'username': 'testuser'
}

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 users data

Request Structure:

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

Post data:

access_token = <access_token>

The response from the server:

{
 "msg": {
  "admin": {
   "password": "21232f297a57a5a743894a0e4a801fc3"
  },
  "testuser": {
   "password": "37b032c83f249979fc5db9b0b391ef4a",
   "email": "testuser@clastercp.com"
  }
 },
 "status": "success",
 "error": ""
}

Errors:

Example:

import requests
import json

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

path = 'system/users/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)

 

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)

 

System config

get|save|read config

get - Returns the current configuration

save - Writes the configuration to a file and changes the configuration number to 1 up. Returns the current configuration

read - Read a configuration from a file. Returns the current configuration.

Request Structure:

http://<cluster>:<port>/api/system/config/<get|save|read>

Post data:

access_token = <access_token>

The response from the server:

{
 "msg": {
  "version": 2,
  "system": {
   "users": {
    "admin": {
     "password": "21232f297a57a5a743894a0e4a801fc3"
    }
   }
  },
  "cluster": {
   "name": "DoCluster",
   "nodes": {
    "node-2.docluster.com": {
     "machine": "x86_64",
     "API_key": "ippowcalrksmufirthcntewujgndhy",
     "MNG_IP": "192.168.129.82"
    },
    "node-3.docluster.com": {
     "machine": "x86_64",
     "API_key": "ikdeiwnlhtswnxxuybfssxzoknhiyb",
     "MNG_IP": "192.168.129.83"
    },
    "node-4.docluster.com": {
     "machine": "x86_64",
     "API_key": "rwlozmuxekgqxahwzxsenbdmgaejvy",
     "MNG_IP": "192.168.129.84"
    }
   }
  },
  "quorum": {
   "nodes": [
    "node-2.docluster.com",
    "node-3.docluster.com",
    "node-4.docluster.com"
   ]
  }
 },
 "status": "success",
 "error": ""
}
{
 "version": 2,
 "system": {
  "users": {
   "admin": {
    "password": "21232f297a57a5a743894a0e4a801fc3"
   }
  }
 },
 "cluster": {
  "name": "DoCluster",
  "nodes": {
   "node-2.docluster.com": {
    "machine": "x86_64",
    "API_key": "ippowcalrksmufirthcntewujgndhy",
    "MNG_IP": "192.168.129.82"
   },
   "node-3.docluster.com": {
    "machine": "x86_64",
    "API_key": "ikdeiwnlhtswnxxuybfssxzoknhiyb",
    "MNG_IP": "192.168.129.83"
   },
   "node-4.docluster.com": {
    "machine": "x86_64",
    "API_key": "rwlozmuxekgqxahwzxsenbdmgaejvy",
    "MNG_IP": "192.168.129.84"
   }
  }
 },
 "quorum": {
  "nodes": [
   "node-2.docluster.com",
   "node-3.docluster.com",
   "node-4.docluster.com"
  ]
 }
}

Errors:

Example:

import requests
import json

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

path = 'system/config/<get|save|read>'
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)

 

 

System loops

get loops

get - Returns the current status of all running software loops.

Request Structure:

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

Post data:

access_token = <access_token>

The response from the server:

{
 "msg": {
  "quorum-Loop_QuorumStatus": {
   "isAlive": true,
   "counter": 19,
   "ident": "140645146556160",
   "native_id": "23681",
   "timeout": "3"
  },
  "cluster-Loop_NodesStatus": {
   "isAlive": true,
   "counter": 15,
   "ident": "140645138163456",
   "native_id": "23682",
   "timeout": "5"
  }
 },
 "status": "success",
 "error": ""
}

Errors:

Example:

import requests
import json

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

path = 'system/loop/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)

System tasks

Get all tasks without log

Request Structure:

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

Post data:

access_token = <access_token>

The response from the server:

{
 "msg": [
  {
   "id": "ntmjhibjazlkmlrmbwpgdgeilcwyvf",
   "node": "PC-ruslan",
   "user": "ruslan",
   "description": "Set /etc/hosts",
   "module": "system",
   "method": "hostsset",
   "queue": true,
   "status": "error",
   "process_id": "60480",
   "start": "09-05-2022 19:34:58",
   "end": "09-05-2022 19:35:02",
   "duration": "3"
  },
  {
   "id": "svipiesvlrplfuvbgcilcvimotekqz",
   "node": "node-2.docluster.com",
   "user": "ruslan",
   "description": "Set /etc/hosts",
   "module": "system",
   "method": "hostsset",
   "queue": true,
   "status": "success",
   "process_id": "79574",
   "start": "09-05-2022 19:34:58",
   "end": "09-05-2022 19:35:02",
   "duration": "3"
  },
  {
   "id": "cavohdzoqabtmqaofmdgtskggdwjne",
   "node": "PC-ruslan",
   "user": "ruslan",
   "description": "Set /etc/hosts",
   "module": "system",
   "method": "hostsset",
   "queue": true,
   "status": "error",
   "process_id": "60558",
   "start": "09-05-2022 19:36:07",
   "end": "09-05-2022 19:36:11",
   "duration": "4"
  },
  {
   "id": "hvrombzgewntoyewhywgseldmwywmo",
   "node": "node-2.docluster.com",
   "user": "ruslan",
   "description": "Set /etc/hosts",
   "module": "system",
   "method": "hostsset",
   "queue": true,
   "status": "success",
   "process_id": "79623",
   "start": "09-05-2022 19:36:08",
   "end": "09-05-2022 19:36:11",
   "duration": "3"
  }
 ],
 "status": "success",
 "error": ""
}

Errors:

-no tasks in the system

Example:

import requests
import json

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

path = 'system/tasks/get'
data = {
        'ip': '1.2.3.4',
}

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 task data per id

Request Structure:

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

Post data:

access_token = <access_token>
id = <task id>

The response from the server:

{
 "msg": [
  {
   "id": "ntmjhibjazlkmlrmbwpgdgeilcwyvf",
   "node": "PC-ruslan",
   "user": "ruslan",
   "description": "Set /etc/hosts",
   "module": "system",
   "method": "hostsset",
   "arg": {
    "192.168.129.198": [
     "PC-ruslan"
    ],
    "192.168.129.81": [
     "node-1.docluster.com"
    ],
    "192.168.129.82": [
     "node-2.docluster.com"
    ],
    "192.168.129.83": [
     "node-3.docluster.com"
    ],
    "192.168.129.84": [
     "node-4.docluster.com"
    ],
    "192.168.129.85": [
     "node-5.docluster.com"
    ],
    "192.168.129.86": [
     "node-6.docluster.com"
    ],
    "192.168.129.87": [
     "node-7.docluster.com"
    ],
    "192.168.129.88": [
     "node-8.docluster.com"
    ],
    "192.168.129.89": [
     "node-9.docluster.com"
    ],
    "192.168.129.90": [
     "node-10.docluster.com",
     "node-10.docluster.comq"
    ]
   },
   "queue": true,
   "status": "error",
   "process_id": "60480",
   "start": "09-05-2022 19:34:58",
   "end": "09-05-2022 19:35:02",
   "duration": "3",
   "log": "Task: ntmjhibjazlkmlrmbwpgdgeilcwyvf\nModule: system\nMethod: hostsset\nDescription: Set /etc/hosts\nUser: ruslan\n-------------------------------------\n/bin/sh: 1: cannot create /etc/hosts: Permission denied\n\n/bin/sh: 1: cannot create /etc/hosts: Permission denied\n\n/bin/sh: 1: cannot create /etc/hosts: Permission denied\n\n/bin/sh: 1: cannot create /etc/hosts: Permission denied\n\n/bin/sh: 1: cannot create /etc/hosts: Permission denied\n\n/bin/sh: 1: cannot create /etc/hosts: Permission denied\n\n/bin/sh: 1: cannot create /etc/hosts: Permission denied\n\n/bin/sh: 1: cannot create /etc/hosts: Permission denied\n\n/bin/sh: 1: cannot create /etc/hosts: Permission denied\n\n/bin/sh: 1: cannot create /etc/hosts: Permission denied\n\n/bin/sh: 1: cannot create /etc/hosts: Permission denied\n\n/bin/sh: 1: cannot create /etc/hosts: Permission denied\n\n/bin/sh: 1: cannot create /etc/hosts: Permission denied\n\nTask: error\n"
  }
 ],
 "status": "success",
 "error": ""
}

Errors:

-no tasks in the system

Example:

import requests
import json

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

path = 'system/tasks/get'
data = {
        'id': <task id>
}

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

 

 

Stop task per id

Request Structure:

http://<cluster>:<port>/api/system/tasks/stop

Post data:

access_token = <access_token>
id = <task id>

The response from the server:

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

Errors:

-no tasks in the system

Example:

import requests
import json

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

path = 'system/tasks/stop'
data = {
        'id': <task id>,
}

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