Coverage for dcim/constants.py: 100%
32 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 18:35 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 18:35 +0000
1import re
3from django.db.models import Q
5from .choices import InterfaceTypeChoices
7# Exclude SVG images (unsupported by PIL)
8DEVICETYPE_IMAGE_FORMATS = 'image/bmp,image/gif,image/jpeg,image/png,image/tiff,image/webp'
11#
12# Racks
13#
15RACK_U_HEIGHT_DEFAULT = 42
16RACK_U_HEIGHT_MAX = 100
18RACK_ELEVATION_BORDER_WIDTH = 2
19RACK_ELEVATION_DEFAULT_LEGEND_WIDTH = 30
20RACK_ELEVATION_DEFAULT_MARGIN_WIDTH = 15
22RACK_STARTING_UNIT_DEFAULT = 1
25#
26# Cables
27#
29CABLE_CONNECTOR_MIN = 1
30CABLE_CONNECTOR_MAX = 256
32CABLE_POSITION_MIN = 1
33CABLE_POSITION_MAX = 1024
36#
37# RearPorts
38#
40PORT_POSITION_MIN = 1
41PORT_POSITION_MAX = 1024
44#
45# Interfaces
46#
48INTERFACE_MTU_MIN = 1
49INTERFACE_MTU_MAX = 65536
51# The number of channels on a channelized interface, and the channel to which a subinterface is bound. A subinterface's
52# channel_id maps directly to a position on the parent interface's cable connector, so these are bounded by the maximum
53# cable position.
54INTERFACE_CHANNELS_MIN = CABLE_POSITION_MIN
55INTERFACE_CHANNELS_MAX = CABLE_POSITION_MAX
57VIRTUAL_IFACE_TYPES = [
58 InterfaceTypeChoices.TYPE_VIRTUAL,
59 InterfaceTypeChoices.TYPE_LAG,
60 InterfaceTypeChoices.TYPE_BRIDGE,
61]
63WIRELESS_IFACE_TYPES = [
64 InterfaceTypeChoices.TYPE_80211A,
65 InterfaceTypeChoices.TYPE_80211G,
66 InterfaceTypeChoices.TYPE_80211N,
67 InterfaceTypeChoices.TYPE_80211AC,
68 InterfaceTypeChoices.TYPE_80211AD,
69 InterfaceTypeChoices.TYPE_80211AX,
70 InterfaceTypeChoices.TYPE_80211AY,
71 InterfaceTypeChoices.TYPE_80211BE,
72 InterfaceTypeChoices.TYPE_802151,
73 InterfaceTypeChoices.TYPE_802154,
74 InterfaceTypeChoices.TYPE_OTHER_WIRELESS,
75 InterfaceTypeChoices.TYPE_GSM,
76 InterfaceTypeChoices.TYPE_CDMA,
77 InterfaceTypeChoices.TYPE_LTE,
78 InterfaceTypeChoices.TYPE_4G,
79 InterfaceTypeChoices.TYPE_5G,
80]
82NONCONNECTABLE_IFACE_TYPES = VIRTUAL_IFACE_TYPES + WIRELESS_IFACE_TYPES + [
83 # Channel subinterfaces derive their cable from the (channelized) parent interface and cannot be cabled directly
84 InterfaceTypeChoices.TYPE_CHANNEL,
85]
88#
89# Device components
90#
92MODULE_TOKEN = '{module}'
93VC_POSITION_RE = re.compile(r'\{vc_position(?::([^}]*))?\}')
95MODULAR_COMPONENT_TEMPLATE_MODELS = Q(
96 app_label='dcim',
97 model__in=(
98 'consoleporttemplate',
99 'consoleserverporttemplate',
100 'coolingintaketemplate',
101 'coolingoutflowtemplate',
102 'frontporttemplate',
103 'interfacetemplate',
104 'poweroutlettemplate',
105 'powerporttemplate',
106 'rearporttemplate',
107 ))
109MODULAR_COMPONENT_MODELS = Q(
110 app_label='dcim',
111 model__in=(
112 'consoleport',
113 'consoleserverport',
114 'coolingintake',
115 'coolingoutflow',
116 'frontport',
117 'interface',
118 'poweroutlet',
119 'powerport',
120 'rearport',
121 ))
124#
125# Cabling and connections
126#
128CABLE_TRACE_SVG_DEFAULT_WIDTH = 400
130# Cable endpoint types
131CABLE_TERMINATION_MODELS = Q(
132 Q(app_label='circuits', model__in=(
133 'circuittermination',
134 )) |
135 Q(app_label='dcim', model__in=(
136 'consoleport',
137 'consoleserverport',
138 'frontport',
139 'interface',
140 'powerfeed',
141 'poweroutlet',
142 'powerport',
143 'rearport',
144 ))
145)
147COMPATIBLE_TERMINATION_TYPES = {
148 'circuittermination': ['interface', 'frontport', 'rearport', 'circuittermination'],
149 'consoleport': ['consoleserverport', 'frontport', 'rearport'],
150 'consoleserverport': ['consoleport', 'frontport', 'rearport'],
151 'interface': ['interface', 'circuittermination', 'frontport', 'rearport'],
152 'frontport': ['consoleport', 'consoleserverport', 'interface', 'frontport', 'rearport', 'circuittermination'],
153 'powerfeed': ['powerport'],
154 'poweroutlet': ['powerport'],
155 'powerport': ['poweroutlet', 'powerfeed'],
156 'rearport': ['consoleport', 'consoleserverport', 'interface', 'frontport', 'rearport', 'circuittermination'],
157}
159# Models which can serve to scope an object by location
160LOCATION_SCOPE_TYPES = (
161 'region', 'sitegroup', 'site', 'location',
162)
165#
166# MAC addresses
167#
169MACADDRESS_ASSIGNMENT_MODELS = Q(
170 Q(app_label='dcim', model='interface') |
171 Q(app_label='virtualization', model='vminterface')
172)