hostinterface.massadd

Description

object hostinterface.massadd(object **parameters**)

This method allows to simultaneously add host interfaces to multiple hosts.

Parameters

(object) Parameters containing the host interfaces to be created on the given hosts.

The method accepts the following parameters.

ParameterTypeDescription
hosts
(required)
object/arrayHosts to be updated.

The hosts must have the hostid property defined.
interfaces
(required)
object/arrayHost interfaces to create on the given hosts.

Return values

(object) Returns an object containing the IDs of the created host interfaces under the interfaceids property.

Examples

Creating interfaces

Create an interface on two hosts.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "hostinterface.massadd",
  4. "params": {
  5. "hosts": [
  6. {
  7. "hostid": "30050"
  8. },
  9. {
  10. "hostid": "30052"
  11. }
  12. ],
  13. "interfaces": {
  14. "dns": "",
  15. "ip": "127.0.0.1",
  16. "main": 0,
  17. "port": "10050",
  18. "type": 1,
  19. "useip": 1
  20. }
  21. },
  22. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  23. "id": 1
  24. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "interfaceids": [
  5. "30069",
  6. "30070"
  7. ]
  8. },
  9. "id": 1
  10. }

See also

Source

CHostInterface::massAdd() in ui/include/classes/api/services/CHostInterface.php.