# Netbox Network Importer
Tool to analyze and synchronize an existing network with a Netbox (SOT).
The main use cases for the network importer:
- Import an existing network into a Netbox
- ~~Check the differences between the running network and the Netbox~~
---
## Install
1. Clone repository
- `git clone git@gitlab.cesnet.cz:701/done/netbox_network_importer.git`
2. Go into the repository
- `cd netbox_network_importer `
3. Create `virtualenv`
- `python3 -m venv venv`
3. Activate it
- `source venv/bin/activate`
3. Install the tool
- `pip install .`
---
## Pre-requisite
To operate, the Netbox Network Importer is dependent on the following items:
- Access to Netbox API
- Access to Network Devices via SSH
- Created Custom Field on Netbox
```json
{
"display": "Ignore Importer",
"content_types": [
"dcim.interface",
],
"type": {
"value": "boolean",
"label": "Boolean (true/false)"
},
"object_type": null,
"data_type": "boolean",
"name": "ignore_importer",
"label": "Ignore Importer",
"description": "Will be ignored when processed by Network Importer",
"required": true,
"filter_logic": {
"value": "exact",
"label": "Exact"
},
"default": false,
"weight": 100,
}
```
---
## Inventory
A device inventory must be available in NetBox.
To be able to connect to the device the following information needs to be defined :
- Primary ip address
- Platform (must be a one of the following ['iosxr', 'ios', 'iosxe'])
---
## Configuration file
The information to connect to NetBox must be provided via the configuration file. The configuration file below present standard options that can be provided to control the behavior of the Netbox Network Importer.
Netbox Network Importer try to find the configuration file at:
- `/home/<user>/.config/netbox_network_importer/config.yml`
- `/etc/netbox_network_importer/config.yml`
- Or you can set path to configuratin file like:
- `netbox_network_importer --config path_to_dir_with_config/ synchronize`
```
---
netbox:
NETBOX_API_TOKEN: "API_TOKEN"
NETBOX_INSTANCE_URL: "https://netbox.done-test.cesnet.cz/"
NETBOX_GRAPHQL_URL: "https://netbox.done-test.cesnet.cz/graphql/"
tacacs:
TACACS_USERNAME: "username"
TACACS_PASSWORD: "password"
config:
LOG_DIR: "path_where_output.log_will_be_stored"
LOG_LEVEL: "DEBUG"
OUTPUT_DIR: "output_folder_where_results_will_be_stored"
```
---
## Execute
The Netbox Network Importer runs only in apply mode.
- ~~In check mode, no modification will be made to the SOT, the differences will be printed on the screen~~
- In apply mode, the NETBOX will be updated with:
- interfaces
- IPs
- vlans
- LAGs
### Apply Mode
The Netbox Network Importer will attempt to create/update or delete all elements in the Netbox that do not match what has been observed in the network.
It will ignore devices or interfaces on certain circumstances:
- Device `status` must be `Active`, otherwise the device is skipped
- Device `primary_ip` must be properly set, otherwise the device is skipped
- Device `platform` must include one of the following values `[ios, iosxr, iosxe]`, otherwise the device is skipped
- If interface has attribute `Ignore Importer` set to `True`, then the processing on the Interface will be skipped and ignored
**Execution**:
- `netbox_network_importer synchronize` # runs the importer
- `netbox_network_importer synchronize -d Rxx` # runs importer on device Rxx from Netbox
- `netbox_network_importer synchronize -p iosxe` # runs importer on all devices with platform iosxe
- `netbox_network_importer synchronize -d Rxx -d Ryy` # runs importer on devices Rxx and Ryy
---
### Help
```
~/netbox_network_importer$ netbox_network_importer --help
Usage: netbox_network_importer [OPTIONS] COMMAND [ARGS]...
Options:
-c, --configs PATH path to folder with configurations
--help Show this message and exit.
Commands:
pyats Connect to device using pyats and pynetbox and print...
synchronize Run set of Nornir task to update data in Netbox from...
~/NETBOX/netbox_network_importer$ netbox_network_importer synchronize --help
Usage: netbox_network_importer synchronize [OPTIONS]
Run set of Nornir task to update data in Netbox from network devices
Args: devices (str): device name filter, can be used multiple times
platforms (str): platform name filter, can be used multiple times
no_progress_bar (bool): use to hide progress bar Returns: dict:
Dictionary of hosts, it's actions and results
Options:
-d, --devices TEXT Run on specificied devices
-p, --platforms TEXT Run on specificied platforms
--no-progress-bar
--help Show this message and exit.```
---
Raw data
{
"_id": null,
"home_page": "https://gitlab.cesnet.cz/701/done/netbox_network_importer",
"name": "netbox-network-importer",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6, <4",
"maintainer_email": "",
"keywords": "netbox,network",
"author": "Jan Krupa",
"author_email": "jan.krupa@cesnet.cz",
"download_url": "https://files.pythonhosted.org/packages/88/0a/d8d75d40d6153672ae3440ed0fb2508763ba0fb97c66ae3ca06689e3460e/netbox_network_importer-1.1.4.tar.gz",
"platform": null,
"description": "# Netbox Network Importer\n\nTool to analyze and synchronize an existing network with a Netbox (SOT).\n\nThe main use cases for the network importer: \n - Import an existing network into a Netbox\n - ~~Check the differences between the running network and the Netbox~~\n\n---\n## Install\n1. Clone repository\n - `git clone git@gitlab.cesnet.cz:701/done/netbox_network_importer.git`\n2. Go into the repository\n - `cd netbox_network_importer `\n3. Create `virtualenv`\n - `python3 -m venv venv`\n3. Activate it\n - `source venv/bin/activate`\n3. Install the tool\n - `pip install .`\n---\n## Pre-requisite\nTo operate, the Netbox Network Importer is dependent on the following items:\n- Access to Netbox API\n- Access to Network Devices via SSH\n- Created Custom Field on Netbox\n```json\n {\n \"display\": \"Ignore Importer\",\n \"content_types\": [\n \"dcim.interface\",\n ],\n \"type\": {\n \"value\": \"boolean\",\n \"label\": \"Boolean (true/false)\"\n },\n \"object_type\": null,\n \"data_type\": \"boolean\",\n \"name\": \"ignore_importer\",\n \"label\": \"Ignore Importer\",\n \"description\": \"Will be ignored when processed by Network Importer\",\n \"required\": true,\n \"filter_logic\": {\n \"value\": \"exact\",\n \"label\": \"Exact\"\n },\n \"default\": false,\n \"weight\": 100,\n }\n```\n---\n## Inventory\nA device inventory must be available in NetBox. \n\nTo be able to connect to the device the following information needs to be defined :\n- Primary ip address\n- Platform (must be a one of the following ['iosxr', 'ios', 'iosxe'])\n---\n## Configuration file\nThe information to connect to NetBox must be provided via the configuration file. The configuration file below present standard options that can be provided to control the behavior of the Netbox Network Importer.\n\nNetbox Network Importer try to find the configuration file at:\n- `/home/<user>/.config/netbox_network_importer/config.yml` \n- `/etc/netbox_network_importer/config.yml`\n- Or you can set path to configuratin file like:\n - `netbox_network_importer --config path_to_dir_with_config/ synchronize`\n```\n---\nnetbox:\n NETBOX_API_TOKEN: \"API_TOKEN\"\n NETBOX_INSTANCE_URL: \"https://netbox.done-test.cesnet.cz/\"\n NETBOX_GRAPHQL_URL: \"https://netbox.done-test.cesnet.cz/graphql/\"\ntacacs:\n TACACS_USERNAME: \"username\"\n TACACS_PASSWORD: \"password\"\n\nconfig:\n LOG_DIR: \"path_where_output.log_will_be_stored\"\n LOG_LEVEL: \"DEBUG\"\n OUTPUT_DIR: \"output_folder_where_results_will_be_stored\"\n```\n---\n## Execute\nThe Netbox Network Importer runs only in apply mode.\n- ~~In check mode, no modification will be made to the SOT, the differences will be printed on the screen~~\n- In apply mode, the NETBOX will be updated with:\n - interfaces\n - IPs\n - vlans \n - LAGs\n\n### Apply Mode\nThe Netbox Network Importer will attempt to create/update or delete all elements in the Netbox that do not match what has been observed in the network.\nIt will ignore devices or interfaces on certain circumstances:\n- Device `status` must be `Active`, otherwise the device is skipped\n- Device `primary_ip` must be properly set, otherwise the device is skipped\n- Device `platform` must include one of the following values `[ios, iosxr, iosxe]`, otherwise the device is skipped\n- If interface has attribute `Ignore Importer` set to `True`, then the processing on the Interface will be skipped and ignored\n\n**Execution**:\n- `netbox_network_importer synchronize` # runs the importer\n- `netbox_network_importer synchronize -d Rxx` # runs importer on device Rxx from Netbox\n- `netbox_network_importer synchronize -p iosxe` # runs importer on all devices with platform iosxe\n- `netbox_network_importer synchronize -d Rxx -d Ryy` # runs importer on devices Rxx and Ryy\n---\n\n### Help\n```\n~/netbox_network_importer$ netbox_network_importer --help\nUsage: netbox_network_importer [OPTIONS] COMMAND [ARGS]...\n\nOptions:\n -c, --configs PATH path to folder with configurations\n --help Show this message and exit.\n\nCommands:\n pyats Connect to device using pyats and pynetbox and print...\n synchronize Run set of Nornir task to update data in Netbox from...\n\n~/NETBOX/netbox_network_importer$ netbox_network_importer synchronize --help\nUsage: netbox_network_importer synchronize [OPTIONS]\n\n Run set of Nornir task to update data in Netbox from network devices\n\n Args: devices (str): device name filter, can be used multiple times\n platforms (str): platform name filter, can be used multiple times\n no_progress_bar (bool): use to hide progress bar Returns: dict:\n Dictionary of hosts, it's actions and results\n\nOptions:\n -d, --devices TEXT Run on specificied devices\n -p, --platforms TEXT Run on specificied platforms\n --no-progress-bar\n --help Show this message and exit.```\n---\n",
"bugtrack_url": null,
"license": "",
"summary": "Poll data from devices and store them into Netbox",
"version": "1.1.4",
"project_urls": {
"Homepage": "https://gitlab.cesnet.cz/701/done/netbox_network_importer"
},
"split_keywords": [
"netbox",
"network"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "880ad8d75d40d6153672ae3440ed0fb2508763ba0fb97c66ae3ca06689e3460e",
"md5": "c3b014fdc3f7c5e63cfd0079e8fb2eb9",
"sha256": "7bc3ca23b2ec7325c8bf83e0ee145927a2fbc4e1de8ea79bfbe5b4edcd8f9515"
},
"downloads": -1,
"filename": "netbox_network_importer-1.1.4.tar.gz",
"has_sig": false,
"md5_digest": "c3b014fdc3f7c5e63cfd0079e8fb2eb9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6, <4",
"size": 25719,
"upload_time": "2023-07-20T06:06:12",
"upload_time_iso_8601": "2023-07-20T06:06:12.227070Z",
"url": "https://files.pythonhosted.org/packages/88/0a/d8d75d40d6153672ae3440ed0fb2508763ba0fb97c66ae3ca06689e3460e/netbox_network_importer-1.1.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-20 06:06:12",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "netbox-network-importer"
}