Inventory¶
The inventory collector keeps device-level facts and (on Junos) chassis
hardware in sync with NetBox.
NAPALM calls¶
driver.get_facts()for serial / OS version / hostname / fqdn.driver.get_chassis_inventory()if available (the bundled enhanced Junos driver provides one). Used to reconciledcim.InventoryItemanddcim.Modulerows.
Device-level entry¶
For every device, the collector emits a single entry whose
object_repr is the device markdown link.
detected_values:
{
"serial_number": "JN12345678AB",
"os_version": "21.4R3.10",
"hostname": "core-01",
"fqdn": "core-01.example.com"
}
current_values: {"serial_number": "<existing>"}.
Action:
changedif the serial differs fromDevice.serial.confirmedotherwise.
Apply behavior writes the new serial to Device.serial and records a
JournalEntry summarizing OS version, hostname, and FQDN.
Chassis inventory (Junos)¶
When driver.get_chassis_inventory() exists, the collector also walks
hardware modules.
For each chassis module:
- Skip
BUILTINmodules and Routing Engines (the latter are covered byget_facts). - Compare to the existing
InventoryItemfor the device by name. Action isnew,changed(serial / part_id / description differ), orconfirmed. - If a matching
dcim.ModuleBayanddcim.ModuleTypeexist for the device's manufacturer (matched onpart_number, thenmodel), an additional Module entry is emitted withobject_repr = "Module <bay>".
detected_values for an inventory item:
{
"name": "FPC 0",
"parent_name": null,
"serial": "AB1234567",
"part_id": "MX-MPC2E-3D",
"description": "Modular Port Concentrator"
}
For a chassis module:
{
"name": "FPC 0/PIC 0",
"component_name": "PIC 0",
"parent_name": "FPC 0",
"serial": "BB9876543",
"part_id": "MIC-3D-4XGE-XFP",
"description": "...",
"module_bay_id": 42,
"module_type_id": 7
}
Stale detection¶
InventoryItemrows on this device withdiscovered=Truewhose names were not seen this run are flaggedstale. Apply deletes them.Modulerows on this device tagged Automatically Discovered whose bays were not visited are flaggedstale. Apply deletes them.
Apply specifics¶
- Newly created
InventoryItemrows are saved withdiscovered=Trueand tagged auto-discovered. - Module creation goes through
create_module()which sets_adopt_components=Trueand_disable_replication=Trueso existing child components are adopted instead of being duplicated. - Parent / child relationships are resolved within the same run by
remembering newly-created items in
created_itemsand modules inmodules_by_name.