GithubHelp home page GithubHelp logo

j-tb / nautobot-plugin-device-onboarding Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nautobot/nautobot-app-device-onboarding

0.0 0.0 0.0 852 KB

Device Onboarding Plugin for Nautobot

License: Other

Dockerfile 0.46% Shell 0.35% Python 95.97% HTML 3.22%

nautobot-plugin-device-onboarding's Introduction

Nautobot Device Onboarding plugin

Build Status

A plugin for Nautobot to easily onboard new devices.

nautobot-device-onboarding is using Netmiko, NAPALM & Django-RQ to simplify the onboarding process of a new device into Nautobot down to an IP Address and a site. The goal of this plugin is not to import everything about a device into Nautobot but rather to help build quickly an inventory in Nautobot that is often the first step into an automation journey.

Installation

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

sudo -iu nautobot
# This may not be required if already in the /opt/nautobot directory
cd /opt/nautobot
source bin/activate

The plugin is available as a Python package in pypi and can be installed with pip.

pip install nautobot-device-onboarding

Compatibility Matrix

Nautobot 1.0
Device Onboarding plugin 1.0 X

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

# echo nautobot-device-onboarding >> local_requirements.txt

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

# In your nautobot_config.py
PLUGINS = ["nautobot_device_onboarding"]

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

Finally, run the migrations for this plugin, and restart Nautobot and the Nautobot worker.

nautobot-server migrate
systemctl restart nautobot nautobot-worker

Plugin Configuration Options

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 Nautobot, 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 Nautobot 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 Nautobot 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 Nautobot slug name of your Platform. The dictionary should be in the format:
    {
      <Netmiko Platform>: <Nautobot 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 nautobot-server migrate from the Nautobot install nautobot/ 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 Nautobot 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 Nautobot as needed.

If the Platform is provided, it must point to an existing Nautobot Platform. NAPALM driver of this platform will be used only if it is defined for the platform in Nautobot. To use a preferred NAPALM driver, either define it in Nautobot 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/device-onboarding/add/
  • A CSV form to import multiple devices in bulk. /plugins/device-onboarding/import/
  • An API, POST /api/plugins​/device-onboarding​/onboarding​/

During a successful onboarding process, a new device will be created in Nautobot 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 Nautobot and can be retrived :

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

API

The plugin includes 4 API endpoints to manage the onbarding tasks

GET        /api/plugins​/device-onboarding​/onboarding​/       Check status of all onboarding tasks.
POST    ​   /api/plugins​/device-onboarding​/onboarding​/       Onboard a new device
GET     ​   /api/plugins​/device-onboarding​/onboarding​/{id}​/  Check the status of a specific onboarding task
DELETE    ​ /api/plugins​/device-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 Nautobot 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 --nautobot-ver and --python-ver if you want to manually define the version of Python and Nautobot to use. Each command also has its own help invoke <command> --help

Local dev environment

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

Utility

  cli              Launch a bash shell inside the running Nautobot 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

nautobot-plugin-device-onboarding's People

Contributors

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

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.