ictdesigntools.cabling.connections¶
Cables between ports, modelled as NetBox models them, and lane-by-lane tracing.
A Cable joins its A terminations to its B terminations (NetBox's a_terminations and
b_terminations): front or rear ports of devices, named by device and port. It carries
NetBox's cable fields (type, status, label, color, length,
length_unit) and, optionally, the Assembly it is built from, whose profile and
polarity say which lane on end A meets which lane on end B. A cable without an assembly joins
its terminations in order, position to position, as a plain cable does in NetBox.
A Plant holds the devices (by name, each with its DeviceType and so its port templates
and front-to-rear port mappings) and the cables. check finds what NetBox would refuse or a
designer would want to know: unknown devices and ports, a port cabled twice, a connector that
does not fit the port, an assembly whose connector count or positions differ from the ports'.
trace follows one lane from a port position through cables and through each device's port
mappings to where it ends, as NetBox's cable trace does; duplex traces a pair of lanes and
says whether they cross, as a TIA-568 duplex channel must (transmit meets receive).
>>> from ictdesigntools.spaces.racks import device_type
>>> from ictdesigntools.cabling.assemblies import assembly
>>> panel = device_type("fiber-enclosure-1u") # 48 LC front, 4 MPO-12 rear
>>> plant = Plant({"P1": panel, "P2": panel})
>>> trunk = plant.connect([("P1", "rear", "MPO 1")], [("P2", "rear", "MPO 1")],
... assembly("mpo12-trunk-om4-15m"))
>>> [str(s) for s in plant.trace(Termination("P1", "front", "1"))]
['P1 front 1', 'P1 rear MPO 1.1', 'P2 rear MPO 1.12', 'P2 front 12']
>>> plant.problems()
[]
Termination
dataclass
¶
A port a cable ends on: a device, the port's side (front or rear) and its name.
object_type gives NetBox's termination type.
Step
dataclass
¶
Step(
port: Termination,
position: int = 1,
cable: int | None = None,
_multi: bool = False,
)
One point of a trace: a port and a position on it (1 for a single-position port).
Cable
dataclass
¶
Plant ¶
Plant(
devices: dict[str, DeviceType],
cables: list[Cable] | None = None,
)
Devices by name and the cables between their ports.
Source code in src/ictdesigntools/cabling/connections.py
from_racks
classmethod
¶
The devices of some racks, by their labels, which must be unique (NetBox names devices uniquely within a site).
Source code in src/ictdesigntools/cabling/connections.py
connect ¶
connect(
a: list[tuple[str, str, str]],
b: list[tuple[str, str, str]],
assembly: Assembly | None = None,
**fields,
) -> Cable
Add a cable from (device, side, port) triples on each end; returns it.
Source code in src/ictdesigntools/cabling/connections.py
template ¶
template(t: Termination) -> PortTemplate | None
The port template a termination names, or None when there is no such port.
Source code in src/ictdesigntools/cabling/connections.py
problems ¶
problems() -> list[Problem]
Everything wrong with the cabling, cable by cable, in order.
Source code in src/ictdesigntools/cabling/connections.py
lanes ¶
lanes(
i: int,
) -> dict[tuple[Termination, int], tuple[Termination, int]]
Cable i's lanes both ways: (port, position) on one end to the same on the other.
An assembly maps them by its profile and polarity; a plain cable joins its
terminations in order, position to position.
Source code in src/ictdesigntools/cabling/connections.py
trace ¶
trace(start: Termination, position: int = 1) -> list[Step]
One lane from a port position to its far end: across each cable at the port, then through the device to the port on its other face, until a port has no cable or a device has no mapping. Each step is a (port, position); a step a cable reached carries that cable's index.
Source code in src/ictdesigntools/cabling/connections.py
duplex ¶
duplex(
tx: Termination,
rx: Termination,
tx_position: int = 1,
rx_position: int = 1,
) -> tuple[Step, Step, bool]
Trace a duplex pair: where each lane ends, and whether they cross (the pair's first lane ending on the far pair's second, as TIA-568 needs so transmit meets receive). Crossing is judged by the far ends' order: port name, then position.