LLDP¶
The lldp collector inspects LLDP neighbors and creates dcim.Cable
rows between matching local and remote interfaces.
NAPALM call¶
driver.get_lldp_neighbors_detail().
Same-site rule¶
The collector deliberately restricts cable creation to neighbors in the same site as the local device:
This prevents a misidentified hostname from creating an erroneous intra-DC cable across sites. If you need cross-site cabling, the cables must be added manually.
Remote device resolution¶
resolve_device_by_name() matches the remote device by name with
progressive domain stripping: switch.dc1.example.com ->
switch.dc1.example -> switch.dc1 -> switch, until a unique match is
found. MultipleObjectsReturned propagates and triggers a warning;
DoesNotExist results in a skipped neighbor.
What it produces¶
Per matched neighbor:
{
"local_interface": "ge-0/0/0",
"remote_device": "switch2.example.com",
"remote_interface": "ge-0/0/4",
"remote_chassis_id": "aa:bb:cc:11:22:33"
}
Action: always new (the collector only emits an entry when both
interfaces exist and neither is already cabled).
Apply behavior¶
- Construct a
Cablebetweenlocal_ifaceandremote_ifacewith statusconnected. - Validate, save, tag with Automatically Discovered.
- Record a
JournalEntryon the local device summarizing the link.
The corresponding apply handler in
netbox_facts/helpers/applier.py::_apply_lldp_entry re-runs the same
checks in case the topology changed between detection and apply (one of
the interfaces having gained a cable in the interim raises
ValueError("Interface already has a cable"), marking the entry as
failed).
Skip conditions¶
The collector silently skips a neighbor when any of the following hold:
remote_system_nameorremote_portis empty.- The remote device cannot be resolved or is in a different site.
- The remote interface does not exist in NetBox.
- Either interface already has a cable.