Skip to content

Commit

Permalink
zabbix-vsphere-import: Find a Zabbix hostgroup by name
Browse files Browse the repository at this point in the history
  • Loading branch information
dnaeon committed Apr 23, 2014
1 parent 480bf80 commit 0c3a195
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/misc-tools/zabbix-vsphere-import
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,28 @@ class ZabbixConnector(object):

return result

def get_host_group_by_name(self, name):
"""
Get a Zabbix hostgroup id by name
Args:
name (str): Name of the host group in Zabbix
Returns:
The id of the host group in Zabbix
"""
data = self.get_host_groups()
groups = data['result']

for group in groups:
if group['name'] == name:
break
else:
return None

return group['groupid']

def create_host(self, host):
"""
Create a Zabbix host
Expand Down

0 comments on commit 0c3a195

Please sign in to comment.