Coverage for netbox_interface_name_rules / family / capabilities.py: 100.00%
12 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-10-16 10:13 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-10-16 10:13 +0000
1# SPDX-License-Identifier: Apache-2.0
2# Copyright (C) 2025 Marcin Zieba <marcinpsk@gmail.com>
3"""Probe what the active NetBox data model can represent and do."""
5import functools
6import importlib.util
8from dcim.models import Interface
9from django.core.exceptions import FieldDoesNotExist
12def supports_channelization() -> bool:
13 """Return whether this NetBox models channelized subinterfaces (4.7+).
15 Probed from the Interface model rather than a version comparison, so a backport or a
16 development build is detected by what it actually provides.
17 """
18 try:
19 Interface._meta.get_field("channel_id")
20 except FieldDoesNotExist:
21 return False
22 return True # pragma: no cover - only reachable on a NetBox that models channelization
25@functools.cache
26def supports_module_moves() -> bool:
27 """Return whether this NetBox moves a module's components with it and renames their raw names (4.7+)."""
28 return importlib.util.find_spec("dcim.models.module_moves") is not None