A NetBox Plugin that gives a UI for generating, comparing and deploying configurations to devices.

Overview

netbox_config_plugin - A plugin to generate, compare and deploy configurations

This plugin allows you to execute your code to generate a config for a device, compare it to the current config of that device and replace configuration with the generated config.

Status of this Plugin

This plugin is compatible with NetBox 3.0.0 to v3.0.7. It is not compatible with versions older than 3.0.0

A basic understanding of python, objects, python modules and the NetBox Django models is required to install this plugin as you have to provide some code on your own that will interact with NetBox.

This plugin is in an early development stage. This features, requirements, UI and workflows of this plugin may change often. Use at your own risk. Please report bugs as a Github issue.

All interactions with the device are done with NAPALM so this should work with any device supported by NAPALM. Although currently only IOS-XE is tested. The general caveats for NAPALM still apply.

Things not included in this plugin

You need to provide on your own:

  • code for generating configs
  • code for wether a device should be configured using this plugin
  • code for gathering the required NAPALM connection data like
    • hostnames
    • usernames
    • passwords and secrets
    • further options that might be required

Details regarding those can be found in the config section.

Installation

First you need to install this python module into your NetBox virtualenv. For a regular NetBox install this can be done by adding it to the local_requirements.txt file.

> /opt/netbox/local_requirements.txt ">
echo "git+https://github.com/991jo/netbox_config_plugin#egg=netbox_config_plugin" >> /opt/netbox/local_requirements.txt

After that you have to add it and the netbox-plugin-extensions the netbox configuration.

, "CONFIG_GENERATOR": , "CONNECTION_OPTIONS": } } } ">
# /opt/netbox/netbox/netbox/configuraton.py

...

PLUGINS = [
	"netbox_config_plugin",
	"netbox_plugin_extensions"
	]
PLUGINS_CONFIG = {
	"netbox_config_plugin" : {
    default_settings = {"CONFIGJOB_AVAILABLE": 
      
       ,
                        "CONFIG_GENERATOR": 
       
        ,
                        "CONNECTION_OPTIONS": 
        
         }
	}
}

        
       
      

The parts with needs to be replaced with a python function. Details on what these functions habe to do can be found in the "Your own functions" section.

After that you can run the NetBox upgrade.sh script to regenerate the venv. If everything works you have to restart your netbox and netbox-rq services.

Your own functions

This Plugin relies on 3 pieces of code that you have to provide. You should be somewhat familiar with the NetBox python models to

CONFIGJOB_AVAILABLE

This function takes a NetBox device instance and returns True when this device should be configurable by this plugin.

To enable the functionallity for all devices you could just return True.

def configjob_available(device) -> bool:
    return True

But this can be restricted. E.g. to only be able to configure the device with the name foo you could use something like:

def configjob_available(device) -> bool:
    return device.name == "foo"

Matching on device types, tags, custom fields, and everything else the NetBox Django Models offer is also possible.

CONFIG_GENERATOR

This is a function that returns a ConfigGenerator object. This ConfigGenerator object has only one method called `generate_config:

# netbox_config_plugin/config_generators.py
class ConfigGenerator(ABC):

    @abstractmethod
    def generate(self, device) -> str:
        """
        Generates a Config for the given Device.
        """
        pass

you have to make a function that returns a subclass of that ConfigGenerator.


class DummyConfigGenerator(ConfigGenerator):

    def generate(self, device) -> str:
        # here goes the code that generates your config
		return "my fancy config"


def config_generator_wrapper(device):
    """
    Returns a ConfigGenerator Object for a Device.

    Raises a NoConfigGenerator Exception if no config generator is available
    for the Device.
    """

    return DummyConfigGenerator()

You could build multiple ConfigGenerator subclasses, e.g. one per vendor, platform, device type or device role, and depending on the device return the apropriate one.

CONNECTION_OPTIONS

This function has to return the driver name, and positional and keyword arguments for the NAPALM Driver. These are passed directly to the NAPALM Driver.

def get_connection_options(device) -> Tuple[str, List, Dict]:
    """
    This function takes the device and returns the required options for
    NAPALM to connect to that device

    The options are:
      - the driver to use (e.g. "ios" or "junos")
      - args and kwargs that are passed to the driver. These depend on the
        driver but usually are:
        - hostname
        - username
        - password
        - timeout (optional)
        - optional_args (optional)
    """
    driver_name = "ios"
    hostname = "2001:db8::42"
    username = "root"
    password = "supersecretpassword"
    args = [hostname, username, password]

    optional_args = {"secret": "supersecretsecret"}
    kwargs = {"optional_args": optional_args}

    return driver_name, args, kwargs

Details on the NAPALM Documentation has details on the Driver and the optional arguments

Job Handling and Job Queues

This plugin uses redis to send jobs to the netbox-rq workers. Currently all jobs are sent to the default queue so no changes should be required for a regular NetBox installation.

You might also like...
A small Python library which gives you the IEEE-754 representation of a floating point number.

ieee754 ieee754 is small Python library which gives you the IEEE-754 representation of a floating point number. You can specify a precision given in t

About A python based Apple Quicktime protocol,you can record audio and video from real iOS devices

介绍 本应用程序使用 python 实现,可以通过 USB 连接 iOS 设备进行屏幕共享 高帧率(30〜60fps) 高画质 低延迟(200ms) 非侵入性 支持多设备并行 Mac OSX 安装 python =3.7 brew install libusb pkg-config 如需使用 g

Capture screen and download off Roku based devices

rokuview Capture screen and download off Roku based devices Tested on Hisense TV with Roku OS built-in No guarantee this will work with all Roku model

Comics/doujinshi reader application. Web-based, will work on desktop and tablet devices with swipe interface.
Comics/doujinshi reader application. Web-based, will work on desktop and tablet devices with swipe interface.

Yomiko Comics/doujinshi reader application. Web-based, will work on desktop and tablet devices with swipe interface. Scans one or more directories of

Open source tools to allow working with ESP devices in the browser

ESP Web Tools Allow flashing ESPHome or other ESP-based firmwares via the browser. Will automatically detect the board type and select a supported fir

This python module allows to extract data from the RAW-file-format produces by devices from Thermo Fisher Scientific.

fisher_py This Python module allows access to Thermo Orbitrap raw mass spectrometer files. Using this library makes it possible to automate the analys

Junos PyEZ is a Python library to remotely manage/automate Junos devices.
Junos PyEZ is a Python library to remotely manage/automate Junos devices.

The repo is under active development. If you take a clone, you are getting the latest, and perhaps not entirely stable code. DOCUMENTATION Official Do

Simple control of Thorlabs Elliptec devices from Python.
Simple control of Thorlabs Elliptec devices from Python.

Elliptec Simple control of Thorlabs Elliptec devices. No docs yet » Get started · Report a bug · Request a feature About The Project ThorLabs Elliptec

A feed generator. Currently supports generating RSS feeds from Google, Bing, and Yahoo news.

A feed generator. Currently supports generating RSS feeds from Google, Bing, and Yahoo news.

Owner
Jo
Jo
Provide Prometheus url_sd compatible API Endpoint with data from Netbox

netbox-plugin-prometheus-sd Provide Prometheus http_sd compatible API Endpoint with data from Netbox. HTTP SD is a new feature in Prometheus and not a

Felix Peters 66 Dec 19, 2022
An electron application to check battery of bluetooth devices connected to linux devices.

bluetooth-battery-electron An electron application to check battery of bluetooth devices connected to linux devices. This project provides an electron

Vasu Sharma 15 Dec 3, 2022
Dotfiles for my configurations!

Dotfiles Repo Welcome! Over here, you can find my dotfiles for various applications, including QTile, Alacritty, Kitty, LunarVim, and more! Make sure

class PythonAddict 3 Jan 10, 2022
Developing and Comparing Vision-based Algorithms for Vision-based Agile Flight

DodgeDrone: Vision-based Agile Drone Flight (ICRA 2022 Competition) Would you like to push the boundaries of drone navigation? Then participate in the

Robotics and Perception Group 115 Dec 10, 2022
This tool helps you to reverse any regex and gives you the opposite/allowed Letters,numerics and symbols.

Regex-Reverser This tool helps you to reverse any regex and gives you the opposite/allowed Letters,numerics and symbols. Screenshots Usage/Examples py

x19 0 Jun 2, 2022
A toolkit for developing and deploying serverless Python code in AWS Lambda.

Python-lambda is a toolset for developing and deploying serverless Python code in AWS Lambda. A call for contributors With python-lambda and pytube bo

Nick Ficano 1.4k Jan 3, 2023
Stopmagic gives you the power of creating amazing Stop Motion animations faster and easier than ever before.

Stopmagic gives you the power of creating amazing Stop Motion animations faster and easier than ever before. This project is maintained by Aldrin Mathew.

Aldrin's Art Factory 67 Dec 31, 2022
Gives criticality score for an open source project

Open Source Project Criticality Score (Beta) This project is maintained by members of the Securing Critical Projects WG. Goals Generate a criticality

Open Source Security Foundation (OpenSSF) 1.1k Dec 23, 2022
Gives you more advanced math in python.

AdvancedPythonMath Gives you more advanced math in python. Functions .simplex(args: {number}) .circ(args: {raidus}) .pytha(args: {leg_a + leg_2}) .slo

Voidy Devleoper 1 Dec 25, 2021