1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #5975: Allow partial vCPU allocations for virtual machines

This commit is contained in:
Jeremy Stretch
2021-03-16 11:52:59 -04:00
parent 46a024441c
commit 2bb4a81e23
4 changed files with 31 additions and 3 deletions

View File

@ -11,4 +11,6 @@ Like devices, each VM can be assigned a platform and/or functional role, and mus
* Failed
* Decommissioning
Additional fields are available for annotating the vCPU count, memory (GB), and disk (GB) allocated to each VM. Each VM may optionally be assigned to a tenant. Virtual machines may have virtual interfaces assigned to them, but do not support any physical component.
Additional fields are available for annotating the vCPU count, memory (GB), and disk (GB) allocated to each VM. A VM may be allocated a partial vCPU count (e.g. 1.5 vCPU).
Each VM may optionally be assigned to a tenant. Virtual machines may have virtual interfaces assigned to them, but do not support any physical component.

View File

@ -79,6 +79,7 @@ The ObjectChange model (which is used to record the creation, modification, and
* [#5895](https://github.com/netbox-community/netbox/issues/5895) - Rename RackGroup to Location
* [#5901](https://github.com/netbox-community/netbox/issues/5901) - Add `created` and `last_updated` fields to device component models
* [#5972](https://github.com/netbox-community/netbox/issues/5972) - Enable bulk editing for organizational models
* [#5975](https://github.com/netbox-community/netbox/issues/5975) - Allow partial vCPU allocations for virtual machines
### Other Changes
@ -129,3 +130,5 @@ The ObjectChange model (which is used to record the creation, modification, and
* ipam.VLANGroup
* Added the `scope_type`, `scope_id`, and `scope` fields (`scope` is a generic foreign key)
* Dropped the `site` foreign key field
* virtualization.VirtualMachine
* `vcpus` has been changed from an integer to a decimal value

View File

@ -0,0 +1,17 @@
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('virtualization', '0020_standardize_models'),
]
operations = [
migrations.AlterField(
model_name='virtualmachine',
name='vcpus',
field=models.DecimalField(blank=True, decimal_places=2, max_digits=6, null=True, validators=[django.core.validators.MinValueValidator(0.01)]),
),
]

View File

@ -1,6 +1,7 @@
from django.conf import settings
from django.contrib.contenttypes.fields import GenericRelation
from django.core.exceptions import ValidationError
from django.core.validators import MinValueValidator
from django.db import models
from django.urls import reverse
@ -255,10 +256,15 @@ class VirtualMachine(PrimaryModel, ConfigContextModel):
null=True,
verbose_name='Primary IPv6'
)
vcpus = models.PositiveSmallIntegerField(
vcpus = models.DecimalField(
max_digits=6,
decimal_places=2,
blank=True,
null=True,
verbose_name='vCPUs'
verbose_name='vCPUs',
validators=(
MinValueValidator(0.01),
)
)
memory = models.PositiveIntegerField(
blank=True,