Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added a new python script that could run on windows #86

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This script will clone a copy of the `netbox-community/devicetype-library` repos
1. This script is written in Python, so lets setup a virtual environment.

```
git clone https://github.com/minitriga/Netbox-Device-Type-Library-Import
git clone https://github.com/minitriga/Netbox-Device-Type-Library-Import
cd Netbox-Device-Type-Library-Import
python3 -m venv venv
source venv/bin/activate
Expand All @@ -38,12 +38,18 @@ 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.
To use the script, simply execute the script as follows. Make sure you're still in the activated virtual environment we created before. (Mac/Linux users)

```
./nb-dt-import.py
```

For windows users, execute this slightly modifiied file in the same activated environment as before.

```
./nb-dt-import_windows.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.
Expand All @@ -58,17 +64,17 @@ 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.
`--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.
It's possible to use this project as a docker container.

To build :
To build :

```
docker build -t netbox-devicetype-import-library .
Expand All @@ -80,15 +86,15 @@ Alternatively you can pull a pre-built image from Github Container Registry (ghc
docker pull ghcr.io/minitriga/netbox-device-type-library-import
```

The container supports the following env var as configuration :
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 :
To run :

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