hostgroup.massadd

Description 说明

object hostgroup.massadd(object parameters)

This method allows to simultaneously add multiple related objects to all the given host groups. 该方法允许同时向所有给定的主机组添加多个相关对象。

Parameters 参数

(object) Parameters containing the IDs of the host groups to update and the objects to add to all the host groups. 包含要更新的主机组的ID和要添加到所有主机组的对象的参数。

The method accepts the following parameters.该方法接受以下参数。

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

The host groups must have the groupid property defined. 主机组必须定义“groupid”属性。
hosts object/array Hosts to add to all host groups. 添加到主机组的所有主机。

The hosts must have the hostid property defined.主机必须定义“hostid”属性。
templates object/array Templates to add to all 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示例

Adding hosts to host groups将主机添加到主机组

Add two hosts to host groups with IDs 5 and 6.将两个主机添加到ID为5和6的主机组。

Request:

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

Response:

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

See also参见

Source来源

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