hostinterface.create

描述

object hostinterface.create(object/array hostInterfaces)

该方法允许创建新的主机接口。

此方法仅适用于管理员超级管理员用户类型。调用该方法的权限可在用户角色设置中撤销。更多信息请参阅User roles

参数

(object/array) 主机 接口创建。该方法接受具有主机接口的主机接口。

返回值

(object) 返回一个包含所创建主机接口ID的object对象,这些ID存储在interfaceids属性下。返回的ID顺序与传入的主机接口顺序保持一致。

示例

创建新接口

在主机 "30052"上创建次级IPagent接口

请求:

{
           "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
       }

响应:

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

创建包含 SNMP 详细信息的接口

请求:

{
           "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
       }

响应:

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

另请参阅

来源

CHostInterface::create() 位于 ui/include/classes/api/services/CHostInterface.php 文件中。