Skip to main content

Manage Multi-Chassis Link Aggregation Groups in Netbox (MC-LAG / MLAG / vPC / etc)

Project description

netbox-multichassis-lag

(This is a current, Netbox 4.5, fork of https://github.com/derek-shnosh/netbox-plugin-mclag)

Description

This is a NetBox Plugin to manage MC-LAG (Multi-Chassis Link Aggregation Groups).

MC-LAG is a generic name for vendor-specific technologies allowing multiple switches to form a common LAG with a remote system. In the interest of discoverability, here is a list of various vendor-specific names for MC-LAG technologies.

  • CLAG
  • Distributed Resilient Network Interconnect
  • Distributed Split Multi-Link Trunking
  • Distributed Trunking
  • MC-LAG
  • mLACP (Multichassis Link Aggregation Control Protocol)
  • MLAG
  • M-LAG
  • Multichassis Etherchannel (MEC)
  • Multi-Chassis Trunking
  • Split multi-link trunking
  • StackWise Virtual
  • Virtual Link Trunking
  • Virtual Port Channel (vPC)
  • vLAG

The plugin itself aims be vendor-neutral, and to use vendor-neutral terminology, and to fit most common MC-LAG implementations. Cisco Nexus Virtual Port Channel (vPC) is used as a sample implementation in examples.

Data model

This plugin creates two new data models, a Multi-Chassis Domain and an Multi-Chassis Link Aggregation Group.

A Multi-Chassis Domain groups two or more devices that participate in creating a Multi-Chassis Link Aggregation Group. Optionally, a Domain ID may be added here to hold any vendor-specific ID required for configuration of the domain.

A Multi-Chassis Link Aggregation Group groups two or more LAG interfaces on domain member devices. Optionally, a Group ID may be added here to hold any vendor-specific ID required for configuration of the group.

To clarify, each switch in the Multi-Chassis Domain will need a regular NetBox LAG interface created, typically just with a single physical interface associated with it. These LAGs are then grouped together by the data models described above.

Here is an example configuration of an MC-LAG setup containing two peer devices, each with one physical participating in a single LAG, using Cisco Nexus vPC terminology.

  • A Multi-Chassis Domain named My VPC Domain, with Domain ID set to 100. This corresponds to the Cisco vPC Domain ID.
  • A Multi-Chassis Link Aggregation Group named My VPC Group, with Group ID set to 200. This corresponds to the Cisco VPC number assigned to the virtual port channel.
  • On each member device Switch1 and Switch2
    • A LAG interface named Po200, representing the local port channel configuration.
    • A physical interface named Te1/0/1 which is a member of the Po200 LAG.

If more configuration fields beyond an ID are required on the Multi-Chassis Domain or Multi-Chassis Link Aggregation Group objects, they may be added as custom fields by the user.

Functionality

The following functionality is currently offered by this plugin:

  • The ability to view/create/update/delete Multi-Chassis Domain objects through the web UI and by API.
  • The ability to view/create/update/delete Multi-Chassis Link Aggregation Group objects through the web UI and by API.
  • Button added to Device view to "Show MC Domain" if a device is associated with an MC Domain
  • Button added to Interface view to "Show MC-LAG" if an interface is associated with an MC-LAG

Configuration template example

The following example proof-of-concept template demonstrates that the model contains the required richness to model Cisco VPC. It's incomplete and will require some improvement before it can actually be used for anything:

{% if device.mc_domains.count() == 1 %}
feature vpc
vpc domain {{ device.mc_domains.get().domain_id }}
  peer-keepalive destination 10.1.1.20 source 10.1.1.10 vrf VPC-KEEPALIVE ### TODO Actually populate IP addresses and VRF names here ###
exit

interface port-channel 1 ### TODO actually figure out correct interface ###
  vpc peer-link
exit
{% endif %}

{%- for interface in device.interfaces.filter(type='lag') %}
{%-   if interface.mc_lags.count() == 1 %}
interface {{ interface.name }}
  vpc {{ interface.mc_lags.get().lag_id }}
exit
{%-   endif %}
{%- endfor %}
{%  for interface in device.interfaces.filter(lag__isnull=False) %}
interface {{ interface.name }}
  channel-group {{ interface.lag.name|replace("Po","") }} mode active
exit
{%  endfor %}

Supported versions

This version of the netbox-multichassis-lag plugin has added compatibility for NetBox 4.5 and should have backwards compatibility down to NetBox 4.2. It is not supported on older versions.

The plugin has been developed for Python 3.12.3, but I expect it to work with any Python version supported by Netbox.

Installation

source /opt/netbox/venv/bin/activate

python3 -m pip install netbox-multichassis-lag

This will install the plugin for you inside of Netbox's virtual environment (venv).

You then need to edit your Netbox configuration file (/opt/netbox/netbox/netbox/configuration.py) to add the plugin to your Netbox configuration adding netbox-multichassis-lag to the PLUGINS list as per this example below:

PLUGINS = [
  'netbox-multichassis-lag',
]

Finally, you'll need to execute a database migration to extend the database with the required schema to support this plugin. You will need to navigate to the netbox subdirectory of your Netbox install directory (e.g. /opt/netbox/netbox and then execute a database migration:

python3 manage.py migrate

Finally, you will then need to restart your Netbox instance.

systemctl restart netbox netbox-rq

Configuration (optional)

By default, the MC-LAG plugin will live under the Plugins menu. If you'd prefer it to have its own menu, you can do that by setting the PLUGIN_OPTIONS in your Netbox configuration file (e.g. /opt/netbox/netbox/netbox/configuration.py) like this:

PLUGINS_CONFIG = {
    'netbox-multichassis-lag': {
        'top_level_menu': True
    }
}

Uninstallation

If you decide the plugin isn't for you and you want to remove it, this is how.

Reverting the database migrations (optional)

If you intend to uninstall netbox-multichassis-lag, you may want to revert the database migrations that this plugin adds. Note: Reverting these migrations will remove any data associated with the plugin. This has to be done before uninstalling the plugin.

Removing the data is not strictly neccessary, but there have been bugs in Netbox in the past that have broken features if data from uninstalled plugins remains in the database, so it might be a good idea to do it.

Manually editing the postgresql database is not recommended, because it may leave migrations out of sync with the actual schema, so instead, to remove the data, the best way is to roll back the migration. This has to be done prior to uninstalling the plugin!

Because this command has the potential for data loss, I strongly recommend you backup the database before running these steps.

First, activate the Netbox virtual environment:

source /opt/netbox/venv/bin/activate (substituting the correct path for your install)

Then, revert the migrations for netbox_plugin_mclag:

python /opt/netbox/netbox/manage.py migrate netbox-multichassis-lag zero (again, substituting the correct path for your install)

Disabling the plugin in the Netbox configuration

Edit your Netbox configuration file (e.g. /opt/netbox/netbox/netbox/configuration.py) to remove netbox-multichassis-lag from the PLUGINS list.

After this, you can restart Netbox to make sure the plugin is no longer loaded.

systemctl restart netbox netbox-rq

Removing the plugin (optional)

Activate your Netbox virtual environment:

source /opt/netbox/venv/bin/activate (substituting the correct path for your install)

Use pip to uninstall the plugin.

pip uninstall netbox-multichassis-lag

Dev Guide: Creating and pushing the package

python3 -m venv .venv
. .venv/bin/activate
pip install -r dev-requirements.txt
python3 -m build
python3 -m twine upload dist/*

Acknowledgements and references

The following materials were instrumental in developing this plugin:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

netbox_multichassis_lag-0.3.1.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

netbox_multichassis_lag-0.3.1-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file netbox_multichassis_lag-0.3.1.tar.gz.

File metadata

  • Download URL: netbox_multichassis_lag-0.3.1.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for netbox_multichassis_lag-0.3.1.tar.gz
Algorithm Hash digest
SHA256 498f854477475c18b20ee42ddbbaaa8e8c932bf7c09811855c5c6bae1ec50d20
MD5 2c51b34f48d86c65fa01e34d259b61b8
BLAKE2b-256 ac2a85a18a38aafc825afe611bc102cd53bcd5cf58e58fe5da8b9a2f8d029afb

See more details on using hashes here.

File details

Details for the file netbox_multichassis_lag-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for netbox_multichassis_lag-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8b0663b4d6c64844ffc8330458dd3e01f16db0005e2c81cd1588daa40bde4623
MD5 a8f1935d0fa0cc09c6e17aaca437542f
BLAKE2b-256 940a9110d1d6e092cb8cf6420ede6dd8cfedc35aa5ea575eac22772bdd55b6cd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page