This library is intended to assist with importing device and module types into NetBox from the NetBox Community DeviceType-Library
Go to file
BorisBachere 0dbd34956d
Update repo.py
Check if slug exists in data.
Without this check, import fail when SLUGS are not none in .env
2023-10-02 15:31:00 +02:00
.github Adding back workflows 2023-03-03 16:27:48 +00:00
.dockerignore Github Workflow and Docker improvements 2021-11-25 01:22:36 -05:00
.env.example Merge branch 'master' into master 2021-11-10 11:09:30 +00:00
.gitignore Added try except block to catch ssl errors. (#74) 2023-03-03 12:25:25 -05:00
Dockerfile Github Workflow and Docker improvements 2021-11-25 01:22:36 -05:00
LICENSE update: README and added dotenv other small stuff 2021-02-26 23:26:32 +01:00
log_handler.py Beta Release Merge (#87) 2023-03-24 15:13:38 -04:00
nb-dt-import.py Fix image upload v2 (#91) 2023-03-28 09:37:50 -04:00
netbox_api.py Added ability for IGNORE_SSL_ERRORS to dictate if the images upload verifys the request (#101) 2023-08-01 10:31:08 -04:00
README.md Fixes #89: Documentation bug: Getting Started git clone url incorrect (#90) 2023-03-27 10:55:03 -04:00
repo.py Update repo.py 2023-10-02 15:31:00 +02:00
requirements.txt Bumping deps. Closes PR#99 and PR#98 (#100) 2023-08-01 10:11:45 -04:00
settings.py Beta Release Merge (#87) 2023-03-24 15:13:38 -04:00

Netbox Device Type Import

This library is intended to be your friend and help you import all the device-types defined within the the NetBox Device Type Library Repository.

Tested working with 2.9.4, 2.10.4

🪄 Description

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.

🚀 Getting Started

  1. This script is written in Python, so lets setup a virtual environment.
git clone https://github.com/netbox-community/Device-Type-Library-Import.git
cd Netbox-Device-Type-Library-Import
python3 -m venv venv
source venv/bin/activate
  1. Now that we have the basics setup, we'll need to install the requirements.
pip install -r requirements.txt
  1. There are two variables that are required when using this script to import device types into your Netbox installation. (1) Your Netbox instance URL and (2) a token with write rights.

Copy the existing .env.example to your own .env file, and fill in the variables.

cp .env.example .env
vim .env

Finally, we are able to execute the script and import some device templates!

🔌 Usage

To use the script, simply execute the script as follows. Make sure you're still in the activated virtual environment we created before.

./nb-dt-import.py

This will clone the latest master branch from the netbox-community/devicetype-library from Github and install it into the repo subdirectory. If this directory already exists, it will perform a git pull to update the reposity instead.

Next, it will loop over every manufacturer and every device of every manufacturer and begin checking if your Netbox install already has them, and if not, creates them. It will skip preexisting manufacturers, devices, interfaces, etc. so as to not end up with duplicate entries in your Netbox instance.

🧰 Arguments

This script currently accepts a list of vendors as an arugment, so that you can selectively import devices.

To import only device by APC, for example:

./nb-dt-import.py --vendors apc

--vendors can also accept a comma separated list of vendors if you want to import multiple.

./nb-dt-import.py --vendors apc,juniper

Docker build

It's possible to use this project as a docker container.

To build :

docker build -t netbox-devicetype-import-library .

Alternatively you can pull a pre-built image from Github Container Registry (ghcr.io):

docker pull ghcr.io/minitriga/netbox-device-type-library-import

The container supports the following env var as configuration :

  • REPO_URL, the repo to look for device types (defaults to https://github.com/netbox-community/devicetype-library.git)
  • REPO_BRANCH, the branch to check out if appropriate, defaults to master.
  • NETBOX_URL, used to access netbox
  • NETBOX_TOKEN, token for accessing netbox
  • VENDORS, a comma-separated list of vendors to import (defaults to None)

To run :

docker run -e "NETBOX_URL=http://netbox:8080/" -e "NETBOX_TOKEN=98765434567890" ghcr.io/minitriga/netbox-device-type-library-import

🧑‍💻 Contributing

We're happy about any pull requests!

📜 License

MIT