mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-22 21:32:23 -06:00
@@ -7,7 +7,7 @@ from django.utils.translation import gettext_lazy as _
|
||||
from core.models import ObjectType
|
||||
from netbox.models import NetBoxModel, PrimaryModel
|
||||
from netbox.models.features import ContactsMixin
|
||||
from vpn.choices import L2VPNTypeChoices
|
||||
from vpn.choices import L2VPNStatusChoices, L2VPNTypeChoices
|
||||
from vpn.constants import L2VPN_ASSIGNMENT_MODELS
|
||||
|
||||
__all__ = (
|
||||
@@ -33,6 +33,12 @@ class L2VPN(ContactsMixin, PrimaryModel):
|
||||
max_length=50,
|
||||
choices=L2VPNTypeChoices
|
||||
)
|
||||
status = models.CharField(
|
||||
verbose_name=_('status'),
|
||||
max_length=50,
|
||||
choices=L2VPNStatusChoices,
|
||||
default=L2VPNStatusChoices.STATUS_ACTIVE,
|
||||
)
|
||||
identifier = models.BigIntegerField(
|
||||
verbose_name=_('identifier'),
|
||||
null=True,
|
||||
@@ -56,7 +62,7 @@ class L2VPN(ContactsMixin, PrimaryModel):
|
||||
null=True
|
||||
)
|
||||
|
||||
clone_fields = ('type',)
|
||||
clone_fields = ('type', 'status')
|
||||
|
||||
class Meta:
|
||||
ordering = ('name', 'identifier')
|
||||
@@ -68,6 +74,9 @@ class L2VPN(ContactsMixin, PrimaryModel):
|
||||
return f'{self.name} ({self.identifier})'
|
||||
return f'{self.name}'
|
||||
|
||||
def get_status_color(self):
|
||||
return L2VPNStatusChoices.colors.get(self.status)
|
||||
|
||||
@cached_property
|
||||
def can_add_termination(self):
|
||||
if self.type in L2VPNTypeChoices.P2P and self.terminations.count() >= 2:
|
||||
|
||||
Reference in New Issue
Block a user