hostinterface.massadd

描述

object hostinterface.massadd(object parameters)

此方法允许同时向多个主机接口添加 主机

::: noteclassic 该方法仅对 管理员超级管理员 可用 用户类型。调用该方法的权限可以在用户角色中被撤销 设置。请参见 User roles 更多信息请参见。 仅返回OutputFormat格式要求结果

参数

(object) 参数包含要在指定的 主机 上创建的 主机 接口。

该方法接受以下参数。

参数 数据类型 描述
interfaces object/array 指向要在给定 主机 上执行 create 的 Host interfaces

参数行为
- 必填
hosts object/array 要更新的 Hosts

该 主机 必须仅定义了 hostid 属性。

参数行为
- 必填

返回值

(object) 返回一个 object,其中包含在 interfaceids 属性下列出的已创建 主机 接口的 ID。

示例

创建接口

在两个 主机 上创建接口。

执行请求:

{
           "jsonrpc": "2.0",
           "method": "hostinterface.massadd",
           "params": {
               "hosts": [
                   {
                       "hostid": "30050"
                   },
                   {
                       "hostid": "30052"
                   }
               ],
               "interfaces": {
                   "dns": "",
                   "ip": "127.0.0.1",
                   "main": 0,
                   "port": "10050",
                   "type": 1,
                   "useip": 1
               }
           },
           "id": 1
       }

响应:

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

另请参阅

来源

CHostInterface::massAdd() 在 ui/include/classes/api/services/CHostInterface.php 中。