hostgroup.massupdate

Description 说明

object hostgroup.massupdate(object parameters)

This method allows to simultaneously replace or remove related objects for multiple host groups.该方法允许同时替换或删除多个主机组的相关对象。

Parameters 参数

(object) Parameters containing the IDs of the host groups to update and the objects that should be updated. 包含要更新的主机组的ID和应更新的对象的参数。

参数 类 描述
groups
(required)
object/array Host groups to be updated. 要更新的主机组。

The host groups must have the groupid property defined. 主机组必须定义“groupid”属性。
hosts object/array Hosts to replace the current hosts on the given host groups. 主机替换给定主机组上的当前主机。

The hosts must have the hostid property defined.主机必须定义“hostid”属性。
templates object/array Templates to replace the current templates on the given host groups.用于替换给定主机组上当前模板的模板。

The templates must have the templateid property defined. 模板必须定义“templateid”属性。

Return values 返回值

(object) Returns an object containing the IDs of the updated host groups under the groupids property.返回包含“groupids”属性下更新的主机组的ID的对象。

Examples 示例

Replacing hosts in a host group 更换主机组中的主机

Replace all hosts in the host group with ID.用ID替换主机组中的所有主机。

Request:

{
           "jsonrpc": "2.0",
           "method": "hostgroup.massupdate",
           "params": {
               "groups": [
                   {
                       "groupid": "6"
                   }
               ],
               "hosts": [
                   {
                       "hostid": "30050"
                   }
               ]
           },
           "auth": "f223adf833b2bf2ff38574a67bba6372",
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "groupids": [
                   "6",
               ]
           },
           "id": 1
       }

See also 参见

Source 来源

CHostGroup::massUpdate() in frontends/php/include/classes/api/services/CHostGroup.php.