替换

描述

object hostinterface.replacehostinterfaces(object **parameters**)

此方法允许给指定主机替换所有主机接口.

参数

(对象) 包含要更新的主机ID和新主机接口的参数.

参数类型描述
hostid
(必选)
字符串要更新主机的ID.
interfaces
(必须)
对象/数组替换当前主机接口的主机接口.

返回值

(对象)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. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  16. "id": 1
  17. }

响应:

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

参考

来源

CHostInterface::replaceHostInterfaces() in frontends/php/include/classes/api/services/CHostInterface.php.