Skip to content

Allow childrens to have multiple parents #210

Open

Description

@chadell

Environment

  • DiffSync version: 1.7.0

Proposed Functionality

children could have multiple parents to represent more real use cases.

Use Case

An ipaddress could belong to an interface but also to a bgppeer

Activity

  1. Kircheneer commented on Aug 25, 2023

    @Kircheneer
    Contributor

    Until we have this, here is a pattern you can use to deal with this.

    class CustomDiff(Diff):
        # This order is significant to the order in which diffsync actions are performed.
        # Create/update operations happen in this exact order, delete operations in reverse.
        order = ["vpn", "role", "vlan", "prefix"]
    
        def get_children(self):
            deferred_children = []
            for model in self.order:
                for child in self.children[model].values():
                    if child.action == DiffSyncActions.DELETE:
                        # Insert the deferred deletion actions in reverse order from the general model order as to resolve
                        # dependencies correctly.
                        deferred_children.insert(0, child)
                    else:
                        yield child
            yield from deferred_children
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: acceptedThis issue has been accepted by the maintainers team for implementationtype: enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions