constants.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. from django.db.models import Q
  2. from .choices import IPAddressRoleChoices
  3. # BGP ASN bounds
  4. BGP_ASN_MIN = 1
  5. BGP_ASN_MAX = 2**32 - 1
  6. #
  7. # VRFs
  8. #
  9. # Per RFC 4364 section 4.2, a route distinguisher may be encoded as one of the following:
  10. # * Type 0 (16-bit AS number : 32-bit integer)
  11. # * Type 1 (32-bit IPv4 address : 16-bit integer)
  12. # * Type 2 (32-bit AS number : 16-bit integer)
  13. # 21 characters are sufficient to convey the longest possible string value (255.255.255.255:65535)
  14. VRF_RD_MAX_LENGTH = 21
  15. #
  16. # Prefixes
  17. #
  18. PREFIX_LENGTH_MIN = 1
  19. PREFIX_LENGTH_MAX = 127 # IPv6
  20. #
  21. # IPAddresses
  22. #
  23. IPADDRESS_ASSIGNMENT_MODELS = Q(
  24. Q(app_label='dcim', model='interface') |
  25. Q(app_label='virtualization', model='vminterface')
  26. )
  27. IPADDRESS_MASK_LENGTH_MIN = 1
  28. IPADDRESS_MASK_LENGTH_MAX = 128 # IPv6
  29. IPADDRESS_ROLES_NONUNIQUE = (
  30. # IPAddress roles which are exempt from unique address enforcement
  31. IPAddressRoleChoices.ROLE_ANYCAST,
  32. IPAddressRoleChoices.ROLE_VIP,
  33. IPAddressRoleChoices.ROLE_VRRP,
  34. IPAddressRoleChoices.ROLE_HSRP,
  35. IPAddressRoleChoices.ROLE_GLBP,
  36. IPAddressRoleChoices.ROLE_CARP,
  37. )
  38. #
  39. # VLANs
  40. #
  41. # 12-bit VLAN ID (values 0 and 4095 are reserved)
  42. VLAN_VID_MIN = 1
  43. VLAN_VID_MAX = 4094
  44. #
  45. # Services
  46. #
  47. # 16-bit port number
  48. SERVICE_PORT_MIN = 1
  49. SERVICE_PORT_MAX = 65535