替换
描述
object hostinterface.replacehostinterfaces(object parameters)
这种方法可以替换指定主机上的所有主机接口。
此方法仅适用于 Admin 和 Super admin 用户类型。调用该方法的权限可在用户角色设置中撤销。更多信息请参阅 用户角色。
参数
(object)
参数包含要更新的主机 ID 和新的主机接口。
参数 | 类型 | 说明 |
---|---|---|
interfaces | object/array | 要替换当前主机接口 的主机接口。 参数行为: - 必须 |
hostid | ID | 要更新的主机的 ID。 参数行为: - 必须 |
返回值
(object)
返回一个对象,其中在 interfaceids
属性下包含创建的主机接口的 ID。
示例
更换主机接口
用一个代理接口取代所有主机接口。
请求:
{
"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。