mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-16 20:22:53 -06:00

* Create MACAddress model and migrations to convert existing .mac_address fields to standalone objects * Add migrations * All views/filtering working and documentation done; no unit tests yet * Redo migrations following VLAN Translation * Remove mac_address filter fields and add table columns for device/vm * Remove unnecessary "bulk rename" * Fix filterset tests for Device * Fix filterset tests for Interface * Fix tests on single-object forms * Fix serializer tests * Fix filterset tests for VMInterface * Fix filterset tests for Device and VirtualMachine * Move new field check into lookup_map iteration * Fix general MACAddress filter tests * Add GraphQL types/filters/schema * Fix bulk edit/create tests (bulk editing Interfaces will be unsupported because of inheritance from ComponentBulkEditForm) * Make mac_address read_only on InterfaceSerializer/VMInterfaceSerializer * Undo unrelated work * Cleanup unused IPAddress derived stuff * API endpoints * Add serializer objects to interface serializers * Clean up unnecessary bulk create forms/views/routes * Add SearchIndex and adjust indexable fields for Interface and VMInterface * Reorganize MACAddress classes out of association with DeviceComponents * Move MACAddressSerializer * Enforce saving only a single is_primary MACAddress per interface/vminterface * Perform is_primary validation on MACAddress model and just check if one already exists for the interface * Remove form-level validation * Fix check for current is_primary setting when reassigning * Model cleanup * Documentation notes and cleanup * Simplify serializer and add ip_addresses * Add to VMInterfaceSerializer too * Style cleanup * Standardize "MAC Address" instead of "MAC" * Remove unused views * Add is_primary field for bulk edit * HTML cleanup and add copy-to-clipboard button * Remove mac_address from Interface and VMInterface bulk-edit forms * Add device and VM filtering * Use combined assigned_object_parent in table to match structure of IPAddressTable * Add GFK fields to MACAddressSerializer * Reorganize "Addressing" sections to remove from proximity to "Device Components" and related groupings * Clean up migrations * Misc cleanup * Add filterset test * Remove mac_address field from interface forms * Designate primary MAC address via a ForeignKey on the interface models * Add serializer fields for primary_mac_address * Update docs --------- Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
141 lines
3.1 KiB
Python
141 lines
3.1 KiB
Python
from django.db.models import Q
|
|
|
|
from .choices import InterfaceTypeChoices
|
|
|
|
# Exclude SVG images (unsupported by PIL)
|
|
DEVICETYPE_IMAGE_FORMATS = 'image/bmp,image/gif,image/jpeg,image/png,image/tiff,image/webp'
|
|
|
|
|
|
#
|
|
# Racks
|
|
#
|
|
|
|
RACK_U_HEIGHT_DEFAULT = 42
|
|
RACK_U_HEIGHT_MAX = 100
|
|
|
|
RACK_ELEVATION_BORDER_WIDTH = 2
|
|
RACK_ELEVATION_DEFAULT_LEGEND_WIDTH = 30
|
|
RACK_ELEVATION_DEFAULT_MARGIN_WIDTH = 15
|
|
|
|
RACK_STARTING_UNIT_DEFAULT = 1
|
|
|
|
|
|
#
|
|
# RearPorts
|
|
#
|
|
|
|
REARPORT_POSITIONS_MIN = 1
|
|
REARPORT_POSITIONS_MAX = 1024
|
|
|
|
|
|
#
|
|
# Interfaces
|
|
#
|
|
|
|
INTERFACE_MTU_MIN = 1
|
|
INTERFACE_MTU_MAX = 65536
|
|
|
|
VIRTUAL_IFACE_TYPES = [
|
|
InterfaceTypeChoices.TYPE_VIRTUAL,
|
|
InterfaceTypeChoices.TYPE_LAG,
|
|
InterfaceTypeChoices.TYPE_BRIDGE,
|
|
]
|
|
|
|
WIRELESS_IFACE_TYPES = [
|
|
InterfaceTypeChoices.TYPE_80211A,
|
|
InterfaceTypeChoices.TYPE_80211G,
|
|
InterfaceTypeChoices.TYPE_80211N,
|
|
InterfaceTypeChoices.TYPE_80211AC,
|
|
InterfaceTypeChoices.TYPE_80211AD,
|
|
InterfaceTypeChoices.TYPE_80211AX,
|
|
InterfaceTypeChoices.TYPE_80211AY,
|
|
InterfaceTypeChoices.TYPE_80211BE,
|
|
InterfaceTypeChoices.TYPE_802151,
|
|
InterfaceTypeChoices.TYPE_802154,
|
|
InterfaceTypeChoices.TYPE_OTHER_WIRELESS,
|
|
]
|
|
|
|
NONCONNECTABLE_IFACE_TYPES = VIRTUAL_IFACE_TYPES + WIRELESS_IFACE_TYPES
|
|
|
|
|
|
#
|
|
# Device components
|
|
#
|
|
|
|
MODULE_TOKEN = '{module}'
|
|
|
|
MODULAR_COMPONENT_TEMPLATE_MODELS = Q(
|
|
app_label='dcim',
|
|
model__in=(
|
|
'consoleporttemplate',
|
|
'consoleserverporttemplate',
|
|
'frontporttemplate',
|
|
'interfacetemplate',
|
|
'poweroutlettemplate',
|
|
'powerporttemplate',
|
|
'rearporttemplate',
|
|
))
|
|
|
|
MODULAR_COMPONENT_MODELS = Q(
|
|
app_label='dcim',
|
|
model__in=(
|
|
'consoleport',
|
|
'consoleserverport',
|
|
'frontport',
|
|
'interface',
|
|
'poweroutlet',
|
|
'powerport',
|
|
'rearport',
|
|
))
|
|
|
|
|
|
#
|
|
# Cabling and connections
|
|
#
|
|
|
|
CABLE_TRACE_SVG_DEFAULT_WIDTH = 400
|
|
|
|
# Cable endpoint types
|
|
CABLE_TERMINATION_MODELS = Q(
|
|
Q(app_label='circuits', model__in=(
|
|
'circuittermination',
|
|
)) |
|
|
Q(app_label='dcim', model__in=(
|
|
'consoleport',
|
|
'consoleserverport',
|
|
'frontport',
|
|
'interface',
|
|
'powerfeed',
|
|
'poweroutlet',
|
|
'powerport',
|
|
'rearport',
|
|
))
|
|
)
|
|
|
|
COMPATIBLE_TERMINATION_TYPES = {
|
|
'circuittermination': ['interface', 'frontport', 'rearport', 'circuittermination'],
|
|
'consoleport': ['consoleserverport', 'frontport', 'rearport'],
|
|
'consoleserverport': ['consoleport', 'frontport', 'rearport'],
|
|
'interface': ['interface', 'circuittermination', 'frontport', 'rearport'],
|
|
'frontport': ['consoleport', 'consoleserverport', 'interface', 'frontport', 'rearport', 'circuittermination'],
|
|
'powerfeed': ['powerport'],
|
|
'poweroutlet': ['powerport'],
|
|
'powerport': ['poweroutlet', 'powerfeed'],
|
|
'rearport': ['consoleport', 'consoleserverport', 'interface', 'frontport', 'rearport', 'circuittermination'],
|
|
}
|
|
|
|
# Models which can serve to scope an object by location
|
|
LOCATION_SCOPE_TYPES = (
|
|
'region', 'sitegroup', 'site', 'location',
|
|
)
|
|
|
|
|
|
#
|
|
# MAC addresses
|
|
#
|
|
|
|
MACADDRESS_ASSIGNMENT_MODELS = Q(
|
|
Q(app_label='dcim', model='interface') |
|
|
Q(app_label='virtualization', model='vminterface')
|
|
)
|