constants.py 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. import re
  2. from django.db.models import Q
  3. from .choices import InterfaceLAGModeChoices, InterfaceTypeChoices
  4. # Exclude SVG images (unsupported by PIL)
  5. DEVICETYPE_IMAGE_FORMATS = 'image/bmp,image/gif,image/jpeg,image/png,image/tiff,image/webp'
  6. #
  7. # Sites
  8. #
  9. # WGS84 semi-major axis (meters), used as the sphere radius for Web Mercator (EPSG:3857)
  10. WEB_MERCATOR_EARTH_RADIUS = 6378137
  11. # Latitude bounds of Web Mercator, at which the projection is square
  12. WEB_MERCATOR_MAX_LATITUDE = 85.05112877980659
  13. #
  14. # Racks
  15. #
  16. RACK_U_HEIGHT_DEFAULT = 42
  17. RACK_U_HEIGHT_MAX = 100
  18. RACK_ELEVATION_BORDER_WIDTH = 2
  19. RACK_ELEVATION_DEFAULT_LEGEND_WIDTH = 30
  20. RACK_ELEVATION_DEFAULT_MARGIN_WIDTH = 15
  21. RACK_STARTING_UNIT_DEFAULT = 1
  22. #
  23. # Cables
  24. #
  25. CABLE_CONNECTOR_MIN = 1
  26. CABLE_CONNECTOR_MAX = 256
  27. CABLE_POSITION_MIN = 1
  28. CABLE_POSITION_MAX = 1024
  29. #
  30. # RearPorts
  31. #
  32. PORT_POSITION_MIN = 1
  33. PORT_POSITION_MAX = 1024
  34. #
  35. # Interfaces
  36. #
  37. INTERFACE_MTU_MIN = 1
  38. INTERFACE_MTU_MAX = 65536
  39. # The number of channels on a channelized interface, and the channel to which a subinterface is bound. A subinterface's
  40. # channel_id maps directly to a position on the parent interface's cable connector, so these are bounded by the maximum
  41. # cable position.
  42. INTERFACE_CHANNELS_MIN = CABLE_POSITION_MIN
  43. INTERFACE_CHANNELS_MAX = CABLE_POSITION_MAX
  44. VIRTUAL_IFACE_TYPES = [
  45. InterfaceTypeChoices.TYPE_VIRTUAL,
  46. InterfaceTypeChoices.TYPE_LAG,
  47. InterfaceTypeChoices.TYPE_BRIDGE,
  48. ]
  49. WIRELESS_IFACE_TYPES = [
  50. InterfaceTypeChoices.TYPE_80211A,
  51. InterfaceTypeChoices.TYPE_80211G,
  52. InterfaceTypeChoices.TYPE_80211N,
  53. InterfaceTypeChoices.TYPE_80211AC,
  54. InterfaceTypeChoices.TYPE_80211AD,
  55. InterfaceTypeChoices.TYPE_80211AX,
  56. InterfaceTypeChoices.TYPE_80211AY,
  57. InterfaceTypeChoices.TYPE_80211BE,
  58. InterfaceTypeChoices.TYPE_802151,
  59. InterfaceTypeChoices.TYPE_802154,
  60. InterfaceTypeChoices.TYPE_OTHER_WIRELESS,
  61. InterfaceTypeChoices.TYPE_GSM,
  62. InterfaceTypeChoices.TYPE_CDMA,
  63. InterfaceTypeChoices.TYPE_LTE,
  64. InterfaceTypeChoices.TYPE_4G,
  65. InterfaceTypeChoices.TYPE_5G,
  66. ]
  67. NONCONNECTABLE_IFACE_TYPES = VIRTUAL_IFACE_TYPES + WIRELESS_IFACE_TYPES + [
  68. # Channel subinterfaces derive their cable from the (channelized) parent interface and cannot be cabled directly
  69. InterfaceTypeChoices.TYPE_CHANNEL,
  70. ]
  71. # LAG modes which select a member interface by transmit hash (Linux bonding xmit_hash_policy)
  72. LAG_HASH_MODES = (
  73. InterfaceLAGModeChoices.MODE_LACP,
  74. InterfaceLAGModeChoices.MODE_STATIC,
  75. )
  76. #
  77. # MAC blocks
  78. #
  79. MACBLOCK_LENGTH_MIN = 1
  80. MACBLOCK_LENGTH_MAX = 48
  81. MACBLOCK_LENGTH_DEFAULT = 24 # An organizationally unique identifier (OUI)
  82. #
  83. # Device components
  84. #
  85. MODULE_TOKEN = '{module}'
  86. VC_POSITION_RE = re.compile(r'\{vc_position(?::([^}]*))?\}')
  87. MODULAR_COMPONENT_TEMPLATE_MODELS = Q(
  88. app_label='dcim',
  89. model__in=(
  90. 'consoleporttemplate',
  91. 'consoleserverporttemplate',
  92. 'coolingintaketemplate',
  93. 'coolingoutflowtemplate',
  94. 'frontporttemplate',
  95. 'interfacetemplate',
  96. 'poweroutlettemplate',
  97. 'powerporttemplate',
  98. 'rearporttemplate',
  99. ))
  100. MODULAR_COMPONENT_MODELS = Q(
  101. app_label='dcim',
  102. model__in=(
  103. 'consoleport',
  104. 'consoleserverport',
  105. 'coolingintake',
  106. 'coolingoutflow',
  107. 'frontport',
  108. 'interface',
  109. 'poweroutlet',
  110. 'powerport',
  111. 'rearport',
  112. ))
  113. #
  114. # Cabling and connections
  115. #
  116. CABLE_TRACE_SVG_DEFAULT_WIDTH = 400
  117. # Cable endpoint types
  118. CABLE_TERMINATION_MODELS = Q(
  119. Q(app_label='circuits', model__in=(
  120. 'circuittermination',
  121. )) |
  122. Q(app_label='dcim', model__in=(
  123. 'consoleport',
  124. 'consoleserverport',
  125. 'frontport',
  126. 'interface',
  127. 'powerfeed',
  128. 'poweroutlet',
  129. 'powerport',
  130. 'rearport',
  131. ))
  132. )
  133. COMPATIBLE_TERMINATION_TYPES = {
  134. 'circuittermination': ['interface', 'frontport', 'rearport', 'circuittermination'],
  135. 'consoleport': ['consoleserverport', 'frontport', 'rearport'],
  136. 'consoleserverport': ['consoleport', 'frontport', 'rearport'],
  137. 'interface': ['interface', 'circuittermination', 'frontport', 'rearport'],
  138. 'frontport': ['consoleport', 'consoleserverport', 'interface', 'frontport', 'rearport', 'circuittermination'],
  139. 'powerfeed': ['powerport'],
  140. 'poweroutlet': ['powerport'],
  141. 'powerport': ['poweroutlet', 'powerfeed'],
  142. 'rearport': ['consoleport', 'consoleserverport', 'interface', 'frontport', 'rearport', 'circuittermination'],
  143. }
  144. # Models which can serve to scope an object by location
  145. LOCATION_SCOPE_TYPES = (
  146. 'region', 'sitegroup', 'site', 'location',
  147. )
  148. #
  149. # MAC addresses
  150. #
  151. MACADDRESS_ASSIGNMENT_MODELS = Q(
  152. Q(app_label='dcim', model='interface') |
  153. Q(app_label='virtualization', model='vminterface')
  154. )