mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-18 21:16:27 -06:00
Merge pull request #3879 from hSaria/3876-asn-field-bounds
Fixes #3876: Min/max values for ASN field
This commit is contained in:
commit
789cf827f2
@ -22,6 +22,7 @@
|
|||||||
* [#3862](https://github.com/netbox-community/netbox/issues/3862) - Allow filtering device components by multiple device names
|
* [#3862](https://github.com/netbox-community/netbox/issues/3862) - Allow filtering device components by multiple device names
|
||||||
* [#3864](https://github.com/netbox-community/netbox/issues/3864) - Disallow /0 masks
|
* [#3864](https://github.com/netbox-community/netbox/issues/3864) - Disallow /0 masks
|
||||||
* [#3872](https://github.com/netbox-community/netbox/issues/3872) - Paginate related IPs of an address
|
* [#3872](https://github.com/netbox-community/netbox/issues/3872) - Paginate related IPs of an address
|
||||||
|
* [#3876](https://github.com/netbox-community/netbox/issues/3876) - Fixed min/max to ASN input field at the site creation page
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -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,14 +3,21 @@ 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):
|
||||||
|
defaults = {'min_value': BGP_ASN_MIN, 'max_value': BGP_ASN_MAX}
|
||||||
|
defaults.update(**kwargs)
|
||||||
|
return super().formfield(**defaults)
|
||||||
|
|
||||||
|
|
||||||
class mac_unix_expanded_uppercase(mac_unix_expanded):
|
class mac_unix_expanded_uppercase(mac_unix_expanded):
|
||||||
word_fmt = '%.2X'
|
word_fmt = '%.2X'
|
||||||
|
@ -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'
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user