Giter Site home page Giter Site logo

networktocode / ntc-netbox-plugin-onboarding Goto Github PK

View Code? Open in Web Editor NEW
246.0 52.0 46.0 984 KB

A plugin for NetBox to easily onboard new devices.

License: Other

Dockerfile 1.02% Python 93.51% HTML 5.05% Shell 0.42%
netbox-plugin netbox napalm netmiko network hacktoberfest

ntc-netbox-plugin-onboarding's Introduction

NetBox Onboarding plugin

Build Status

A plugin for NetBox to easily onboard new devices.

ntc-netbox-plugin-onboarding is using Netmiko, NAPALM & Django-RQ to simplify the onboarding process of a new device into NetBox down to an IP Address and a site. 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.

Installation

If using the installation pattern from the NetBox Documentation, you will need to activate the virtual environment before installing so that you install the package into the virtual environment.

cd /opt/netbox
source venv/bin/activate

The plugin is available as a Python package in pypi and can be installed with pip. Once the installation is completed, then NetBox and the NetBox worker must be restarted.

pip install ntc-netbox-plugin-onboarding
systemctl restart netbox netbox-rq

Compatibility Matrix

Netbox 2.8 Netbox 2.9 Netbox 2.10 Netbox 2.11
Onboarding Plugin 1.3 X
Onboarding Plugin 2.0 X X
Onboarding Plugin 2.1 X X X
Onboarding Plugin 2.2 X X X X

To ensure NetBox Onboarding plugin is automatically re-installed during future upgrades, create a file named local_requirements.txt (if not already existing) in the NetBox root directory (alongside requirements.txt) and list the ntc-netbox-plugin-onboarding package:

# echo ntc-netbox-plugin-onboarding >> local_requirements.txt

Once installed, the plugin needs to be enabled in your configuration.py

# In your configuration.py
PLUGINS = ["netbox_onboarding"]

# PLUGINS_CONFIG = {
#   "netbox_onboarding": {
#     ADD YOUR SETTINGS HERE
#   }
# }

Finally, make sure to run the migrations for this plugin

python3 manage.py migrate

The plugin behavior can be controlled with the following list of settings

  • 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)
  • 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.
  • 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.
  • 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.
  • create_management_interface_if_missing boolean (default True), If True, add management interface and IP address to the device. If False no management interfaces will be created, nor will the IP address be added to NetBox, while the device will still get added.
  • default_device_status string (default "active"), status assigned to a new device by default (must be lowercase).
  • default_device_role string (default "network")
  • default_device_role_color string (default FF0000), color assigned to the device role if it needs to be created.
  • default_management_interface string (default "PLACEHOLDER"), name of the management interface that will be created, if one can't be identified on the device.
  • default_management_prefix_length integer ( default 0), length of the prefix that will be used for the management IP address, if the IP can't be found.
  • skip_device_type_on_update boolean (default False), If True, an existing NetBox device will not get its device type updated. If False, device type will be updated with one discovered on a device.
  • skip_manufacturer_on_update boolean (default False), If True, an existing NetBox device will not get its manufacturer updated. If False, manufacturer will be updated with one discovered on a device.
  • platform_map (dictionary), mapping of an auto-detected Netmiko platform to the NetBox slug name of your Platform. The dictionary should be in the format:
    {
      <Netmiko Platform>: <NetBox Slug>
    }
  • onboarding_extensions_map (dictionary), mapping of a NAPALM driver name to the loadable Python module used as an onboarding extension. The dictionary should be in the format:
    {
      <Napalm Driver Name>: <Loadable Python Module>
    }
  • object_match_strategy (string), defines the method for searching models. There are currently two strategies, strict and loose. Strict has to be a direct match, normally using a slug. Loose allows a range of search criteria to match a single object. If multiple objects are returned an error is raised.

Upgrades

When a new release comes out it may be necessary to run a migration of the database to account for any changes in the data models used by this plugin. Execute the command python3 manage.py migratefrom the NetBox install netbox/ directory after updating the package.

Usage

Preparation

To properly onboard a device, the plugin needs to only know the Site as well as device's primary IP address or DNS Name.

For DNS Name Resolution to work, the instance of NetBox must be able to resolve the name of the device to IP address.

Providing other attributes (Platform, Device Type, Device Role) is optional - if any of these attributes is provided, plugin will use provided value for the onboarded device. 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.

If the Platform is provided, it must point to an existing NetBox Platform. NAPALM driver of this platform will be used only if it is defined for the platform in NetBox. To use a preferred NAPALM driver, either define it in NetBox per platform or in the plugins settings under platform_map

Onboard a new device

A new device can be onboarded via :

  • A web form /plugins/onboarding/add/
  • A CSV form to import multiple devices in bulk. /plugins/onboarding/import/
  • An API, POST /api/plugins​/onboarding​/onboarding​/

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.

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.

Consult the status of onboarding tasks

The status of the onboarding process for each device is maintained is a dedicated table in NetBox and can be retrived :

  • Via the UI /plugins/onboarding/
  • Via the API GET /api/plugins​/onboarding​/onboarding​/

API

The plugin includes 4 API endpoints to manage the onbarding tasks

GET        /api/plugins​/onboarding​/onboarding​/       Check status of all onboarding tasks.
POST    ​   /api/plugins​/onboarding​/onboarding​/       Onboard a new device
GET     ​   /api/plugins​/onboarding​/onboarding​/{id}​/  Check the status of a specific onboarding task
DELETE    ​ /api/plugins​/onboarding​/onboarding​/{id}​/  Delete a specific onboarding task

Contributing

Pull requests are welcomed and automatically built and tested against multiple version of Python and multiple version of NetBox through TravisCI.

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.

The project is following Network to Code software development guideline and is leveraging:

  • Black, Pylint, Bandit and pydocstyle for Python linting and formatting.
  • Django unit test to ensure the plugin is working properly.

CLI Helper Commands

The project is coming with a CLI helper based on invoke to help setup the development environment. The commands are listed below in 3 categories dev environment, utility and testing.

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

Local dev environment

  build            Build all docker images.
  debug            Start NetBox and its dependencies in debug mode.
  destroy          Destroy all containers and volumes.
  start            Start NetBox and its dependencies in detached mode.
  stop             Stop NetBox and its dependencies.

Utility

  cli              Launch a bash shell inside the running NetBox container.
  create-user      Create a new user in django (default: admin), will prompt for password.
  makemigrations   Run Make Migration in Django.
  nbshell          Launch a nbshell session.

Testing

  tests            Run all tests for this plugin.
  pylint           Run pylint code analysis.
  pydocstyle       Run pydocstyle to validate docstring formatting adheres to NTC defined standards.
  bandit           Run bandit to validate basic static code security analysis.
  black            Run black to check that Python files adhere to its style standards.
  unittest         Run Django unit tests for the plugin.

Questions

For any questions or comments, please check the FAQ first and feel free to swing by the Network to Code slack channel (channel #networktocode). Sign up here

Screenshots

List of Onboarding Tasks Onboarding Tasks

CSV form to import multiple devices CSV Form

Onboard a single device Single Device Form

Menu Menu

ntc-netbox-plugin-onboarding's People

Contributors

carbonarok avatar chadell avatar dgarros avatar glennmatthews avatar jeremypng avatar jvanderaa avatar mzbroch avatar ndom91 avatar nniehoff avatar phillsimonds avatar ryanmerolle avatar shakefu avatar whitej6 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ntc-netbox-plugin-onboarding's Issues

Specify 2.8.1 as the minimum version

Environment

  • Python version: 3.7
  • NetBox version: 2.8.0
  • ntc-netbox-plugin-onboarding version: 1.0.0

Steps to Reproduce

  1. Install NetBox v2.8.0
  2. Install plugin
  3. Attempt to run migrations

Expected Behavior

Migrations to successfully apply.

Observed Behavior

django.db.migrations.exceptions.NodeNotFoundError: Migration netbox_onboarding.0001_initial dependencies reference nonexistent parent node ('dcim', '0105_interface_name_collation')

The issue here is the plugin specifies 0105_interface_name_collation as a dependency in its initial migration. This is likely due to the plugin being initially developed against 2.8.1, as that is the NetBox version where that dependant migration first appeared.

Because people have already installed this plugin in environments, the correct solution here is to specify the plugin's minimum NetBox version to be 2.8.1.

Failed Task - Restart Button

Environment

  • Python version: 3.7.7
  • NetBox version: 2.8.8
  • ntc-netbox-plugin-onboarding version: 1.1

Proposed Functionality

After a failed task it would be beneficial to have a restart button to retry the onboarding.

Use Case

During initial use of the onboarding application your NetBox instance may require changes to the environment to get into a working state. It would be helpful to allow the changes to be made and then restart a failed task

Onboarding device fails with "create_management_interface_if_missing"

Environment

  • Python version: 3.6.8
  • NetBox version: 2.8.7
  • ntc-netbox-plugin-onboarding version: 1.2.0

After upgrading the onboarding plugin onboarding a new device fails with "create_management_interface_if_missing". Device is created but the management interface is missing.

For this switch I do not have a dedicated management interface but I use inline management of VLAN10.

With verison 1.1.0 of the pluging onboarding created the VLAN10 as the management interface correctly. After upgrade to version 1.2 he device is created but no interface for that device is generated.

Steps to Reproduce

  1. Upgrade the onboarding pluging from 1.1.0 to 1.2.0
  2. onboard a device with site and IP address
  3. wait for the error.
  4. Device is created, but without interface.

Expected Behavior

Device being created with the VLAN10 interface.

Observed Behavior

Device created without the interface.

Add support for NetBox's NAPALM arguments

Platform View (dcim/platforms/) allows to specify custom NAPALM arguments - currently those are not respected by the onboarding plugin.

  1. Add support for NetBox's NAPALM arguments in get_onboarding_facts
  2. Highest priority for NAPALM arguments is NetBox
  3. Lower priority for NAPALM arguments is env variables (settings.NAPALM_ARGS)
  4. Arguments (NetBox and env) should be merged

Add option for onboard process to add all interfaces

NetBox Cersion: 2.8.4
OnBoarding Plugin Version: 1.0.0
Python Version: 3.6.8
NAPALM Version: 3.0.1
Arista EOS Version: 4.22.5M

It looks like at least with EOS, when you onboard a device only the interface associated to the IP used to onboard the device is created with the new device.

cisco enable secret aren't passed through

The cisco enable secret isn't passed to the onboarding.
Thus "enable" doesn't work.

diff:
--- a/netbox_onboarding/worker.py
+++ b/netbox_onboarding/worker.py
@@ -29,6 +29,8 @@ def onboard_device(task_id, credentials):
"""Process a single OnboardingTask instance."""
username = credentials.username
password = credentials.password

  • secret = credentials.secret

    try:
    ot = OnboardingTask.objects.get(id=task_id)
    @@ -43,7 +45,7 @@ def onboard_device(task_id, credentials):
    ot.status = OnboardingStatusChoices.STATUS_RUNNING
    ot.save()

  •    netdev = NetdevKeeper(ot, username, password)
    
  •    netdev = NetdevKeeper(ot, username, password, secret)
       nbk = NetboxKeeper(netdev=netdev)
    
       netdev.get_required_info()
    

Add documentation visible when viewing the on-board device form

When you navigate to the form to execute a task, there is a question mark icon for help. When clicking that, there is no documentation and the following error is displayed:

Unable to load documentation, file not found: /opt/netbox/docs/models/netbox_onboarding/onboardingtask.md

We don't need much, but something describing the plugin and maybe some common questions and use cases?

add transport telnet

This is maybe a bit dirty.
To facilitate the telnet "transport" instead of ssh.
When port 23 is selected, add automatically the transport:telnet option

diff:
--- a/netbox_onboarding/onboard.py
+++ b/netbox_onboarding/onboard.py
@@ -321,6 +321,10 @@ class NetdevKeeper:
driver = get_network_driver(driver_name)
optional_args = settings.NAPALM_ARGS.copy()
optional_args["secret"] = self.secret
+

  •        if self.ot.port == 23:
    
  •           optional_args["transport"] = "telnet"
    
  •        dev = driver(
               hostname=mgmt_ipaddr,
               username=self.username,
    

Detect unknown devices

Environment

  • Python version: any
  • NetBox version: any
  • ntc-netbox-plugin-onboarding version: any

Onboarding plugin could detect yet unknown devices

Proposed Functionality

Based on known devices the onboarding plugin could detect its neighbors by various means. On known devices it could request

  • LLDP, CDP, ... discovery protocols
  • ARP table
  • Routing table

to gather information about existing devices per site. The plugin could check, which devices are already known to netbox and
start an onboarding process for yet unknown devices.

Since only devices that do exist in the network, to time consuming scannning would happen. Variables could limit the scope of the detection (by IP address, by system name, or others).

For a proof-of-concept see:
https://groups.google.com/g/netbox-discuss/c/AjUXGZAQ81Q

Use Case

This feature would automatically onboard all devices in a site without previous knowledge. Or it would show devices that exist but cannot be accessed because the credentials do not fit.

Autocreated DeviceRole has no assigned color

When the plugin automatically creates a DeviceRole, it doesn't set any color value for this role. Apparently in NetBox the label display for a colorless role defaults to white text on a clear background, which is nearly invisible in the UI. The role should have a default color assigned to it so that it's visible as a label.

image

Gather information about interfaces while onboarding

Environment

  • Python version: any
  • NetBox version: any
  • ntc-netbox-plugin-onboarding version: any

While onboarding a device, the plugin also could gather information about the interfaces.

Proposed Functionality

At the moment the onboarding plugin only gathers basic information about a new device. But while onboarding it also could gather information about the interfaces. An option could limit ("regex") the names of the interfaces to recognize.

A proof-of-concept written in ansible for a Cisco device:


  • name: Test
    hosts: switch07

    tasks:

    • name: Setup
      netbox.netbox.netbox_device_interface:
      netbox_url: http://127.0.0.1:8000
      netbox_token: 123456
      data:
      device: switch07
      description: "{{ item.value.description }}"
      name: "{{ item.key }}"
      type: 1000Base-T (1GE)
      enabled: "{{ item.value.operstatus == 'up' }}"
      loop: "{{ ansible_facts.net_interfaces | dict2items }}"
      when: item.value.type is match ("Gigabit Ethernet")
      delegate_to: localhost

Use Case

Makes the life of an admin easier because he would not have to add in interfaces manually after onboarding a device.

Add support for Multi-member devices

Environment

  • Python version: 3.7.7
  • NetBox version: 2.8.7
  • ntc-netbox-plugin-onboarding version: 1.2.0

Proposed Functionality

Add support for multi-member devices like Cisco Stackwise or Juniper Virtual Chassis. (1 logicial device, 1 configuration, multiple physical devices)
When a device composed of multiple members is getting onboarded, each member should be created in NetBox with its own serial number and all members should be part of a Virtual Chassis Object with the appropriate number id.

The name of the primary device in the stack/vc should be the hostname of the device and the other members should have a name derived from the hostname:

  • Hostname: stackA
  • Primary device name: stackA
  • other_member: stackA:{memberid}

There are other similar devices that would be great to support in the future like Cisco VSS

If a multi member device with the same hostname already exist, each member should be updated to reflect the current status of the device: serial number, member id, new member, missing member etc ...

Use Case

The use case for this feature is to simplify the onboarding of multi member devices and provide a framework to support vendor specific code.

default_device_status ignored

Environment

  • Python version: 3.6.8
  • NetBox version: 2.8.7
  • ntc-netbox-plugin-onboarding version: 1.1.0

Cofigured the onboarding plugin according to doc. Onboarding is working, but the option is ignored.

Steps to Reproduce

  1. Install
  2. Configure
  3. Run

Expected Behavior

New device with given default status created in netbox.

Observed Behavior

New device with state "Active" created in netbox.

netbox config is:

PLUGINS_CONFIG = {
  'netbox_onboarding': {
    'default_device_status': 'staged'
  }
}

unable to import plugin netbox_onboarding

Environment

  • Python version: 3.6
  • NetBox version: 2.9.3
  • ntc-netbox-plugin-onboarding version: 1.3

Steps to Reproduce

1.sudo /opt/netbox/venv/bin/gunicorn --pid /var/tmp/netbox.pid --pythonpath /opt/netbox/netbox --config /opt/netbox/gunicorn.py netbox.wsgi
2.
3.

Expected Behavior

to see onboarding option avaialbe on UI

Observed Behavior

Traceback (most recent call last):
File "/opt/netbox/venv/lib64/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/opt/netbox/venv/lib64/python3.6/site-packages/gunicorn/workers/gthread.py", line 92, in init_process
super().init_process()
File "/opt/netbox/venv/lib64/python3.6/site-packages/gunicorn/workers/base.py", line 119, in init_process
self.load_wsgi()
File "/opt/netbox/venv/lib64/python3.6/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
self.wsgi = self.app.wsgi()
File "/opt/netbox/venv/lib64/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/opt/netbox/venv/lib64/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
return self.load_wsgiapp()
File "/opt/netbox/venv/lib64/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
return util.import_app(self.app_uri)
File "/opt/netbox/venv/lib64/python3.6/site-packages/gunicorn/util.py", line 358, in import_app
mod = importlib.import_module(module)
File "/usr/lib64/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 665, in _load_unlocked
File "", line 678, in exec_module
File "", line 219, in _call_with_frames_removed
File "/opt/netbox/netbox/netbox/wsgi.py", line 7, in
application = get_wsgi_application()
File "/opt/netbox/venv/lib64/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
django.setup(set_prefix=False)
File "/opt/netbox/venv/lib64/python3.6/site-packages/django/init.py", line 19, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/opt/netbox/venv/lib64/python3.6/site-packages/django/conf/init.py", line 83, in getattr
self._setup(name)
File "/opt/netbox/venv/lib64/python3.6/site-packages/django/conf/init.py", line 70, in _setup
self._wrapped = Settings(settings_module)
File "/opt/netbox/venv/lib64/python3.6/site-packages/django/conf/init.py", line 177, in init
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib64/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 665, in _load_unlocked
File "", line 678, in exec_module
File "", line 219, in _call_with_frames_removed
File "/opt/netbox/netbox/netbox/settings.py", line 599, in
"correct Python environment.".format(plugin_name)
django.core.exceptions.ImproperlyConfigured: Unable to import plugin netbox_onboarding: Module not found. Check that the plugin module has been installed within the correct Python environment.

Add support for NetBox 2.9

Environment

  • Python version: 3.7.7
  • NetBox version: 2.9.2
  • ntc-netbox-plugin-onboarding version: 1.3.0

Proposed Functionality

We need to add support for NetBox 2.9, I don't foresee major changes but looks like the tests are not passing current in with the master branch from the netbox project

Use Case

Ensure the plugin is working properly with NetBox 2.9 and fix the unit tests

Possibility to add a label while onbaording

Environment

  • Python version: 3.6.8
  • NetBox version: 2.8.7
  • ntc-netbox-plugin-onboarding version: 1.2.0

It would be nice to have the possibilty to add a label to onboarded devices. This could help when automating the follow-up processes after onboarding new devices.

Example:

  1. Onboard a new device with the label "new"
  2. For all devices with the label "new"
    2.1 Trigger the collection of interface information
    2.2 Delete the label "new"

So after onbaording a new deivce, additional information could be collected.

Proposed Functionality

See above

Use Case

See above

csv import function missing device_type override option

Environment

  • Python version: 3.7.7
  • NetBox version: 2.8.4
  • ntc-netbox-plugin-onboarding version: 1.0.0

Steps to Reproduce

Go to import option.

Expected Behavior

csv import function should have all the fields the single device web form shows.

Observed Behavior

csv import function missing device_type override option

NetBox 2.9 - Bulk onboarding

Hello,

when trying do a bulk import, the following error occurs:

<class 'AttributeError'>

'OnboardingTask' object has no attribute '_cf'

Python version: 3.6.9
NetBox version: 2.9.2

Is this a bug or have I misconfigured the system?

Thank you.

Onboarding does not trigger webhook "device->create"

Environment

  • Python version: 3.6.8
  • NetBox version: 2.8.7
  • ntc-netbox-plugin-onboarding version: 1.2.0

When onboarding a device the webhook for device creation is not triggered.

I did create a webhook with dcim->device create and update. It works if I create or update a new device manually. But onboarding the device does not trigger the webhook.

You also can this behaviour in the changelog of the device. If the device was onboarded, the changelog is empty.

Steps to Reproduce

  1. Create a webhook for device->create
  2. onboard a device
  3. webhook is not triggered.

Expected Behavior

webhook to be triggered.

Observed Behavior

nothing.

Re-onboarding of an existing device is not working if the device type is not present

Environment

  • Python version: 3.7.7
  • NetBox version: 2.8.8
  • ntc-netbox-plugin-onboarding version: 1.2.0

Steps to Reproduce

  1. Disable create_device_type_if_missing
  2. Ensure the device type matching the device is not already present
  3. Re-onboard an existing device

Expected Behavior

Since the device already exist and already have a device_type assigned, the re-onboarding should work as expected.

Observed Behavior

The re-onboarding is failing because the device_type is not present

No NAPALM driver for Napalm-ros

Environment

  • Python version: 3.8.5
  • NetBox version: 2.9.7
  • ntc-netbox-plugin-onboarding version: 2.0.0

Just got using netbox. I installed an on-boarding plugin but it does not work for mikrotik routeros routers.
I get this error message.

OnboardException: fail-general: Onboarding for Platform None not supported, as it has no specified NAPALM driver

(venv) root@netbox:/opt/netbox# pip freeze
napalm==2.5.0

PLUGINS = [
"netbox_onboarding"]

I went ahead to install napalm-ros module. I decided to add it as a plugin, it crashed the netbox application. Stating no napalm-ros app found.

(venv) root@netbox:/opt/netbox# pip freeze
napalm==2.5.0
napalm-ros==0.8.0

(venv) root@netbox:/opt/netbox# cat local_requirements.txt
napalm
django-storages
ntc-netbox-plugin-onboarding
napalm-ros

(venv) root@netbox:/opt/netbox# pip install local_requirements.txt
ERROR: Could not find a version that satisfies the requirement local_requirements.txt (from versions: none)
ERROR: No matching distribution found for local_requirements.txt

PLUGINS = [
"netbox_onboarding",
"napalm_ros"]

(venv) root@netbox:/opt/netbox/netbox# python3 manage.py migrate
File "/opt/netbox/netbox/netbox/urls.py", line 8, in
from extras.plugins.urls import plugin_admin_patterns, plugin_patterns, plugin_api_patterns
File "/opt/netbox/netbox/extras/plugins/urls.py", line 24, in
app = apps.get_app_config(plugin_name)
File "/opt/netbox/venv/lib/python3.8/site-packages/django/apps/registry.py", line 162, in get_app_config
raise LookupError(message)
LookupError: No installed app with label 'napalm-ros'.

At this point netbox crashes.

Pass netbox plugin settings for default mappings

Environment

  • Python version: 3.7.7
  • NetBox version: 2.8.5
  • ntc-netbox-plugin-onboarding version: Example: 1.0.0

Proposed Functionality

The NetBox plugins function has a way to pass cars from the NetBox config file for the deployed plugin. It would be useful to use this function to pass platform and manufacturer name mappings. Example:

 PLUGINS_CONFIG = {
   "netbox_onboarding": {
      platform_map: {
            "arista_eos": "eos",
            "cisco_ios": "ios",
     },
      manufacturer_map: {
            "Arista": "Arista Networks",
            "Cisco": "Cisco Networks",
     },
   }
 }

Use Case

This would be useful if individuals did not want to rename their current platform and manufacturers or the associated slugs. It may seem like a minor hurtle for some people, but their automation may already match a slug they set already or they may want the slug to exactly match the napalm driver.

Onboard Existing Devices

Add functionality to update existing devices.

I need to hash out the specifics, but it would be useful to update devices that are already in NetBox based on a hostname and site match.

Some people have workflows where they rack devices or at least mark said devices as planned in a rack. It could be useful to allow you to complete the onboard process of these devices even though they are technically in NetBox.

Navigating to plugins/onboarding/import/ causes Server Error: 'OnboardingTask' object has no attribute '_cf'

Environment

  • Python version: 3.8.2
  • NetBox version: 2.9.4
  • ntc-netbox-plugin-onboarding version: 1.3.0

Steps to Reproduce

  1. Navigate to plugins/onboarding/import/ or
  2. From the Onboarding Tasks page, click on the "Import" button, or
  3. From the Home page, click on Plugins > Onboarding Tasks > "Bulk Import" button.

Expected Behavior

I expected the Onboarding Task Bulk Import page to be displayed.

Observed Behavior

Received the following exception:

"Server Error

There was a problem with your request. Please contact an administrator.

The complete exception is provided below:

<class 'AttributeError'>

'OnboardingTask' object has no attribute '_cf'

Python version: 3.8.2
NetBox version: 2.9.4"

Screenshot also attached.

onboarding

Devices never get added

Environment

  • Python version: 3.6.8
  • NetBox version: 2.8.5
  • ntc-netbox-plugin-onboarding version: 1.1.0

Steps to Reproduce

  1. https://netbox/plugins/onboarding/add/ - Add the device per instructions provided
  2. Click on "Create"
  3. Check device status under Onboarding Tasks or under the Admin panel

Expected Behavior

Device to be added

Observed Behavior

New device never gets added.

Uppercase Device Type Model slug causes duplicate key value error

Environment

  • Python version: 3.7.2
  • NetBox version: 2.8.5
  • ntc-netbox-plugin-onboarding version: 1.1.0

Steps to Reproduce

  1. Create a Device Type with a Model Slug that is in ALL CAPITALS(also had the main name of the device as the same)
  2. Onboard the device

Expected Behavior

Successful onboarding of device, no new addition of the Device Type.

Observed Behavior

Platform is successfully populated but after that it fails.

Seems it was trying to recreate the Device Type even if I set it to not create if not found.

Onboarding Tasks states the following:

fail-general: duplicate key value violates unique constraint "dcim_devicetype_manufacturer_id_model_17948c0c_uniq" DETAIL: Key (manufacturer_id, model)=(2, WS-C2960C-8TC-L) already exists.

Workaround

Go to device type -> model slug and turn the UPPERCASE into lowercase. Did not modify the device model name

onboarding fails 'ipv4' when onboarding

In the case the interface has no ipv4 address, but has ipv6, the onboarding fails with "ipv4" error message.

Diff to fix this:
diff --git a/netbox_onboarding/onboard.py b/netbox_onboarding/onboard.py
index d646af1..3b1c3e2 100644
--- a/netbox_onboarding/onboard.py
+++ b/netbox_onboarding/onboard.py
@@ -354,7 +354,7 @@ class NetdevKeeper:
def get_mgmt_info():
"""Get the interface name and prefix length for the management interface."""
for if_name, if_data in ip_ifs.items():

  •            for if_addr, if_addr_data in if_data["ipv4"].items():
    
  •            for if_addr, if_addr_data in if_data.get("ipv4",{}).items()::
                   if if_addr == mgmt_ipaddr:
                       return (if_name, if_addr_data["prefix_length"])
           return (default_mgmt_if, default_mgmt_pfxlen)
    

Add a setting for default Status

Currently all devices onboarded with this plugin will have the status Active, by default.

The proposal is to turn the default status into a setting that will allow each user to define his/her own.

Improve management of configuration.py files for testing

In the current implementation (#14) , we are maintaining a configuration.py file per version of NetBox that is defined in .travis.yml, the idea is to support multiple versions of NetBox in the future that might require different configuration.py file.
This solution is working for now but not sure if it will be easy to manage over time.

This issue is meant to track this discussion and collect additional ideas

Create OnboardingDevice instance for existing devices

OnboardingDevice is a new model added in the ntc-netbox-plugin-onboarding release 2.0

The goal of the OnboardingDevice model is to:

  • provide information about the Device model related to the OnboardingDevice (including last time of onboarding or the status of the onboarding)
  • provide settings related to the onboarded Device (if the onboarding is enabled/disabled or future settings)

Currently, the OnboardingDevice() instance is created automatically, due to registration for signal, every time a new Device is created in NetBox. This will not cover the situations for NetBox brownfield environments, where the Devices already exist, and the action of re-onboarding is applied on the Devices. In this case, the re-onboarding will not create the OnboardingDevice() model instance.

Goal of this issue is to solve this behaviour by implementing a solution where a OnboardingDevice will be automatically created during re-onboarding for the existing NetBox Device()

Add Support for SSH Keys

Environment

  • Python version: 3.7.7
  • NetBox version: 2.8.8
  • ntc-netbox-plugin-onboarding version: 1.1

Proposed Functionality

Would like to allow the application to use SSH keys to log into network devices.

Use Case

Look at either requiring the use of NetBox server keys, or to include a key file for the onboarding task to log into network devices.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.