Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow DiffSyncModel to be present in multiple branches from top_level #287

Open
Yoyasp opened this issue Mar 19, 2025 · 3 comments
Open
Labels
status: gathering feedback Further discussion is needed to determine this issue's scope and/or implementation status: internal review Internal discussion is required to move forward with issue

Comments

@Yoyasp
Copy link

Yoyasp commented Mar 19, 2025

Environment

  • DiffSync version: 2.0.0

Proposed Functionality

Allow instances of DiffSyncModels to be preset in multiple branches.
This would allow a model to have an optional parent while still syncing all the objects without parents

Use Case

In the Netbox model we can have a VirtualChassis that includes member Device's, but also have Device's that are not part of a VirtualChassis.
If i split up these entities in two DiffSyncModel's and make Device a child of the VirtualChassis i must choose whether i only want to sync the Device's that are part of a VirtualChassis:

  • by making the VirtualChassis a top_level entry. This however will ignore all the devices that are not a child of VirtualChassis. Or:
  • by making the Device a top_level entry. This however will not create the VirtualChassis.

If i add both VirtualChassis and Device to top_level i get an error that Device's that are a child of VirtualChassis are already created when it wants to add the Device from that top_level entry.

This is exactly the same object so i dont know why it couldnt be possible to just skip over trying to recreate this. This would also be a nicer option than what is suggested in #285 .

@jdrew82
Copy link

jdrew82 commented Mar 19, 2025

I've actually done a Nautobot SSoT integration that handled that particular use case. You treat the Device and VirtualChassis as their own top_level objects that are not related via the parent/child relationship construct. You then simply have the VirtualChassis that a Device is a part of as an optional attribute on the Device. Have the VirtualChassis created before the Devices and you can then assign the Device to the VC when it's created.

@jdrew82 jdrew82 added status: gathering feedback Further discussion is needed to determine this issue's scope and/or implementation status: internal review Internal discussion is required to move forward with issue labels Mar 19, 2025
@Yoyasp
Copy link
Author

Yoyasp commented Mar 19, 2025

Thanks for the reply, i guess that would work as a work around. I would have to create the virtual chassis, save their new ids and assign those as a variable on the device.
There would also need to be some rewriting on the feedback of the diffs but thats doable.

Ill see if i can post some code for a future adventurer...

In the mean time, does my request make any sense, or is this just my stupid edge case?

@jdrew82
Copy link

jdrew82 commented Mar 20, 2025

I don't think it's a stupid edge case but I don't think it's a case that will fit within how DiffSync works. At this time DiffSync will treat each as it's own object and has no idea of the previously created one so you'd need to write your CRUD operations to handle that particular case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: gathering feedback Further discussion is needed to determine this issue's scope and/or implementation status: internal review Internal discussion is required to move forward with issue
Projects
None yet
Development

No branches or pull requests

2 participants