mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Replaced ASN bounds with constants
This commit is contained in:
@ -1,4 +1,8 @@
|
|||||||
|
|
||||||
|
# BGP ASN bounds
|
||||||
|
BGP_ASN_MIN = 1
|
||||||
|
BGP_ASN_MAX = 2**32 - 1
|
||||||
|
|
||||||
# Rack types
|
# Rack types
|
||||||
RACK_TYPE_2POST = 100
|
RACK_TYPE_2POST = 100
|
||||||
RACK_TYPE_4POST = 200
|
RACK_TYPE_4POST = 200
|
||||||
|
@ -3,16 +3,18 @@ from django.core.validators import MinValueValidator, MaxValueValidator
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from netaddr import AddrFormatError, EUI, mac_unix_expanded
|
from netaddr import AddrFormatError, EUI, mac_unix_expanded
|
||||||
|
|
||||||
|
from .constants import *
|
||||||
|
|
||||||
|
|
||||||
class ASNField(models.BigIntegerField):
|
class ASNField(models.BigIntegerField):
|
||||||
description = "32-bit ASN field"
|
description = "32-bit ASN field"
|
||||||
default_validators = [
|
default_validators = [
|
||||||
MinValueValidator(1),
|
MinValueValidator(BGP_ASN_MIN),
|
||||||
MaxValueValidator(4294967295),
|
MaxValueValidator(BGP_ASN_MAX),
|
||||||
]
|
]
|
||||||
|
|
||||||
def formfield(self, **kwargs):
|
def formfield(self, **kwargs):
|
||||||
defaults = {'min_value': 1, 'max_value': 4294967295}
|
defaults = {'min_value': BGP_ASN_MIN, 'max_value': BGP_ASN_MAX}
|
||||||
defaults.update(**kwargs)
|
defaults.update(**kwargs)
|
||||||
return super().formfield(**defaults)
|
return super().formfield(**defaults)
|
||||||
|
|
||||||
|
@ -292,8 +292,8 @@ class SiteBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldBulkEditFor
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
asn = forms.IntegerField(
|
asn = forms.IntegerField(
|
||||||
min_value=1,
|
min_value=BGP_ASN_MIN,
|
||||||
max_value=4294967295,
|
max_value=BGP_ASN_MAX,
|
||||||
required=False,
|
required=False,
|
||||||
label='ASN'
|
label='ASN'
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user