|
1 |
| -# NetBox Onboaring plugin |
| 1 | +# NetBox Onboarding plugin |
2 | 2 |
|
3 | 3 | <!-- Build status with linky to the builds for ease of access. -->
|
4 | 4 | [](https://travis-ci.com/networktocode/ntc-netbox-plugin-onboarding)
|
5 | 5 |
|
6 |
| -<!-- TODO: https://github.com/networktocode/ntc-netbox-plugin-onboarding/issues/3 |
| 6 | +A plugin for [NetBox](https://github.com/netbox-community/netbox) to easily onboard new devices. |
7 | 7 |
|
8 |
| -Improve this readme with accurate descriptions of what this does, as well as |
9 |
| -appropriate links to rendered documentation and standard sections such as: |
| 8 | +`ntc-netbox-plugin-onboarding` is using [Netmiko](https://github.com/ktbyers/netmiko), [NAPALM](https://napalm.readthedocs.io/en/latest/) & [Django-RQ](https://github.com/rq/django-rq) to simplify the onboarding process of a new device into NetBox down to an IP Address and a site. |
| 9 | +The goal of this plugin is not to import everything about a device into NetBox but rather to help build quickly an inventory in NetBox that is often the first step into an automation journey. |
10 | 10 |
|
11 | 11 | ## Installation
|
12 | 12 |
|
| 13 | +The plugin is available as a Python package in pypi and can be installed with pip |
| 14 | +```shell |
| 15 | +pip install ntc-netbox-plugin-onboarding |
| 16 | +``` |
| 17 | + |
| 18 | +Once installed, the plugin needs to be enabled in your `configuration.py` |
| 19 | +```python |
| 20 | +# In your configuration.py |
| 21 | +PLUGINS = ["netbox_onboarding"] |
| 22 | + |
| 23 | +# PLUGINS_CONFIG = { |
| 24 | +# "netbox_onboarding": { |
| 25 | +# ADD YOUR SETTINGS HERE |
| 26 | +# } |
| 27 | +# } |
| 28 | +``` |
| 29 | + |
| 30 | +The plugin behavior can be controlled with the following list of settings |
| 31 | + |
| 32 | +- `create_platform_if_missing` boolean (default True), If True, a new platform object will be created if the platform discovered by netmiko do not already exist and is in the list of supported platforms (`cisco_ios`, `cisco_nxos`, `arista_eos`, `juniper_junos`, `cisco_xr`) |
| 33 | +- `create_device_type_if_missing` boolean (default True), If True, a new device type object will be created if the model discovered by Napalm do not match an existing device type. |
| 34 | +- `create_manufacturer_if_missing` boolean (default True), If True, a new manufacturer object will be created if the manufacturer discovered by Napalm is do not match an existing manufacturer, this option is only valid if `create_device_type_if_missing` is True as well. |
| 35 | +- `create_device_role_if_missing` boolean (default True), If True, a new device role object will be created if the device role provided was not provided as part of the onboarding and if the `default_device_role` do not already exist. |
| 36 | +- `default_device_role` string (default "network") |
| 37 | + |
13 | 38 | ## Usage
|
| 39 | +### Preparation |
14 | 40 |
|
15 |
| -## Contributing |
| 41 | +To work properly the plugin needs to know the Site, Platform, Device Type, Device Role of each device as well as its primary IP address. |
| 42 | +It's recommended to create these objects in NetBox ahead of time and to provide them when you want to start the onboarding process. |
| 43 | + |
| 44 | +If `Platform`, `Device Type` and/or `Device Role` are not provided, the plugin will try to identify these information automatically and, based on the settings, it can create them in NetBox as needed. |
| 45 | +> If the Platform is provided, it must contains a valid Napalm driver available to the worker in Python |
| 46 | +
|
| 47 | +### Onboard a new device |
16 | 48 |
|
17 |
| ---> |
| 49 | +A new device can be onboarded via : |
| 50 | +- A web form `/plugins/onboarding/add/` |
| 51 | +- A CSV form to import multiple devices in bulk. `/plugins/onboarding/import/` |
| 52 | +- An API, `POST /api/plugins/onboarding/onboarding/` |
18 | 53 |
|
| 54 | +During a successful onboarding process, a new device will be created in NetBox with its management interface and its primary IP assigned. The management interface will be discovered on the device based on the IP address provided. |
19 | 55 |
|
| 56 | +> By default, the plugin is using the credentials defined in the main `configuration.py` for Napalm (`NAPALM_USERNAME`/`NAPALM_PASSWORD`). It's possible to define specific credentials for each onboarding task. |
| 57 | +
|
| 58 | +### Consult the status of onboarding tasks |
| 59 | + |
| 60 | +The status of the onboarding process for each device is maintained is a dedicated table in NetBox and can be retrived : |
| 61 | +- Via the UI `/plugins/onboarding/` |
| 62 | +- Via the API `GET /api/plugins/onboarding/onboarding/` |
| 63 | + |
| 64 | +### API |
| 65 | + |
| 66 | +The plugin includes 4 API endpoints to manage the onbarding tasks |
| 67 | + |
| 68 | +```shell |
| 69 | +GET /api/plugins/onboarding/onboarding/ Check status of all onboarding tasks. |
| 70 | +POST /api/plugins/onboarding/onboarding/ Onboard a new device |
| 71 | +GET /api/plugins/onboarding/onboarding/{id}/ Check the status of a specific onboarding task |
| 72 | +DELETE /api/plugins/onboarding/onboarding/{id}/ Delete a specific onboarding task |
20 | 73 | ```
|
21 |
| -invoke --list |
22 |
| -Available tasks: |
23 | 74 |
|
| 75 | +## Contributing |
| 76 | + |
| 77 | +Pull requests are welcomed and automatically built and tested against multiple version of Python and multiple version of NetBox through TravisCI. |
| 78 | + |
| 79 | +The project is packaged with a light development environment based on `docker-compose` to help with the local development of the project and to run the tests within TravisCI. |
| 80 | + |
| 81 | +The project is following Network to Code software development guideline and is leveraging: |
| 82 | +- Black, Pylint, Bandit and pydocstyle for Python linting and formatting. |
| 83 | +- Django unit test to ensure the plugin is working properly. |
| 84 | + |
| 85 | +### CLI Helper Commands |
| 86 | + |
| 87 | +The project is coming with a CLI helper based on [invoke](http://www.pyinvoke.org/) to help setup the development environment. The commands are listed below in 3 categories `dev environment`, `utility` and `testing`. |
| 88 | + |
| 89 | +Each command can be executed with `invoke <command>`. All commands support the arguments `--netbox-ver` and `--python-ver` if you want to manually define the version of Python and NetBox to use. Each command also has its own help `invoke <command> --help` |
| 90 | + |
| 91 | +#### Local dev environment |
| 92 | +``` |
24 | 93 | build Build all docker images.
|
25 |
| - cli Launch a bash shell inside the running NetBox container. |
26 |
| - create-user Create a new user in django (default: admin), will prompt for password |
27 | 94 | debug Start NetBox and its dependencies in debug mode.
|
28 | 95 | destroy Destroy all containers and volumes.
|
29 |
| - makemigrations Run Make Migration in Django |
30 |
| - nbshell Launch a nbshell session. |
31 | 96 | start Start NetBox and its dependencies in detached mode.
|
32 | 97 | stop Stop NetBox and its dependencies.
|
33 | 98 | ```
|
| 99 | + |
| 100 | +#### Utility |
| 101 | +``` |
| 102 | + cli Launch a bash shell inside the running NetBox container. |
| 103 | + create-user Create a new user in django (default: admin), will prompt for password. |
| 104 | + makemigrations Run Make Migration in Django. |
| 105 | + nbshell Launch a nbshell session. |
| 106 | +``` |
| 107 | +#### Testing |
| 108 | + |
| 109 | +``` |
| 110 | + tests Run all tests for this plugin. |
| 111 | + pylint Run pylint code analysis. |
| 112 | + pydocstyle Run pydocstyle to validate docstring formatting adheres to NTC defined standards. |
| 113 | + bandit Run bandit to validate basic static code security analysis. |
| 114 | + black Run black to check that Python files adhere to its style standards. |
| 115 | + unittest Run Django unit tests for the plugin. |
| 116 | +``` |
| 117 | + |
| 118 | +## Questions |
| 119 | + |
| 120 | +For any questions or comments, please check the [FAQ](FAQ.md) first and feel free to swing by the [Network to Code slack channel](https://networktocode.slack.com/) (channel #networktocode). |
| 121 | +Sign up [here](http://slack.networktocode.com/) |
| 122 | + |
| 123 | +## Screenshot |
| 124 | + |
| 125 | +Onboard a single device |
| 126 | + |
0 commit comments