Skip to content

Interfaces and Cables

Outcome: the map's connections exist — an interface on each of the lab's two devices, and a cable recorded between them. Devices in rows are an inventory. Devices joined by cables are a network, and the join is made of two record types this chapter adds.

Interfaces: where a device meets the world

An interface is a named port on a device: eth0, GigabitEthernet1/0/1, a management port, a virtual interface on a VM. It has a type — NetBox keeps a long honest list, from 1000base-t (copper gigabit Ethernet) through fibre forms to virtual — and it is the thing addresses are assigned to (chapter 7 spent one) and cables terminate on. The lab created one per device, each answered 201:

curl -s -X POST .../api/dcim/interfaces/ \
  -d '{"device":1,"name":"eth0","type":"1000base-t"}'

(Transcripts t08-api-proof.txt step 6 and t11-cable.txt.)

Interfaces carry more of the truth than their names: enabled or not, the MAC address if you record it, the MTU, and the fields that let a port be a member of a link aggregation group or an access port on a VLAN. Those refinements are part of the same record; the lab's plain eth0 is the honest minimum.

Cables: the record between

A cable joins terminations: an A end and a B end, each of which is an interface (or a front/rear port, a console port, a power port — cables are not only for data). A cable has a type (cat6 in the lab), a status, and can carry a colour, a length and a label. The lab joined its two switches' eth0 interfaces in one call:

curl -s -X POST .../api/dcim/cables/ \
  -d '{"a_terminations":[{"object_type":"dcim.interface","object_id":1}],
       "b_terminations":[{"object_type":"dcim.interface","object_id":2}],
       "type":"cat6","status":"connected"}'

and read the result back:

{'id': 1, 'type': 'cat6',
 'status': {'value': 'connected', 'label': 'Connected'}}
cables: 1

(Transcript t11-cable.txt.)

What the cable buys you

Once cables are records, questions that used to need a person under a desk become queries: what is this interface connected to; trace the path from this device to that one (NetBox follows cable paths end to end, across patch panels modelled as front and rear ports); which cables land on a device about to be decommissioned. The path tracing across pass-through ports is described here from the model — the lab's single direct cable is the whole of what it ran — but the direct cable is the atom every path is built from, and it is verified above.

The check

The device page for lab-sw-01 shows its interface with the cable attached, and the interface's own page names the other end: lab-sw-02, eth0. Through the API, GET /api/dcim/cables/ returns a count of 1 — one cable, both ends accounted for.