netbox icon indicating copy to clipboard operation
netbox copied to clipboard

Support for offline storage of modules

Open jeremystretch opened this issue 9 months ago • 6 comments

NetBox version

v4.2.6

Feature type

Data model extension

Proposed functionality

Add ForeignKeys to Site and Location on the Module model, replicating what exists today on the Device model. If the module is installed within a device, these values will be inherited from the parent device. If not installed within a device, the module can be assigned to a site and (optionally) a location designated for storage.

We should also add an explicit "storage" choice for the status fields on both Device and Module.

Use case

Introducing a relationship between a module and a site/location enables a module to exist outside the context of a parent device. Although modules generally are not considered operational on their own, this is useful for tracking modules for inventory purposes.

Database changes

  • Add site and location ForeignKeys on Module

External dependencies

N/A

jeremystretch avatar Mar 25 '25 14:03 jeremystretch

Unfortunately this is going to be more complicated than originally assumed. One of the reasons NetBox currently prohibits moving modules among devices is that the individual components belonging to a module may introduce blocking relationships. For example, interfaces belonging to a module are also assigned to a device; deinstalling the module requires severing that relationship. This is especially involved where those interfaces (or similar components) serve as cable termination points.

Another complicating factor is token-based component names. When a component template is added to a module type, its name can be tokenized to effect automatic naming according to the module bay in which it is installed. "Removing" a module requires reversing that renaming function, however no canonical backward path currently exists.

This is going to require substantially more planning and implementation work than I had hoped. Given that we're due to release the v4.3 beta in just two weeks, I'm going to bump it from that milestone.

jeremystretch avatar Mar 31 '25 17:03 jeremystretch

@jeremystretch should this be a replacement for the netbox-inventory plugin? Right now the communication when using the plugin is that an asset is something in inventory and it becomes a Device when in use. I fear some confusion for users of this plugin if a device or module can have the status "stored" as the line between Asset and Device seems to blur.

alehaa avatar Apr 15 '25 20:04 alehaa

I am a +1 for this as well. I have several spare disks/dimms ... etc that absolutely fit the definition of "module, to be installed in a module-bay" but turning a module-type into an actual module requires specifying a device which defeats the purpose of "module that will be installed in any one of $devices, as soon as $device shows hardware issues".

I didn't understand that the inventory plugin was distinct from the soon-to-be-removed "device inventory items" so I guess that's where i'll look in the mean time.

I fear some confusion for users of this plugin if a device or module can have the status "stored" as the line between Asset and Device seems to blur.

I'd argue that's already starting to happen :D. Even though the docs are clear:

A module is a field-replaceable hardware component installed within a device which...

I just assumed that a module could also be un-installed.

Unfortunately this is going to be more complicated than originally assumed. One of the reasons NetBox currently prohibits moving modules among devices is that the individual components belonging to a module may introduce blocking relationships.

You could avoid a lot of this complexity by having an intermediate type, no?

ModuleType can be "hydrated" to form a new/unique instance of Module. This is where you'd supply serial number and the profile / additional attributes. the Module type can then be converted to an InstalledModule type which then requires the additional device/bay ... etc. info.

stateDiagram-v2
    [*] --> ModuleType: define

    state ModuleType {
        [*] --> Defined
        Defined --> Module: instantiate\n(assign serial number)

        state Module {
            [*] --> Uninstalled
            Uninstalled --> InstalledModule: install\n(assign device, module-bay)
            InstalledModule --> Uninstalled: uninstall\n(remove device, module-bay)
        }
    }

kquinsland avatar Jun 22 '25 17:06 kquinsland

Related usecase/issue: https://github.com/netbox-community/netbox/issues/15289

kquinsland avatar Jun 22 '25 17:06 kquinsland

This is needed for us to move away from Inventory Items, since a module isn't deleted IRL just because it is removed from a Device's Module Bay. We have thousands of SFP's, SIM cards, and whatnot. They shouldn't be deleted just because they are detached from a slot.

TheFlyingCorpse avatar Nov 03 '25 19:11 TheFlyingCorpse