Skip to content

Commit

Permalink
bugfix: Don't delete old tags
Browse files Browse the repository at this point in the history
aka: remove some debug stuff I had earlier
  • Loading branch information
eric-eisenhart committed May 16, 2024
1 parent 6b8bee7 commit d2fad86
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/sonic/netbox_zabbix/netbox_zabbix.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,23 +123,24 @@ def copy_netbox_maint_update_info_to_zabbix_tags(self, netbox_servers, zabbix_se
if netbox_servers[name].custom_fields['update_group']:
self.log.info(f"Adding update_group to zabbix for {name}")

if zabbix_servers[name]['tags']:
if 'tags' in zabbix_servers[name]:
tags = zabbix_servers[name]['tags']
self.log.info(f"DEBUG: tags: {pformat(tags)}")
new_tags = [item for item in tags if item['tag'] != 'netbox-update-group']
self.log.info(f"DEBUG: new_tags(1): {pformat(new_tags)}")
else:
new_tags = []

new_tags.append({
'tag': 'netbox-update-group',
'value': netbox_servers[name].custom_fields['update_group'],
})

self.log.info(f"DEBUG: new_tags(2): {pformat(new_tags)}")

response = self.zabbix.api.host.update(
hostid=zabbix_servers[name]['hostid'],
# tags=new_tags,
tags={
'tag': 'netbox-update-group',
'value': netbox_servers[name].custom_fields['update_group'],
},
tags=new_tags,
)
self.log.info(f"DEBUG: response: {pformat(response)}")
else:
Expand Down

0 comments on commit d2fad86

Please sign in to comment.