Skip to content

User Guide: Device drivers

SCadilhac edited this page Nov 12, 2021 · 2 revisions

Device drivers

Each supported type of device in Netshot rely on a single Javascript file, which is often called driver. This file describes the special attributes of the device type (e.g. running config and configuration register for a Cisco IOS device), and contains runnable code that will be executed when interacting with the device (e.g. taking a snapshot of the device).

Driver location

The Netshot package (especially the .jar file) contains several built-in drivers for some well known network device operating systems. These drivers are automatically loaded from the package without further action, which makes Netshot able to manage most of the router and switch devices out of the box.

Netshot also automatically loads drivers from the file system, which allows you to add your own driver files, by placing them in the directory defined in the Netshot configuration file by netshot.drivers.path.

If you want to make changes to an existing built-in driver, you can extract it from the .jar file, and copy it to the driver directory. The driver loaded from the file system has priority over the built-in driver.

The drivers can be dynamically reloaded while Netshot runs from the Admin page.

Driver structure

A driver is a Javascript file.

A driver must contain the following global objects:

  • Info: object describing the driver.
  • Device: object describing the specific attributes of this type of device.
  • Config: object describing the attributes of a configuration of a device of this type (an history of these attributes will be kept, as opposed to the device attributes).
  • CLI: object containing the logic to interact with the device's CLI, as a state machine.
  • snapshot(cli, device, config, debug): a function to be called each time a snapshot on a device of this type is started.
  • analyzeSyslog(message): function which will be automatically called whenever a Syslog message is received. The function must return true if it recognizes a configuration change notification for the type of device it supports.
  • analyzeTrap(trap): function which will be automatically called whenever a trap message is received (with the right community). The function must return true if it recognizes a configuration change notification for the specific type of device it supports.
  • snmpAutoDiscover(sysObjectID, sysDesc): function which will be called when a device is added to Netshot in autodiscovery mode. The driver will have to look at the sysObjectID and sysDesc and return true if it thinks it can support this device. If it returns true, Netshot will effectively add the device to the database, and assigns this driver to the device for future actions.