mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-29 11:56:25 -06:00
Address PR feedback
This commit is contained in:
parent
cf72b7cb63
commit
0d3016f287
@ -567,7 +567,7 @@ class BaseInterface(models.Model):
|
||||
related_name='%(class)ss_svlan',
|
||||
null=True,
|
||||
blank=True,
|
||||
verbose_name=_('Q-inQ SVLAN')
|
||||
verbose_name=_('Q-in-Q SVLAN')
|
||||
)
|
||||
|
||||
class Meta:
|
||||
|
@ -282,6 +282,12 @@ class VLAN(PrimaryModel):
|
||||
'qinq_svlan': _("Only Q-in-Q customer VLANs maybe assigned to a service VLAN.")
|
||||
})
|
||||
|
||||
# A Q-in-Q customer VLAN must be assigned to a service VLAN
|
||||
if self.qinq_role == VLANQinQRoleChoices.ROLE_CUSTOMER and not self.qinq_svlan:
|
||||
raise ValidationError({
|
||||
'qinq_role': _("A Q-in-Q customer VLAN must be assigned to a service VLAN.")
|
||||
})
|
||||
|
||||
def get_status_color(self):
|
||||
return VLANStatusChoices.colors.get(self.status)
|
||||
|
||||
|
@ -586,3 +586,24 @@ class TestVLANGroup(TestCase):
|
||||
vlangroup.vid_ranges = string_to_ranges('2-2')
|
||||
vlangroup.full_clean()
|
||||
vlangroup.save()
|
||||
|
||||
|
||||
class TestVLAN(TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
VLAN.objects.bulk_create((
|
||||
VLAN(name='VLAN 1', vid=1, qinq_role=VLANQinQRoleChoices.ROLE_SERVICE),
|
||||
))
|
||||
|
||||
def test_qinq_role(self):
|
||||
svlan = VLAN.objects.filter(qinq_role=VLANQinQRoleChoices.ROLE_SERVICE).first()
|
||||
|
||||
vlan = VLAN(
|
||||
name='VLAN X',
|
||||
vid=999,
|
||||
qinq_role=VLANQinQRoleChoices.ROLE_SERVICE,
|
||||
qinq_svlan=svlan
|
||||
)
|
||||
with self.assertRaises(ValidationError):
|
||||
vlan.full_clean()
|
||||
|
Loading…
Reference in New Issue
Block a user