constants.py 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. FHRPGroupProtocolChoices.PROTOCOL_OTHER: IPAddressRoleChoices.ROLE_VIP,
  52. }
  53. #
  54. # VLANs
  55. #
  56. # 12-bit VLAN ID (values 0 and 4095 are reserved)
  57. VLAN_VID_MIN = 1
  58. VLAN_VID_MAX = 4094
  59. # models values for ContentTypes which may be VLANGroup scope types
  60. VLANGROUP_SCOPE_TYPES = (
  61. 'region', 'sitegroup', 'site', 'location', 'rack', 'clustergroup', 'cluster',
  62. )
  63. #
  64. # Services
  65. #
  66. # 16-bit port number
  67. SERVICE_PORT_MIN = 1
  68. SERVICE_PORT_MAX = 65535
  69. L2VPN_ASSIGNMENT_MODELS = Q(
  70. Q(app_label='dcim', model='interface') |
  71. Q(app_label='ipam', model='vlan') |
  72. Q(app_label='virtualization', model='vminterface')
  73. )