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

Closes #8222: Enable the assignment of a VM to a specific host device within a cluster

This commit is contained in:
jeremystretch
2022-05-25 16:01:10 -04:00
parent 31024ce672
commit b331f047af
17 changed files with 155 additions and 48 deletions

View File

@ -1,5 +1,5 @@
from dcim.choices import InterfaceModeChoices
from dcim.models import DeviceRole, Platform, Site
from dcim.models import Device, DeviceRole, Platform, Site
from ipam.models import VRF
from netbox.forms import NetBoxModelCSVForm
from tenancy.models import Tenant
@ -76,6 +76,12 @@ class VirtualMachineCSVForm(NetBoxModelCSVForm):
to_field_name='name',
help_text='Assigned cluster'
)
device = CSVModelChoiceField(
queryset=Device.objects.all(),
to_field_name='name',
required=False,
help_text='Assigned device within cluster'
)
role = CSVModelChoiceField(
queryset=DeviceRole.objects.filter(
vm_role=True
@ -100,7 +106,7 @@ class VirtualMachineCSVForm(NetBoxModelCSVForm):
class Meta:
model = VirtualMachine
fields = (
'name', 'status', 'role', 'cluster', 'tenant', 'platform', 'vcpus', 'memory', 'disk', 'comments',
'name', 'status', 'role', 'cluster', 'device', 'tenant', 'platform', 'vcpus', 'memory', 'disk', 'comments',
)