替换

描述

object hostinterface.replacehostinterfaces(object parameters)

这种方法可以替换指定主机上的所有主机接口。

此方法仅适用于 AdminSuper admin 用户类型。调用该方法的权限可在用户角色设置中撤销。更多信息请参阅 用户角色

参数

(object) 参数包含要更新的主机 ID 和新的主机接口。

参数类型说明
interfacesobject/array要替换当前主机接口 的主机接口。

参数行为:
- 必须
hostidID要更新的主机的 ID。

参数行为:
- 必须

返回值

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

示例

更换主机接口

用一个代理接口取代所有主机接口。

请求

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "hostinterface.replacehostinterfaces",
  4. "params": {
  5. "hostid": "30052",
  6. "interfaces": {
  7. "dns": "",
  8. "ip": "127.0.0.1",
  9. "main": 1,
  10. "port": "10050",
  11. "type": 1,
  12. "useip": 1
  13. }
  14. },
  15. "id": 1
  16. }

响应:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "interfaceids": [
  5. "30081"
  6. ]
  7. },
  8. "id": 1
  9. }

另见

来源

CHostInterface::replaceHostInterfaces() 在 ui/include/classes/api/services/CHostInterface.php