hostinterface.replacehostinterfaces

描述

object hostinterface.replacehostinterfaces(object parameters)

此方法允许替换给定 主机 上的所有 主机 接口。

此方法仅对 AdminSuper admin 用户类型可用。调用该方法的权限可以在用户角色设置中撤销。更多信息请参见 User roles

参数

(object) 包含待更新的 主机 ID 的参数,并且 新的 主机 接口。

参数 数据类型 描述
interfaces object/array 用于替换当前 主机 接口的 Host interfaces

参数行为
- 必填
hostid ID 要更新的主机的ID。

参数行为
- 必填

返回值

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

示例

替换主机接口

将所有 主机 接口替换为单个 agent 接口。

执行请求:

{
           "jsonrpc": "2.0",
           "method": "hostinterface.replacehostinterfaces",
           "params": {
               "hostid": "30052",
               "interfaces": {
                   "dns": "",
                   "ip": "127.0.0.1",
                   "main": 1,
                   "port": "10050",
                   "type": 1,
                   "useip": 1
               }
           },
           "id": 1
       }

响应:

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

另请参阅

来源

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