constants.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. from django.db.models import Q
  2. from .choices import FHRPGroupProtocolChoices, 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. # Also used for RouteTargets
  15. VRF_RD_MAX_LENGTH = 21
  16. #
  17. # Prefixes
  18. #
  19. PREFIX_LENGTH_MIN = 1
  20. PREFIX_LENGTH_MAX = 127 # IPv6
  21. #
  22. # IPAddresses
  23. #
  24. IPADDRESS_ASSIGNMENT_MODELS = Q(
  25. Q(app_label='dcim', model='interface') |
  26. Q(app_label='ipam', model='fhrpgroup') |
  27. Q(app_label='virtualization', model='vminterface')
  28. )
  29. IPADDRESS_MASK_LENGTH_MIN = 1
  30. IPADDRESS_MASK_LENGTH_MAX = 128 # IPv6
  31. IPADDRESS_ROLES_NONUNIQUE = (
  32. # IPAddress roles which are exempt from unique address enforcement
  33. IPAddressRoleChoices.ROLE_ANYCAST,
  34. IPAddressRoleChoices.ROLE_VIP,
  35. IPAddressRoleChoices.ROLE_VRRP,
  36. IPAddressRoleChoices.ROLE_HSRP,
  37. IPAddressRoleChoices.ROLE_GLBP,
  38. IPAddressRoleChoices.ROLE_CARP,
  39. )
  40. #
  41. # FHRP groups
  42. #
  43. FHRPGROUPASSIGNMENT_PRIORITY_MIN = 0
  44. FHRPGROUPASSIGNMENT_PRIORITY_MAX = 255
  45. FHRP_PROTOCOL_ROLE_MAPPINGS = {
  46. FHRPGroupProtocolChoices.PROTOCOL_VRRP2: IPAddressRoleChoices.ROLE_VRRP,
  47. FHRPGroupProtocolChoices.PROTOCOL_VRRP3: IPAddressRoleChoices.ROLE_VRRP,
  48. FHRPGroupProtocolChoices.PROTOCOL_HSRP: IPAddressRoleChoices.ROLE_HSRP,
  49. FHRPGroupProtocolChoices.PROTOCOL_GLBP: IPAddressRoleChoices.ROLE_GLBP,
  50. FHRPGroupProtocolChoices.PROTOCOL_CARP: IPAddressRoleChoices.ROLE_CARP,
  51. }
  52. #
  53. # VLANs
  54. #
  55. # 12-bit VLAN ID (values 0 and 4095 are reserved)
  56. VLAN_VID_MIN = 1
  57. VLAN_VID_MAX = 4094
  58. # models values for ContentTypes which may be VLANGroup scope types
  59. VLANGROUP_SCOPE_TYPES = (
  60. 'region', 'sitegroup', 'site', 'location', 'rack', 'clustergroup', 'cluster',
  61. )
  62. #
  63. # Services
  64. #
  65. # 16-bit port number
  66. SERVICE_PORT_MIN = 1
  67. SERVICE_PORT_MAX = 65535