iDebugAll / nextbox-ui-plugin

A topology visualization plugin for Netbox powered by NextUI Toolkit
MIT License
466 stars 59 forks source link

virtual-chassis support #48

Open amat3ur85 opened 3 years ago

amat3ur85 commented 3 years ago

It would be really useful if we can see device as virtual chassis master and connect them together, rather then individual stack members, if logical scheme is needed.

If we have core-sw1 with 2 physical cisco devices in stack we will import followtin objects into netbox:

In virtual chassis object, core-sw1 device object will be denoted as master with only virtual interfaces created on it. Individual members (core-sw1_1 and core-sw1_2) would have interfaces 1/0/1-48 and 2/0/1-48, respectively.

Logic could be something in line:

nb_devices = nb.dcim.devices.filter(site_id=site.id)

masters_checked = []
for device in nb_devices:
    if device.virtual_chassis:
        vc = nb.dcim.virtual_chassis.get(device.virtual_chassis.id)
        if vc.master.name not in masters_imported:
            masters_checked.append(vc.master.name)
            device_for_connection = nb.dcim.devices.get(vc.master.id)
     else:
         # as usual :)

Afterwards all interfaces will be present on device_for_connection. We just need to keep track of already connected device, so we don't check twice for all stack members.

virtual_chassis

amat3ur85 commented 3 years ago

One more note: Since many users prepared scripts and are using plugin as is, maybe it would be good to add one more button on top to select "group with virtual chassis" if grouping is wanted or if that is not selected to work as is.