From 0ad2fee13e61218e80c8e5e546ac63c85e100990 Mon Sep 17 00:00:00 2001 From: Marin Atanasov Nikolov Date: Wed, 23 Apr 2014 10:31:37 +0300 Subject: [PATCH] zabbix-vsphere-import: Add method for creating a hostgroup in Zabbix --- src/misc-tools/zabbix-vsphere-import | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/misc-tools/zabbix-vsphere-import b/src/misc-tools/zabbix-vsphere-import index 81bf097..3fa81cd 100755 --- a/src/misc-tools/zabbix-vsphere-import +++ b/src/misc-tools/zabbix-vsphere-import @@ -216,6 +216,30 @@ class ZabbixConnector(object): return group['groupid'] + def create_host_group(self, name): + """ + Create a Zabbix host group + + Args: + name (str): Name of the host group to create + + Returns: + The id of the newly create host group + + """ + logging.info( + '[%s] Creating Zabbix host group %s', + self.options['zabbix']['hostname'], + name + ) + + result = self._call_zabbix_method( + method='hostgroup.create', + params={'name': name} + ) + + return result['groupids'] + def create_host(self, host): """ Create a Zabbix host