hostinterface.replacehostinterfaces

Description 说明

object hostinterface.replacehostinterfaces(object parameters)

This method allows to replace all host interfaces on a given host.此方法允许替换给定主机上的所有主机接口。

Parameters 参数

(object) Parameters containing the ID of the host to be updated and the new host interfaces.包含要更新的主机ID和新主机接口的参数。

参数 类 描述
hostid
(required)
string ID of the host to be updated. 要更新的主机的ID。
interfaces
(required)
object/array Host interfaces to replace the current host interfaces with. 替换当前主机接口的主机接口。

Return values 返回值

(object) Returns an object containing the IDs of the created host interfaces under the interfaceids property.返回一个包含“interfaceID”属性下创建的主机接口的ID的对象。

Examples 示例

Replacing host interfaces 更换主机接口

Replace all host interfaces with a single agent interface.用单个代理接口替换所有主机接口。

Request:

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

Response:

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

See also 参见

Source 来源

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