Skip to content

Commit fecfd66

Browse files
committed
removes source tags from objects which don't belong to that source bb-Ricardo#273
1 parent 3b55c71 commit fecfd66

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

module/netbox/inventory.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -319,16 +319,18 @@ def tag_all_the_things(self, netbox_handler):
319319
else:
320320

321321
if bool(set(this_object_tags).intersection(disabled_sources_tags)) is True:
322-
log.debug2(f"Object '{this_object.get_display_name()}' was added "
322+
log.debug2(f"Object {this_object.__class__.name} '{this_object.get_display_name()}' was added "
323323
f"from a currently disabled source. Skipping orphaned tagging.")
324324
continue
325325

326326
# test for different conditions.
327327
if netbox_handler.primary_tag not in this_object_tags:
328328
continue
329329

330-
if bool(set(this_object_tags).intersection(all_sources_tags)) is False \
331-
and netbox_handler.ignore_unknown_source_object_pruning is True:
330+
if bool(set(this_object_tags).intersection(all_sources_tags)) is True:
331+
for source_tag in all_sources_tags:
332+
this_object.remove_tags(source_tag)
333+
elif netbox_handler.settings.ignore_unknown_source_object_pruning is True:
332334
continue
333335

334336
if getattr(this_object, "prune", False) is False:

0 commit comments

Comments
 (0)