mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
#7852: Extend VRF assignment to VM interfaces
This commit is contained in:
@ -2,7 +2,7 @@ from django.urls import reverse
|
||||
from rest_framework import status
|
||||
|
||||
from dcim.choices import InterfaceModeChoices
|
||||
from ipam.models import VLAN
|
||||
from ipam.models import VLAN, VRF
|
||||
from utilities.testing import APITestCase, APIViewTestCases
|
||||
from virtualization.models import Cluster, ClusterGroup, ClusterType, VirtualMachine, VMInterface
|
||||
|
||||
@ -234,6 +234,13 @@ class VMInterfaceTest(APIViewTestCases.APIViewTestCase):
|
||||
)
|
||||
VLAN.objects.bulk_create(vlans)
|
||||
|
||||
vrfs = (
|
||||
VRF(name='VRF 1'),
|
||||
VRF(name='VRF 2'),
|
||||
VRF(name='VRF 3'),
|
||||
)
|
||||
VRF.objects.bulk_create(vrfs)
|
||||
|
||||
cls.create_data = [
|
||||
{
|
||||
'virtual_machine': virtualmachine.pk,
|
||||
@ -241,6 +248,7 @@ class VMInterfaceTest(APIViewTestCases.APIViewTestCase):
|
||||
'mode': InterfaceModeChoices.MODE_TAGGED,
|
||||
'tagged_vlans': [vlans[0].pk, vlans[1].pk],
|
||||
'untagged_vlan': vlans[2].pk,
|
||||
'vrf': vrfs[0].pk,
|
||||
},
|
||||
{
|
||||
'virtual_machine': virtualmachine.pk,
|
||||
@ -249,6 +257,7 @@ class VMInterfaceTest(APIViewTestCases.APIViewTestCase):
|
||||
'bridge': interfaces[0].pk,
|
||||
'tagged_vlans': [vlans[0].pk, vlans[1].pk],
|
||||
'untagged_vlan': vlans[2].pk,
|
||||
'vrf': vrfs[1].pk,
|
||||
},
|
||||
{
|
||||
'virtual_machine': virtualmachine.pk,
|
||||
@ -257,5 +266,6 @@ class VMInterfaceTest(APIViewTestCases.APIViewTestCase):
|
||||
'parent': interfaces[1].pk,
|
||||
'tagged_vlans': [vlans[0].pk, vlans[1].pk],
|
||||
'untagged_vlan': vlans[2].pk,
|
||||
'vrf': vrfs[2].pk,
|
||||
},
|
||||
]
|
||||
|
Reference in New Issue
Block a user