def zabbix_update_task(hostname, ip, templates): if not settings.ZABBIX_URL: return zabbix = Zabbix(settings.ZABBIX_URL, settings.ZABBIX_USER, settings.ZABBIX_PASSWORD) zabbix.set_host_templates(hostname, ip, templates, group_name=settings.ZABBIX_DEFAULT_GROUP)
def update_zabbix_templates(device, templates=None): hostname = device.name # FIXME: is this deliberate? role = device.venture_role try: ip = device.ipaddress_set.get(hostname=hostname) except IPAddress.DoesNotExist: return if templates is None: templates = _calculate_zabbix_templates(role) zabbix = Zabbix(settings.ZABBIX_URL, settings.ZABBIX_USER, settings.ZABBIX_PASSWORD) zabbix.set_host_templates(hostname, str(ip.address), templates, group_name=settings.ZABBIX_DEFAULT_GROUP)