constants.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. import re
  2. from django.db.models import Q
  3. from .choices import 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. # Racks
  8. #
  9. RACK_U_HEIGHT_DEFAULT = 42
  10. RACK_U_HEIGHT_MAX = 100
  11. RACK_ELEVATION_BORDER_WIDTH = 2
  12. RACK_ELEVATION_DEFAULT_LEGEND_WIDTH = 30
  13. RACK_ELEVATION_DEFAULT_MARGIN_WIDTH = 15
  14. RACK_STARTING_UNIT_DEFAULT = 1
  15. #
  16. # Cables
  17. #
  18. CABLE_CONNECTOR_MIN = 1
  19. CABLE_CONNECTOR_MAX = 256
  20. CABLE_POSITION_MIN = 1
  21. CABLE_POSITION_MAX = 1024
  22. #
  23. # RearPorts
  24. #
  25. PORT_POSITION_MIN = 1
  26. PORT_POSITION_MAX = 1024
  27. #
  28. # Interfaces
  29. #
  30. INTERFACE_MTU_MIN = 1
  31. INTERFACE_MTU_MAX = 65536
  32. # The number of channels on a channelized interface, and the channel to which a subinterface is bound. A subinterface's
  33. # channel_id maps directly to a position on the parent interface's cable connector, so these are bounded by the maximum
  34. # cable position.
  35. INTERFACE_CHANNELS_MIN = CABLE_POSITION_MIN
  36. INTERFACE_CHANNELS_MAX = CABLE_POSITION_MAX
  37. VIRTUAL_IFACE_TYPES = [
  38. InterfaceTypeChoices.TYPE_VIRTUAL,
  39. InterfaceTypeChoices.TYPE_LAG,
  40. InterfaceTypeChoices.TYPE_BRIDGE,
  41. ]
  42. WIRELESS_IFACE_TYPES = [
  43. InterfaceTypeChoices.TYPE_80211A,
  44. InterfaceTypeChoices.TYPE_80211G,
  45. InterfaceTypeChoices.TYPE_80211N,
  46. InterfaceTypeChoices.TYPE_80211AC,
  47. InterfaceTypeChoices.TYPE_80211AD,
  48. InterfaceTypeChoices.TYPE_80211AX,
  49. InterfaceTypeChoices.TYPE_80211AY,
  50. InterfaceTypeChoices.TYPE_80211BE,
  51. InterfaceTypeChoices.TYPE_802151,
  52. InterfaceTypeChoices.TYPE_802154,
  53. InterfaceTypeChoices.TYPE_OTHER_WIRELESS,
  54. InterfaceTypeChoices.TYPE_GSM,
  55. InterfaceTypeChoices.TYPE_CDMA,
  56. InterfaceTypeChoices.TYPE_LTE,
  57. InterfaceTypeChoices.TYPE_4G,
  58. InterfaceTypeChoices.TYPE_5G,
  59. ]
  60. NONCONNECTABLE_IFACE_TYPES = VIRTUAL_IFACE_TYPES + WIRELESS_IFACE_TYPES + [
  61. # Channel subinterfaces derive their cable from the (channelized) parent interface and cannot be cabled directly
  62. InterfaceTypeChoices.TYPE_CHANNEL,
  63. ]
  64. #
  65. # Device components
  66. #
  67. MODULE_TOKEN = '{module}'
  68. VC_POSITION_RE = re.compile(r'\{vc_position(?::([^}]*))?\}')
  69. MODULAR_COMPONENT_TEMPLATE_MODELS = Q(
  70. app_label='dcim',
  71. model__in=(
  72. 'consoleporttemplate',
  73. 'consoleserverporttemplate',
  74. 'coolingintaketemplate',
  75. 'coolingoutflowtemplate',
  76. 'frontporttemplate',
  77. 'interfacetemplate',
  78. 'poweroutlettemplate',
  79. 'powerporttemplate',
  80. 'rearporttemplate',
  81. ))
  82. MODULAR_COMPONENT_MODELS = Q(
  83. app_label='dcim',
  84. model__in=(
  85. 'consoleport',
  86. 'consoleserverport',
  87. 'coolingintake',
  88. 'coolingoutflow',
  89. 'frontport',
  90. 'interface',
  91. 'poweroutlet',
  92. 'powerport',
  93. 'rearport',
  94. ))
  95. #
  96. # Cabling and connections
  97. #
  98. CABLE_TRACE_SVG_DEFAULT_WIDTH = 400
  99. # Cable endpoint types
  100. CABLE_TERMINATION_MODELS = Q(
  101. Q(app_label='circuits', model__in=(
  102. 'circuittermination',
  103. )) |
  104. Q(app_label='dcim', model__in=(
  105. 'consoleport',
  106. 'consoleserverport',
  107. 'frontport',
  108. 'interface',
  109. 'powerfeed',
  110. 'poweroutlet',
  111. 'powerport',
  112. 'rearport',
  113. ))
  114. )
  115. COMPATIBLE_TERMINATION_TYPES = {
  116. 'circuittermination': ['interface', 'frontport', 'rearport', 'circuittermination'],
  117. 'consoleport': ['consoleserverport', 'frontport', 'rearport'],
  118. 'consoleserverport': ['consoleport', 'frontport', 'rearport'],
  119. 'interface': ['interface', 'circuittermination', 'frontport', 'rearport'],
  120. 'frontport': ['consoleport', 'consoleserverport', 'interface', 'frontport', 'rearport', 'circuittermination'],
  121. 'powerfeed': ['powerport'],
  122. 'poweroutlet': ['powerport'],
  123. 'powerport': ['poweroutlet', 'powerfeed'],
  124. 'rearport': ['consoleport', 'consoleserverport', 'interface', 'frontport', 'rearport', 'circuittermination'],
  125. }
  126. # Models which can serve to scope an object by location
  127. LOCATION_SCOPE_TYPES = (
  128. 'region', 'sitegroup', 'site', 'location',
  129. )
  130. #
  131. # MAC addresses
  132. #
  133. MACADDRESS_ASSIGNMENT_MODELS = Q(
  134. Q(app_label='dcim', model='interface') |
  135. Q(app_label='virtualization', model='vminterface')
  136. )