hanode.get

Description

integer/array hanode.get(object parameters)

The method allows to retrieve a list of High availability cluster nodes according to the given parameters.

This method is only available to Super admin user types. See User roles for more information.

Parameters

(object) Parameters defining the desired output.

The method supports the following parameters.

ParameterTypeDescription
ha_nodeidsstring/arrayReturn only nodes with the given node IDs.
filterobjectReturn only those results that exactly match the given filter.

Accepts an array, where the keys are property names, and the values are either a single value or an array of values to match against.

Allows filtering by the node properties: name, address, status.
sortfieldstring/arraySort the result by the given properties.

Possible values are: name, lastaccess, status.
countOutputflagThese parameters being common for all get methods are described in detail in the reference commentary.
limitinteger
outputquery
preservekeysboolean
sortorderstring/array

Return values

(integer/array) Returns either:

  • an array of objects;
  • the count of retrieved objects, if the countOutput parameter has been used.

Examples

Get a list of nodes ordered by status

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "hanode.get",
  4. "params": {
  5. "preservekeys": true,
  6. "sortfield": "status",
  7. "sortorder": "DESC"
  8. },
  9. "auth": "3a57200802b24cda67c4e4010b50c065",
  10. "id": 1
  11. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "ckuo7i1nw000h0sajj3l3hh8u": {
  5. "ha_nodeid": "ckuo7i1nw000h0sajj3l3hh8u",
  6. "name": "node-active",
  7. "address": "192.168.1.13",
  8. "port": "10051",
  9. "lastaccess": "1635335704",
  10. "status": "3"
  11. },
  12. "ckuo7i1nw000e0sajwfttc1mp": {
  13. "ha_nodeid": "ckuo7i1nw000e0sajwfttc1mp",
  14. "name": "node6",
  15. "address": "192.168.1.10",
  16. "port": "10053",
  17. "lastaccess": "1635332902",
  18. "status": "2"
  19. },
  20. "ckuo7i1nv000c0sajz85xcrtt": {
  21. "ha_nodeid": "ckuo7i1nv000c0sajz85xcrtt",
  22. "name": "node4",
  23. "address": "192.168.1.8",
  24. "port": "10052",
  25. "lastaccess": "1635334214",
  26. "status": "1"
  27. },
  28. "ckuo7i1nv000a0saj1fcdkeu4": {
  29. "ha_nodeid": "ckuo7i1nv000a0saj1fcdkeu4",
  30. "name": "node2",
  31. "address": "192.168.1.6",
  32. "port": "10051",
  33. "lastaccess": "1635335705",
  34. "status": "0"
  35. }
  36. },
  37. "id": 1
  38. }

Get a list of specific nodes by their IDs

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "hanode.get",
  4. "params": {
  5. "ha_nodeids": ["ckuo7i1nw000e0sajwfttc1mp", "ckuo7i1nv000c0sajz85xcrtt"]
  6. },
  7. "auth": "3a57200802b24cda67c4e4010b50c065",
  8. "id": 1
  9. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "ha_nodeid": "ckuo7i1nv000c0sajz85xcrtt",
  6. "name": "node4",
  7. "address": "192.168.1.8",
  8. "port": "10052",
  9. "lastaccess": "1635334214",
  10. "status": "1"
  11. },
  12. {
  13. "ha_nodeid": "ckuo7i1nw000e0sajwfttc1mp",
  14. "name": "node6",
  15. "address": "192.168.1.10",
  16. "port": "10053",
  17. "lastaccess": "1635332902",
  18. "status": "2"
  19. }
  20. ],
  21. "id": 1
  22. }

Get a list of stopped nodes

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "hanode.get",
  4. "params": {
  5. "output": ["ha_nodeid", "address", "port"],
  6. "filter": {
  7. "status": 1
  8. }
  9. },
  10. "auth": "3a57200802b24cda67c4e4010b50c065",
  11. "id": 1
  12. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "ha_nodeid": "ckuo7i1nw000g0sajjsjre7e3",
  6. "address": "192.168.1.12",
  7. "port": "10051"
  8. },
  9. {
  10. "ha_nodeid": "ckuo7i1nv000c0sajz85xcrtt",
  11. "address": "192.168.1.8",
  12. "port": "10052"
  13. },
  14. {
  15. "ha_nodeid": "ckuo7i1nv000d0sajd95y1b6x",
  16. "address": "192.168.1.9",
  17. "port": "10053"
  18. }
  19. ],
  20. "id": 1
  21. }

Get a count of standby nodes

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "hanode.get",
  4. "params": {
  5. "countOutput": true,
  6. "filter": {
  7. "status": 0
  8. }
  9. },
  10. "auth": "3a57200802b24cda67c4e4010b50c065",
  11. "id": 1
  12. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": "3",
  4. "id": 1
  5. }

Check status of nodes at specific IP addresses

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "hanode.get",
  4. "params": {
  5. "output": ["name", "status"],
  6. "filter": {
  7. "address": ["192.168.1.7", "192.168.1.13"]
  8. }
  9. },
  10. "auth": "3a57200802b24cda67c4e4010b50c065",
  11. "id": 1
  12. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "name": "node3",
  6. "status": "0"
  7. },
  8. {
  9. "name": "node-active",
  10. "status": "3"
  11. }
  12. ],
  13. "id": 1
  14. }

Source

CHaNode::get() in ui/include/classes/api/services/CHaNode.php.