This is a translation of the original English documentation page. Help us make it better.

hostinterface.create

Description

object hostinterface.create(object/array hostInterfaces)

This method allows to create new host interfaces.

This method is only available to Admin and Super admin user types. Permissions to call the method can be revoked in user role settings. See User roles for more information.

Parameters

(object/array) Host interfaces to create. The method accepts host interfaces with the standard host interface properties.

Restituisce i valori

(object) Restituisce un oggetto contenente gli ID delle interfacce host create nella proprietà interfaceids. L'ordine degli ID restituiti corrispondono all'ordine delle interfacce host passate.

Esempi

Create a new interface

Create a secondary IP agent interface on host "30052."

Request:

{
           "jsonrpc": "2.0",
           "method": "hostinterface.create",
           "params": {
               "hostid": "30052",
               "main": "0",
               "type": "1",
               "useip": "1"
               "ip": "127.0.0.1",
               "dns": "",
               "port": "10050",
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "interfaceids": [
                   "30062"
               ]
           },
           "id": 1
       }

Create an interface with SNMP details

Request:

{
           "jsonrpc": "2.0",
           "method": "hostinterface.create",
           "params": {
               "hostid": "10456",
               "main": "0",
               "type": "2",
               "useip": "1",
               "ip": "127.0.0.1",
               "dns": "",
               "port": "1601",
               "details": {
                   "version": "2",
                   "bulk": "1",
                   "community": "{$SNMP_COMMUNITY}"
               }
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "interfaceids": [
                   "30063"
               ]
           },
           "id": 1
       }

Guarda anche

Fonte

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