ictdesigntools.spaces.racks¶
Racks and cabinets: what is mounted where, whether it fits, and the elevation drawing.
The model follows NetBox DCIM, so a design moves into NetBox and back without translation:
RackType is a NetBox rack type, DeviceType a device type, Role a device role, and
Device a device placed at a position (its lowest unit, counted on the rails from the
rack's starting_unit) on a face. Units are whole or half (u_height 0.5, 1, 1.5 …).
check finds what does not fit: positions off the rails, overlaps on a face (a full-depth
device takes both faces), weight over the rack's rating, power over a budget, and airflow that
runs against the rest of the rack. elevation draws the front and rear with the library's
drawing engine (ictdesigntools.draw), so it can be written out as SVG, PDF or DXF.
Generic racks and equipment come from data/racks.toml (rack_types(), device_types(),
roles()); custom ones are made directly.
>>> rack = Rack(rack_type("generic-cabinet-42u-600x1070"), [
... Device(device_type("patch-panel-24-1u"), 42, name="PP-A"),
... Device(device_type("server-2u"), 20),
... ])
>>> report = check(rack)
>>> report.passes, report.u_used
(True, 3.0)
PortTemplate
dataclass
¶
PortTemplate(
type: str,
count: int = 1,
name: str = "{n}",
positions: int = 1,
connector: str = "",
)
A NetBox front or rear port template: count ports of a NetBox port type (such as
8p8c, lc, sn, mpo or f), named by name with {n} for the number,
each with positions fibers or circuits behind it (12 for an MPO-12 rear port). A port
is one connector, as in NetBox: a duplex LC pair is two ports. connector names the
footprint in data/connectors.toml for a type NetBox has no slug for, such as MMC
(type="other", connector="mmc").
PortMapping
dataclass
¶
One front port position passing through to one rear port position (NetBox 4.5's port
mapping; before it, a front port's rear_port and rear_port_position).
DeviceType
dataclass
¶
DeviceType(
model: str,
u_height: float = 1.0,
is_full_depth: bool = True,
airflow: str | None = None,
weight_kg: float | None = None,
maximum_draw: float | None = None,
allocated_draw: float | None = None,
exclude_from_utilization: bool = False,
role: Role | None = None,
manufacturer: str = "Generic",
part_number: str = "",
slug: str = "",
source: str = "",
front_ports: tuple[PortTemplate, ...] = (),
rear_ports: tuple[PortTemplate, ...] = (),
)
port_mappings
property
¶
port_mappings: list[PortMapping]
How the front ports pass through to the rear ports (none without both).
Device
dataclass
¶
Device(
device_type: DeviceType,
position: float | None,
face: str = "front",
name: str = "",
)
A device in a rack. position None leaves it unracked (a 0U PDU, a device on a shelf):
it still counts towards weight and power.
port_map ¶
port_map(
front: tuple[PortTemplate, ...],
rear: tuple[PortTemplate, ...],
) -> list[PortMapping]
Front port positions mapped onto rear port positions in order, as NetBox assigns them when ports are made from a pattern: 48 LC front ports fill four MPO-12 rear ports, front port 13 landing on MPO 2 position 1. Raises ValueError when the positions differ.
Source code in src/ictdesigntools/spaces/racks.py
check ¶
Space, weight, power and airflow of a rack and its devices.
Source code in src/ictdesigntools/spaces/racks.py
elevation ¶
elevation(
rack: Rack,
faces: tuple[str, ...] = FACES,
report: RackReport | None = None,
ports: bool = False,
) -> Drawing
Front and rear elevations side by side, in mm, with unit numbers on the rails, each device
labelled to fit, full-depth devices shown from behind on the other face, and devices with a
problem outlined. Devices carry a Meta (id device-<index>, kind device) for
to_svg(interactive=True). With ports, devices with port templates show their ports
(front ports on the face they are mounted on, rear ports from behind when full depth), each
a Meta of kind port with id device-<index>-<front|rear>-port-<name>, and the
label moves to the left of the ports; shapes are styled by name (rail, unit, behind,
problem, role-<slug>) for to_svg(classes=True).
Source code in src/ictdesigntools/spaces/racks.py
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 | |