Pass action value to `lookup_object` method to allow for conditional lookup based on action type
Environment
- Nautobot version: 1.2.8
- nautobot-ssot version: 1.1.2
Proposed Functionality
As a plugin developer I would like to be able to conditionally look up objects based on the action type applied to given diffsync record.
Use Case
As a plugin developer I want to specify that the object lookup should not happen for records that were deleted. I only want to perform object lookup for records that were created or updated.
Any chance you can provide an actual example?
Sure. I have a try-except in the lookup_object method where I log job warning message when lookup fails. But without knowing the type of action that trigerred the lookup I don't know if the lookup failure is genuine (create, update) or expected (delete).
If I knew the action type I could log warnings for genuine failures only. Right now each lookup failure for deleted objects will generate the warning message.
try:
return getattr(NautobotDiffSync, model_name)._nautobot_model.objects.get(
_custom_field_data__netbox_id=int(unique_id)
)
except ObjectDoesNotExist:
self.log_warning(message=lookup_failure_message)