constants.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. from django.db.models import Q
  2. from .choices import FHRPGroupProtocolChoices, IPAddressRoleChoices
  3. #
  4. # VRFs
  5. #
  6. # Per RFC 4364 section 4.2, a route distinguisher may be encoded as one of the following:
  7. # * Type 0 (16-bit AS number : 32-bit integer)
  8. # * Type 1 (32-bit IPv4 address : 16-bit integer)
  9. # * Type 2 (32-bit AS number : 16-bit integer)
  10. # 21 characters are sufficient to convey the longest possible string value (255.255.255.255:65535)
  11. # Also used for RouteTargets
  12. VRF_RD_MAX_LENGTH = 21
  13. #
  14. # Prefixes
  15. #
  16. PREFIX_LENGTH_MIN = 1
  17. PREFIX_LENGTH_MAX = 127 # IPv6
  18. #
  19. # IPAddresses
  20. #
  21. IPADDRESS_ASSIGNMENT_MODELS = Q(
  22. Q(app_label='dcim', model='interface') |
  23. Q(app_label='ipam', model='fhrpgroup') |
  24. Q(app_label='virtualization', model='vminterface')
  25. )
  26. IPADDRESS_MASK_LENGTH_MIN = 1
  27. IPADDRESS_MASK_LENGTH_MAX = 128 # IPv6
  28. IPADDRESS_ROLES_NONUNIQUE = (
  29. # IPAddress roles which are exempt from unique address enforcement
  30. IPAddressRoleChoices.ROLE_ANYCAST,
  31. IPAddressRoleChoices.ROLE_VIP,
  32. IPAddressRoleChoices.ROLE_VRRP,
  33. IPAddressRoleChoices.ROLE_HSRP,
  34. IPAddressRoleChoices.ROLE_GLBP,
  35. IPAddressRoleChoices.ROLE_CARP,
  36. )
  37. #
  38. # FHRP groups
  39. #
  40. FHRPGROUPASSIGNMENT_PRIORITY_MIN = 0
  41. FHRPGROUPASSIGNMENT_PRIORITY_MAX = 255
  42. FHRP_PROTOCOL_ROLE_MAPPINGS = {
  43. FHRPGroupProtocolChoices.PROTOCOL_VRRP2: IPAddressRoleChoices.ROLE_VRRP,
  44. FHRPGroupProtocolChoices.PROTOCOL_VRRP3: IPAddressRoleChoices.ROLE_VRRP,
  45. FHRPGroupProtocolChoices.PROTOCOL_HSRP: IPAddressRoleChoices.ROLE_HSRP,
  46. FHRPGroupProtocolChoices.PROTOCOL_GLBP: IPAddressRoleChoices.ROLE_GLBP,
  47. FHRPGroupProtocolChoices.PROTOCOL_CARP: IPAddressRoleChoices.ROLE_CARP,
  48. FHRPGroupProtocolChoices.PROTOCOL_OTHER: IPAddressRoleChoices.ROLE_VIP,
  49. }
  50. #
  51. # VLANs
  52. #
  53. # 12-bit VLAN ID (values 0 and 4095 are reserved)
  54. VLAN_VID_MIN = 1
  55. VLAN_VID_MAX = 4094
  56. # models values for ContentTypes which may be VLANGroup scope types
  57. VLANGROUP_SCOPE_TYPES = (
  58. 'region', 'sitegroup', 'site', 'location', 'rack', 'clustergroup', 'cluster',
  59. )
  60. #
  61. # Services
  62. #
  63. SERVICE_ASSIGNMENT_MODELS = Q(
  64. Q(app_label='dcim', model='device') |
  65. Q(app_label='ipam', model='fhrpgroup') |
  66. Q(app_label='virtualization', model='virtualmachine')
  67. )
  68. # 16-bit port number
  69. SERVICE_PORT_MIN = 1
  70. SERVICE_PORT_MAX = 65535