Skip to content

✨ Link Image to Tenant and TenantGroup#240

Merged
fanshan merged 1 commit into
mainfrom
feat/image-tenant-tenantgroup
Jun 5, 2026
Merged

✨ Link Image to Tenant and TenantGroup#240
fanshan merged 1 commit into
mainfrom
feat/image-tenant-tenantgroup

Conversation

@fanshan

@fanshan fanshan commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

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.

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:
@fanshan fanshan force-pushed the feat/image-tenant-tenantgroup branch from 483afb7 to 4446ded Compare June 5, 2026 12:13
@fanshan fanshan requested a review from lvenier June 5, 2026 12:23
@fanshan fanshan self-assigned this Jun 5, 2026
@fanshan fanshan merged commit b6aa5cc into main Jun 5, 2026
2 checks passed
@fanshan fanshan deleted the feat/image-tenant-tenantgroup branch June 5, 2026 15:48
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.

2 participants