|
|
@@ -4,7 +4,7 @@ from django.test import TestCase
|
|
|
from dcim.choices import *
|
|
|
from dcim.filtersets import *
|
|
|
from dcim.models import *
|
|
|
-from ipam.models import ASN, IPAddress, RIR
|
|
|
+from ipam.models import ASN, IPAddress, RIR, VRF
|
|
|
from tenancy.models import Tenant, TenantGroup
|
|
|
from utilities.choices import ColorChoices
|
|
|
from utilities.testing import ChangeLoggedFilterSetTests, create_test_device
|
|
|
@@ -2370,15 +2370,22 @@ class InterfaceTestCase(TestCase, ChangeLoggedFilterSetTests):
|
|
|
)
|
|
|
Device.objects.bulk_create(devices)
|
|
|
|
|
|
+ vrfs = (
|
|
|
+ VRF(name='VRF 1', rd='65000:1'),
|
|
|
+ VRF(name='VRF 2', rd='65000:2'),
|
|
|
+ VRF(name='VRF 3', rd='65000:3'),
|
|
|
+ )
|
|
|
+ VRF.objects.bulk_create(vrfs)
|
|
|
+
|
|
|
# VirtualChassis assignment for filtering
|
|
|
virtual_chassis = VirtualChassis.objects.create(master=devices[0])
|
|
|
Device.objects.filter(pk=devices[0].pk).update(virtual_chassis=virtual_chassis, vc_position=1, vc_priority=1)
|
|
|
Device.objects.filter(pk=devices[1].pk).update(virtual_chassis=virtual_chassis, vc_position=2, vc_priority=2)
|
|
|
|
|
|
interfaces = (
|
|
|
- Interface(device=devices[0], name='Interface 1', label='A', type=InterfaceTypeChoices.TYPE_1GE_SFP, enabled=True, mgmt_only=True, mtu=100, mode=InterfaceModeChoices.MODE_ACCESS, mac_address='00-00-00-00-00-01', description='First'),
|
|
|
- Interface(device=devices[1], name='Interface 2', label='B', type=InterfaceTypeChoices.TYPE_1GE_GBIC, enabled=True, mgmt_only=True, mtu=200, mode=InterfaceModeChoices.MODE_TAGGED, mac_address='00-00-00-00-00-02', description='Second'),
|
|
|
- Interface(device=devices[2], name='Interface 3', label='C', type=InterfaceTypeChoices.TYPE_1GE_FIXED, enabled=False, mgmt_only=False, mtu=300, mode=InterfaceModeChoices.MODE_TAGGED_ALL, mac_address='00-00-00-00-00-03', description='Third'),
|
|
|
+ Interface(device=devices[0], name='Interface 1', label='A', type=InterfaceTypeChoices.TYPE_1GE_SFP, enabled=True, mgmt_only=True, mtu=100, mode=InterfaceModeChoices.MODE_ACCESS, mac_address='00-00-00-00-00-01', description='First', vrf=vrfs[0]),
|
|
|
+ Interface(device=devices[1], name='Interface 2', label='B', type=InterfaceTypeChoices.TYPE_1GE_GBIC, enabled=True, mgmt_only=True, mtu=200, mode=InterfaceModeChoices.MODE_TAGGED, mac_address='00-00-00-00-00-02', description='Second', vrf=vrfs[1]),
|
|
|
+ Interface(device=devices[2], name='Interface 3', label='C', type=InterfaceTypeChoices.TYPE_1GE_FIXED, enabled=False, mgmt_only=False, mtu=300, mode=InterfaceModeChoices.MODE_TAGGED_ALL, mac_address='00-00-00-00-00-03', description='Third', vrf=vrfs[2]),
|
|
|
Interface(device=devices[3], name='Interface 4', label='D', type=InterfaceTypeChoices.TYPE_OTHER, enabled=True, mgmt_only=True, tx_power=40),
|
|
|
Interface(device=devices[3], name='Interface 5', label='E', type=InterfaceTypeChoices.TYPE_OTHER, enabled=True, mgmt_only=True, tx_power=40),
|
|
|
Interface(device=devices[3], name='Interface 6', label='F', type=InterfaceTypeChoices.TYPE_OTHER, enabled=False, mgmt_only=False, tx_power=40),
|
|
|
@@ -2550,6 +2557,13 @@ class InterfaceTestCase(TestCase, ChangeLoggedFilterSetTests):
|
|
|
params = {'tx_power': [40]}
|
|
|
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 3)
|
|
|
|
|
|
+ def test_vrf(self):
|
|
|
+ vrfs = VRF.objects.all()[:2]
|
|
|
+ params = {'vrf_id': [vrfs[0].pk, vrfs[1].pk]}
|
|
|
+ self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
|
|
+ params = {'vrf': [vrfs[0].rd, vrfs[1].rd]}
|
|
|
+ self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
|
|
+
|
|
|
|
|
|
class FrontPortTestCase(TestCase, ChangeLoggedFilterSetTests):
|
|
|
queryset = FrontPort.objects.all()
|