This library is intended to be your friend and help you import all the device-types defined within the NetBox Device Type Library Repository.
Tested working with NetBox 3.2+ through 4.5+ (weekly CI run against NetBox
main)
⚠️ direnv users — This repo ships a.envrc.examplefile. If you use direnv, review the file before enabling it:cp .envrc.example .envrc cat .envrc # confirm it only loads .env vars and syncs uv direnv allowThe file exclusively loads variables from
.envinto your shell and runsuv syncto keep dependencies up to date. Your.envrcis git-ignored.
This script will clone a copy of the netbox-community/devicetype-library repository to your
machine to allow it to import the device types you would like without copy and pasting them
into the NetBox UI.
-
Install dependencies with
uv:uv sync
-
Copy
.env.exampleto.envand fill in your NetBox URL and API token (the token needs write rights):cp .env.example .env vim .env
-
Run the script:
uv run nb-dt-import.py
Running the script clones (or updates) the netbox-community/devicetype-library repository
into the repo subdirectory, then loops over every manufacturer and device, creating anything
that is missing from NetBox while skipping entries that already exist.
This script currently accepts a list of vendors as an argument, so that you can selectively import devices.
To import only device by APC, for example:
uv run nb-dt-import.py --vendors apc--vendors can also accept a comma-separated list of vendors if you want to import multiple.
uv run nb-dt-import.py --vendors apc,juniperBy default, the script only creates new device types and skips existing ones. To update existing device types:
uv run nb-dt-import.py --updateThis will:
- Add new components (interfaces, power ports, etc.) that are in YAML but missing from NetBox
- Update properties of existing components if they've changed
- Update device type properties (u_height, part_number, etc.) if they've changed
- Report components that exist in NetBox but are missing from YAML (won't delete by default)
WARNING: Removing components can affect existing device instances in NetBox.
If you've changed a device type definition (for example, converting interfaces to module-bays to support SFP modules), you can remove obsolete components with:
uv run nb-dt-import.py --update --remove-componentsThis will delete any components (interfaces, ports, bays, etc.) that exist in NetBox but are no longer present in the YAML definition.
Use cases:
- Converting fixed interfaces to module-bays for modular devices
- Removing incorrectly defined components from device templates
- Cleaning up after major device type definition changes
Important considerations:
- Components attached to actual device instances may prevent deletion
- Review the change detection report before enabling component removal
- Test on a staging NetBox instance first if possible
We're happy about any pull requests!
MIT