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

Location List and Locations not Showing Associated VLAN Groups #18742

Open
Kurnugia opened this issue Feb 26, 2025 · 3 comments · May be fixed by #18804
Open

Location List and Locations not Showing Associated VLAN Groups #18742

Kurnugia opened this issue Feb 26, 2025 · 3 comments · May be fixed by #18804
Assignees
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@Kurnugia
Copy link

Kurnugia commented Feb 26, 2025

Deployment Type

Self-hosted

NetBox Version

v4.2.3

Python Version

3.12

Steps to Reproduce

  1. Create a Site.
  2. Create a Location within that Site.
  3. Create a VLAN Group and any constituent VLANs.
  4. Assign the VLAN Group to the Location.
  5. View the list of Locations.
  6. View the Location with the VLAN Group assigned.

Expected Behavior

Viewing the Location List

  • When viewing the list of Locations, we should be able to see any reference to the associated VLAN Group(s).

Viewing the Location Itself

  • When viewing the Location itself, we should be able to see any reference to the assigned VLAN Group(s) in the Related Objects list at the right.

Image

Observed Behavior

We do not see any reference to any VLAN Groups anywhere other than when viewing IPAM > VLAN Groups. This makes it difficult to see which VLAN Groups are defined for different locations within a site.


Potential Resolutions

I tried to resolve some of this, but I don't have enough knowledge/experience with the coding of NetBox.

Location List

File: /opt/netbox/netbox/dcim/tables/sites.py

Changes:

class LocationTable ...
    ...
    vlan_groups = tables.ManyToManyColumn(
        verbose_name=_("VLAN Groups"),
        linkify_item=True,
    )
    class Meta(NetBoxTable.Meta):
        model = Location
        fields = (
            'pk', 'id', 'name', 'site', 'status', 'facility', 'tenant', 'tenant_group', 'rack_count', 'device_count',
            'description', 'slug', 'contacts', 'tags', 'actions', 'created', 'last_updated', "vlan_groups",
        )

This would result in the following:

Image

Location

I was unable to figure out how to update the Related Objects field when looking at a Location to view the associated VLAN Groups.

@Kurnugia Kurnugia added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels Feb 26, 2025
@bctiemann

This comment has been minimized.

@bctiemann
Copy link
Contributor

This functionality is handled by passing extra fields to the get_related_models method here:

netbox/netbox/dcim/views.py

Lines 530 to 552 in b9b42cd

def get_extra_context(self, request, instance):
locations = instance.get_descendants(include_self=True)
return {
'related_models': self.get_related_models(
request,
locations,
omit=[CableTermination, Cluster, Prefix, WirelessLAN],
extra=(
(
Circuit.objects.restrict(request.user, 'view').filter(
terminations___location=instance
).distinct(),
'location_id'
),
# Handle these relations manually to avoid erroneous filter name resolution
(Cluster.objects.restrict(request.user, 'view').filter(_location=instance), 'location_id'),
(Prefix.objects.restrict(request.user, 'view').filter(_location=instance), 'location_id'),
(WirelessLAN.objects.restrict(request.user, 'view').filter(_location=instance), 'location_id'),
),
),
}

VLAN groups can be added to Related Objects by adding this:

                    (VLANGroup.objects.restrict(request.user, 'view').filter(location=instance), 'location'),

However, I think this would be better handled as a feature request rather than a bug, as this is basically just adding a field to a listing in an understood way, and the only point of contention would be whether it's a valuable enough addition.

@bctiemann
Copy link
Contributor

@Kurnugia Actually on further thought this does seem like a bug -- this is not expected behavior. The intent is for ALL related objects (except for certain explicitly omitted ones) to appear automatically in that list, and VLAN groups should be showing up there.

None of the GenericRelations that have been added to various models since the introduction of scoping will have been added to Related Objects in this way, and so an ideal fix would be to add them explicitly (as in my previous comment) to all affected models, of which there might be quite a few.

@bctiemann bctiemann added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation severity: low Does not significantly disrupt application functionality, or a workaround is available and removed status: needs triage This issue is awaiting triage by a maintainer labels Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
3 participants