hostinterface.massadd

描述

object hostinterface.massadd(object parameters)

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

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

参数

(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 中。