Closes #12024: Allow Virtual Machines to be assigned directly to Devices #101

Closed
opened 2026-04-05 16:21:41 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @pheus on 3/23/2026

Fixes: #12024

Summary

This PR allows virtual machines to be assigned directly to a standalone device, without requiring a cluster. Previously, a VM could only be placed on a site or within a cluster (with an optional device pin). This adds a third placement mode: direct assignment to a device that doesn't belong to any cluster.

Changes

Model (VirtualMachine)

  • A VM can now be assigned to a site, a cluster, a standalone device, or a combination (e.g. cluster + device pin)
  • Site is automatically inherited from the assigned cluster or device when not explicitly set
  • If a device belongs to a cluster, the cluster must still be specified on the VM
  • Added device-scoped uniqueness constraints (name must be unique per device and tenant for standalone assignments)

Forms

  • Updated VirtualMachineForm, VirtualMachineImportForm, and VirtualMachineBulkEditForm with descriptive help texts for the site, cluster, and device fields

Documentation

  • Updated model docstring, virtualmachine.md model docs, and virtualization.md feature page to describe all three placement modes
  • Added "New in NetBox v4.6" callout for the standalone device feature

Tests

  • Added comprehensive test coverage for all valid and invalid placement combinations, standalone device assignment, name uniqueness per device, site auto-inheritance, tenant scoping, and case-insensitive name checks
*Originally created by @pheus on 3/23/2026* ### Fixes: #12024 ### Summary This PR allows virtual machines to be assigned directly to a standalone device, without requiring a cluster. Previously, a VM could only be placed on a site or within a cluster (with an optional device pin). This adds a third placement mode: direct assignment to a device that doesn't belong to any cluster. ### Changes **Model (`VirtualMachine`)** - A VM can now be assigned to a site, a cluster, a standalone device, or a combination (e.g. cluster + device pin) - Site is automatically inherited from the assigned cluster or device when not explicitly set - If a device belongs to a cluster, the cluster must still be specified on the VM - Added device-scoped uniqueness constraints (name must be unique per device and tenant for standalone assignments) **Forms** - Updated `VirtualMachineForm`, `VirtualMachineImportForm`, and `VirtualMachineBulkEditForm` with descriptive help texts for the site, cluster, and device fields **Documentation** - Updated model docstring, `virtualmachine.md` model docs, and `virtualization.md` feature page to describe all three placement modes - Added "New in NetBox v4.6" callout for the standalone device feature **Tests** - Added comprehensive test coverage for all valid and invalid placement combinations, standalone device assignment, name uniqueness per device, site auto-inheritance, tenant scoping, and case-insensitive name checks
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/netbox#101