Skip to content

Conversation

bctiemann
Copy link
Contributor

Fixes: #19720

Adds a GenericRelation to BaseInterface providing a reverse lookup interface which can be used in MACAddress queries against the assigned_object field (a GFK to Interface or VMInterface), for example in permissions:

Screenshot 2025-10-02 at 10 04 44 PM

Note that this lookup will be called interface regardless of whether the target object is an Interface or a VMInterface.

… be queried via "interface" reverse relation in permissions
@bctiemann bctiemann requested review from a team, jnovinger and Copilot and removed request for a team October 3, 2025 02:10
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a GenericRelation field to the BaseInterface model to enable reverse lookups of MAC addresses assigned to interfaces. This allows for more intuitive querying of MAC addresses through their associated interfaces.

  • Adds a mac_addresses field as a GenericRelation to BaseInterface
  • Enables reverse lookup with related_query_name='interface' for both Interface and VMInterface objects
  • Supports filtering MAC addresses by their assigned interface objects in permissions and queries

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

content_type_field='assigned_object_type',
object_id_field='assigned_object_id',
related_query_name='interface',
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm, doesn't the Interface model already have a mac_addresses generic relation that will just override this?

Same thing for VMInterface. As a matter of fact, I think that overriding this will actually break the expectation that the related query name will be interface for MAC addresses pointing back at VM interfaces.

@bctiemann bctiemann marked this pull request as draft October 9, 2025 18:40
@bctiemann bctiemann closed this Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Permissions constraints not working for MAC Address objects
2 participants