mirror of
https://github.com/netbox-community/netbox.git
synced 2026-03-30 06:12:13 +02:00
feat(virtualization): Add Virtual Machine Type model
Introduce `VirtualMachineType` to classify virtual machines and apply default platform, vCPU, and memory values when creating a VM. This adds the new model and its relationship to `VirtualMachine`, and wires it through forms, filtersets, tables, views, the REST API, GraphQL, navigation, search, documentation, and tests. Explicit values set on a virtual machine continue to take precedence, and changes to a type do not retroactively update existing VMs.
This commit is contained in:
@@ -74,6 +74,7 @@ These are considered the "core" application models which are used to model netwo
|
||||
* [tenancy.Tenant](../models/tenancy/tenant.md)
|
||||
* [virtualization.Cluster](../models/virtualization/cluster.md)
|
||||
* [virtualization.VirtualMachine](../models/virtualization/virtualmachine.md)
|
||||
* [virtualization.VirtualMachineType](../models/virtualization/virtualmachinetype.md)
|
||||
* [vpn.IKEPolicy](../models/vpn/ikepolicy.md)
|
||||
* [vpn.IKEProposal](../models/vpn/ikeproposal.md)
|
||||
* [vpn.IPSecPolicy](../models/vpn/ipsecpolicy.md)
|
||||
@@ -93,6 +94,7 @@ Organization models are used to organize and classify primary models.
|
||||
* [dcim.DeviceRole](../models/dcim/devicerole.md)
|
||||
* [dcim.Manufacturer](../models/dcim/manufacturer.md)
|
||||
* [dcim.Platform](../models/dcim/platform.md)
|
||||
* [dcim.RackGroup](../models/dcim/rackgroup.md)
|
||||
* [dcim.RackRole](../models/dcim/rackrole.md)
|
||||
* [ipam.ASNRange](../models/ipam/asnrange.md)
|
||||
* [ipam.RIR](../models/ipam/rir.md)
|
||||
|
||||
@@ -5,27 +5,37 @@ Virtual machines, clusters, and standalone hypervisors can be modeled in NetBox
|
||||
```mermaid
|
||||
flowchart TD
|
||||
ClusterGroup & ClusterType --> Cluster
|
||||
Cluster --> VirtualMachine
|
||||
VirtualMachineType --> VirtualMachine
|
||||
Device --> VirtualMachine
|
||||
Cluster --> VirtualMachine
|
||||
Platform --> VirtualMachine
|
||||
VirtualMachine --> VMInterface
|
||||
|
||||
click Cluster "../../models/virtualization/cluster/"
|
||||
click ClusterGroup "../../models/virtualization/clustergroup/"
|
||||
click ClusterType "../../models/virtualization/clustertype/"
|
||||
click Device "../../models/dcim/device/"
|
||||
click Platform "../../models/dcim/platform/"
|
||||
click VirtualMachine "../../models/virtualization/virtualmachine/"
|
||||
click VMInterface "../../models/virtualization/vminterface/"
|
||||
click Cluster "../../models/virtualization/cluster/"
|
||||
click ClusterGroup "../../models/virtualization/clustergroup/"
|
||||
click ClusterType "../../models/virtualization/clustertype/"
|
||||
click VirtualMachineType "../../models/virtualization/virtualmachinetype/"
|
||||
click Device "../../models/dcim/device/"
|
||||
click Platform "../../models/dcim/platform/"
|
||||
click VirtualMachine "../../models/virtualization/virtualmachine/"
|
||||
click VMInterface "../../models/virtualization/vminterface/"
|
||||
```
|
||||
|
||||
## Clusters
|
||||
|
||||
A cluster is one or more physical host devices on which virtual machines can run. Each cluster must have a type and operational status, and may be assigned to a group. (Both types and groups are user-defined.) Each cluster may designate one or more devices as hosts, however this is optional.
|
||||
A cluster is one or more physical host devices on which virtual machines can run.
|
||||
|
||||
Each cluster must have a type and operational status, and may be assigned to a group. (Both types and groups are user-defined.) Each cluster may designate one or more devices as hosts, however this is optional.
|
||||
|
||||
## Virtual Machine Types
|
||||
|
||||
A virtual machine type provides reusable classification for virtual machines and can define create-time defaults for platform, vCPUs, and memory. This is useful when multiple virtual machines share a common sizing or profile while still allowing per-instance overrides after creation.
|
||||
|
||||
## Virtual Machines
|
||||
|
||||
A virtual machine is a virtualized compute instance. These behave in NetBox very similarly to device objects, but without any physical attributes. For example, a VM may have interfaces assigned to it with IP addresses and VLANs, however its interfaces cannot be connected via cables (because they are virtual). Each VM may define its compute, memory, and storage resources as well.
|
||||
A virtual machine is a virtualized compute instance. These behave in NetBox very similarly to device objects, but without any physical attributes.
|
||||
|
||||
For example, a VM may have interfaces assigned to it with IP addresses and VLANs, however its interfaces cannot be connected via cables (because they are virtual). Each VM may define its compute, memory, and storage resources as well. A VM can optionally be assigned a [virtual machine type](../models/virtualization/virtualmachinetype.md) to classify it and provide default values for selected attributes at creation time.
|
||||
|
||||
A VM can be placed in one of three ways:
|
||||
|
||||
|
||||
@@ -13,6 +13,12 @@ The virtual machine's configured name. Must be unique within its scoping context
|
||||
- If assigned to a **cluster**: unique within the cluster and tenant.
|
||||
- If assigned to a **device** (no cluster): unique within the device and tenant.
|
||||
|
||||
### Type
|
||||
|
||||
The [virtual machine type](./virtualmachinetype.md) assigned to the VM. A type classifies a virtual machine and can provide default values for platform, vCPUs, and memory when the VM is created.
|
||||
|
||||
Changes made to a virtual machine type do **not** apply retroactively to existing virtual machines.
|
||||
|
||||
### Role
|
||||
|
||||
The functional role assigned to the VM.
|
||||
@@ -45,7 +51,7 @@ The location or host for this VM. At least one must be specified:
|
||||
|
||||
### Platform
|
||||
|
||||
A VM may be associated with a particular [platform](../dcim/platform.md) to indicate its operating system.
|
||||
A VM may be associated with a particular [platform](../dcim/platform.md) to indicate its operating system. If a virtual machine type defines a default platform, it will be applied when the VM is created unless an explicit platform is specified.
|
||||
|
||||
### Primary IPv4 & IPv6 Addresses
|
||||
|
||||
@@ -56,11 +62,11 @@ Each VM may designate one primary IPv4 address and/or one primary IPv6 address f
|
||||
|
||||
### vCPUs
|
||||
|
||||
The number of virtual CPUs provisioned. A VM may be allocated a partial vCPU count (e.g. 1.5 vCPU).
|
||||
The number of virtual CPUs provisioned. A VM may be allocated a partial vCPU count (e.g. 1.5 vCPU). If a virtual machine type defines a default vCPU allocation, it will be applied when the VM is created unless an explicit value is specified.
|
||||
|
||||
### Memory
|
||||
|
||||
The amount of running memory provisioned, in megabytes.
|
||||
The amount of running memory provisioned, in megabytes. If a virtual machine type defines a default memory allocation, it will be applied when the VM is created unless an explicit value is specified.
|
||||
|
||||
### Disk
|
||||
|
||||
|
||||
27
docs/models/virtualization/virtualmachinetype.md
Normal file
27
docs/models/virtualization/virtualmachinetype.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# Virtual Machine Types
|
||||
|
||||
A virtual machine type defines a reusable classification and default configuration for [virtual machines](./virtualmachine.md).
|
||||
|
||||
A type can optionally provide default values for a VM's [platform](../dcim/platform.md), vCPU allocation, and memory allocation. When a virtual machine is created with an assigned type, any unset values among these fields will inherit their defaults from the type. Changes made to a virtual machine type do **not** apply retroactively to existing virtual machines.
|
||||
|
||||
## Fields
|
||||
|
||||
### Name
|
||||
|
||||
A unique human-friendly name.
|
||||
|
||||
### Slug
|
||||
|
||||
A unique URL-friendly identifier. (This value can be used for filtering.)
|
||||
|
||||
### Default Platform
|
||||
|
||||
If defined, virtual machines instantiated with this type will automatically inherit the selected platform when no explicit platform is provided.
|
||||
|
||||
### Default vCPUs
|
||||
|
||||
The default number of vCPUs to assign when creating a virtual machine from this type.
|
||||
|
||||
### Default Memory
|
||||
|
||||
The default amount of memory, in megabytes, to assign when creating a virtual machine from this type.
|
||||
Reference in New Issue
Block a user