Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion nbxsync/jobs/cfggroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,14 @@ def _propagate():
class DeleteHostGroupAssignmentClonesJob:
def __init__(self, **kwargs):
self.configgroup_pk = kwargs['configgroup_pk']
self.zabbixhostgroup_pk = kwargs['zabbixhostgroup_pk']

def run(self):
assignments = ZabbixHostgroupAssignment.objects.filter(zabbixconfigurationgroup_id=self.configgroup_pk).select_related('assigned_object_type')

def _delete():
for assigned in assignments:
ZabbixHostgroupAssignment.objects.filter(assigned_object_type=assigned.assigned_object_type, assigned_object_id=assigned.assigned_object_id, zabbixconfigurationgroup_id=self.configgroup_pk).delete()
ZabbixHostgroupAssignment.objects.filter(zabbixhostgroup_id=self.zabbixhostgroup_pk, assigned_object_type=assigned.assigned_object_type, assigned_object_id=assigned.assigned_object_id, zabbixconfigurationgroup_id=self.configgroup_pk).delete()

transaction.on_commit(_delete)

Expand Down
2 changes: 1 addition & 1 deletion nbxsync/signals/zabbixhostgroupassignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ def handle_postdelete_zabbixhostgroupassignment(sender, instance, **kwargs):
if not is_configgroup_assignment(instance):
return

delete_hostgroup_assignment_clones.delay(configgroup_pk=instance.assigned_object_id)
delete_hostgroup_assignment_clones.delay(configgroup_pk=instance.assigned_object_id, zabbixhostgroup_pk=instance.zabbixhostgroup_id)
4 changes: 2 additions & 2 deletions nbxsync/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ def propagate_hostgroup_assignment(assignment_pk):


@job('low')
def delete_hostgroup_assignment_clones(configgroup_pk):
DeleteHostGroupAssignmentClonesJob(configgroup_pk=configgroup_pk).run()
def delete_hostgroup_assignment_clones(configgroup_pk, zabbixhostgroup_pk):
DeleteHostGroupAssignmentClonesJob(configgroup_pk=configgroup_pk, zabbixhostgroup_pk=zabbixhostgroup_pk).run()


@job('low')
Expand Down