nav
nav copied to clipboard
Post event when new device entries are created (first time seen)
From the docs, https://nav.readthedocs.io/en/latest/reference/alerttypes.html, it isn't exactly clear that there is a precise distinction between deviceActive
events and deviceState
events.
Some light digging into the revision history seems to suggest both deviceActive
and deviceState
events were only ever posted by the by the ancient device management tool when devices were manually entered into the inventory. This tool no longer exists in NAV.
Only the deviceState
event has any existing alert types attached to it. This seems to suggest we should use deviceState
events to signal lifecycle events that were detected by the collection engine, and leave 'deviceActive' events alone for the time being.
Current data model
The Device
model is used to register (mainly) physical devices, identified by serial number. Various other models in NAV will have a relation to Device
. Most commonly, NetboxEntity
, Module
or PowerSupplyOrFan
will relate to Device.
The oldest model still in use here is Module
, which is used to register module entities in devices. A newer model is NetboxEntity
, which tries to model the entire ENTITY-MIB::entPhysicalTable
structure in the SQL database. A Netbox
consists of multiple entities, and some of these are physical devices, so NetboxEntity
has an optional relation to Device
.
https://github.com/Uninett/nav/blob/70dec3cd8393d1a67340db0d959365463f8bbef0/python/nav/models/manage.py#L817-L828
What to post, and when
When new Device
instance is registered, usually, some other model is also registered, which relates to this. We might want to post different types of deviceState
alerts, depending on what type of Device
is being created.
Knowing whether a Device
began serving as a chassis, a module, a power supply or a fan in a Netbox is useful, and the event should differentiate between these things.
The model already has the alert deviceInIPOperation
- this might be obsolete, since the data model no longer relates a Netbox directly to a device. This is more or less the same as a device starting to serve as a chassis in a Netbox. A single switch is a Netbox with a single chassis entity. A switch stack is a Netbox with multiple chassis entities.
All of these entries are created by ipdevpoll upon discovery, so the ipdevpoll framework should be the one to actually post the appropriate events.