✨ Link Image to Tenant and TenantGroup#240
Merged
Merged
Conversation
Docker images hosted in NetBox need to be associated with the tenants that own or consume them. This allows operators to filter, audit, and report on container images per business unit or customer, in line with the tenancy model already used throughout the NetBox data model. **Model (`Image`)** - Added nullable `tenant_group` FK → `tenancy.TenantGroup` (SET_NULL) - Added nullable `tenant` FK → `tenancy.Tenant` (SET_NULL) Deletion of a tenant/group sets the field to NULL rather than cascading, so images are never accidentally removed. **Forms** - `ImageForm`: new "Tenancy" fieldset (bottom of form) with `tenant_group` and `tenant`; tenant is filtered by selected group via `query_params`. - `ImageFilterForm`: multi-select filters for `tenant_group_id` and `tenant_id` so list views can be scoped to one or more tenants. - `ImageBulkEditForm`: bulk-assign tenant group and tenant to a selection of images. **Filterset** - `ImageFilterSet`: `tenant_group_id` and `tenant_id` `ModelMultipleChoiceFilter` entries so the API and UI filters work correctly. **Table** - `ImageTable`: `tenant_group` and `tenant` columns added to both the full field list and the default visible columns. **Serializer** - `ImageSerializer`: `tenant_group` and `tenant` rendered as nested objects (using NetBox's `TenantGroupSerializer` / `TenantSerializer` with `nested=True`) so the REST API exposes the full relation. **Template** - `image.html`: "Tenancy" card added to the detail page (left column, between the main Image card and custom fields), showing Tenant Group and Tenant with links or a placeholder when unset. **Tests** - `tests/query_counts.json` baseline file created (all 321 tests pass). **CI** - Bumped test matrix to Python 3.13 and NetBox v4.5.10 / v4.6.2. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> :arrow_up:
483afb7 to
4446ded
Compare
lvenier
approved these changes
Jun 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Docker images hosted in NetBox need to be associated with the tenants that own or consume them. This allows operators to filter, audit, and report on container images per business unit or customer, in line with the tenancy model already used throughout the NetBox data model.
Model (
Image)tenant_groupFK →tenancy.TenantGroup(SET_NULL)tenantFK →tenancy.Tenant(SET_NULL) Deletion of a tenant/group sets the field to NULL rather than cascading, so images are never accidentally removed.Forms
ImageForm: new "Tenancy" fieldset (bottom of form) withtenant_groupandtenant; tenant is filtered by selected group viaquery_params.ImageFilterForm: multi-select filters fortenant_group_idandtenant_idso list views can be scoped to one or more tenants.ImageBulkEditForm: bulk-assign tenant group and tenant to a selection of images.Filterset
ImageFilterSet:tenant_group_idandtenant_idModelMultipleChoiceFilterentries so the API and UI filters work correctly.Table
ImageTable:tenant_groupandtenantcolumns added to both the full field list and the default visible columns.Serializer
ImageSerializer:tenant_groupandtenantrendered as nested objects (using NetBox'sTenantGroupSerializer/TenantSerializerwithnested=True) so the REST API exposes the full relation.Template
image.html: "Tenancy" card added to the detail page (left column, between the main Image card and custom fields), showing Tenant Group and Tenant with links or a placeholder when unset.Tests
tests/query_counts.jsonbaseline file created (all 321 tests pass).CI