From fef213dd5d8e5202dca049eb10a131b8243a3db2 Mon Sep 17 00:00:00 2001 From: "ricardo.bartels@telekom.de" Date: Thu, 14 Sep 2023 22:09:51 +0200 Subject: [PATCH] fixes issue with orphaned tag colour being reverted #340 --- module/netbox/connection.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/module/netbox/connection.py b/module/netbox/connection.py index 3b34434..5cb981c 100644 --- a/module/netbox/connection.py +++ b/module/netbox/connection.py @@ -531,12 +531,18 @@ class NetBoxHandler: prune_text = f"Objects would be automatically removed after {self.settings.prune_delay_in_days} days " \ f"but pruning is currently disabled." - self.inventory.add_update_object(NBTag, data={ - "name": self.orphaned_tag, - "color": "607d8b", - "description": "A source which has previously provided this object no " - f"longer states it exists. {prune_text}" - }) + orphaned_tag_object = self.inventory.add_update_object(NBTag, data={"name": self.orphaned_tag}) + + if orphaned_tag_object is not None: + orphaned_tag_data = { + "name": self.orphaned_tag, + "description": "A source which has previously provided this object no " + f"longer states it exists. {prune_text}" + } + if orphaned_tag_object.is_new is True: + orphaned_tag_data["color"] = "607d8a" + + orphaned_tag_object.update(data=orphaned_tag_data) self.inventory.add_update_object(NBTag, data={ "name": self.primary_tag,