mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #38484 from mchugh19/zabhost-create-groups
allow zabbix_host.present to use group names in addition to groupids
This commit is contained in:
commit
20ae6c90f0
1 changed files with 15 additions and 0 deletions
|
@ -9,6 +9,7 @@ Management of Zabbix hosts.
|
|||
from __future__ import absolute_import
|
||||
from json import loads, dumps
|
||||
from copy import deepcopy
|
||||
from salt.ext import six
|
||||
|
||||
|
||||
def __virtual__():
|
||||
|
@ -125,6 +126,20 @@ def present(host, groups, interfaces, **kwargs):
|
|||
|
||||
interfaces_formated = _interface_format(interfaces)
|
||||
|
||||
# Ensure groups are all groupid
|
||||
groupids = []
|
||||
for group in groups:
|
||||
if isinstance(group, six.string_types):
|
||||
groupid = __salt__['zabbix.hostgroup_get'](name=group)
|
||||
try:
|
||||
groupids.append(int(groupid[0]['groupid']))
|
||||
except TypeError:
|
||||
ret['comment'] = 'Invalid group {0}'.format(group)
|
||||
return ret
|
||||
else:
|
||||
groupids.append(group)
|
||||
groups = groupids
|
||||
|
||||
host_exists = __salt__['zabbix.host_exists'](host)
|
||||
|
||||
if host_exists:
|
||||
|
|
Loading…
Add table
Reference in a new issue