nautobot-app-ssot icon indicating copy to clipboard operation
nautobot-app-ssot copied to clipboard

Filter source objects to diff

Open chadell opened this issue 2 years ago • 5 comments

Proposed Functionality

By default, diffsync is executed for all the objects in the source and target adapted. We could apply filtering to only sync objects that match some criteria.

Filtering objects to execute diffsync could help to simplify some cases when only one or a few objects need to be evaluated for a sync.

Use Cases

As a network engineer, I would like to define filter criteria in the SSoT execution so the loading of objects in the source and destination datasets are restricted, and the whole process is narrowed down to a specific scope. For instance, Nautobot and an external Asset Management system contain 1000s of Sites/Location, but when a change on a specific one happens I would like to run the SSoT only for this location, from both the source and destination. So, the loading function should take into account the filtering for both adapters, and load only the related information. If the location contains Devices, and Devices contain Interfaces, I would only be interested on comparing this related data, leaving all the rest out of the comparison.

chadell avatar Mar 28 '22 05:03 chadell

Consider Mappings implementation in servicenow-ssot as an idea to incorporate custom checks: table_query

chadell avatar Feb 27 '23 08:02 chadell

Possible implementation plan:

Provide a way to pass filters into an adapter per model that specifies which objects we are interested in. This could initially be enforced in $adapter.add, but also available as a field inside of the adapter for custom implementations to use in the load part prior to the add part. This usage in the load part would need to be documented well to communicate this to potential users.

Kircheneer avatar May 04 '23 14:05 Kircheneer

May also be worth exploring dynamic groups to achieve this behaviour on the Nautobot side. This would require more models to be supported with dynamic groups (https://github.com/nautobot/nautobot/issues/1822).

Kircheneer avatar May 04 '23 14:05 Kircheneer

I am finding this is commonly implemented via dynamic groups today (for the models that they support) in that a job input var is used to allow selection of a group and then that group's queryset is used by the adaptor.

lampwins avatar Jun 23 '23 21:06 lampwins

Relates to #229

Kircheneer avatar Oct 05 '23 13:10 Kircheneer