exp

package
v0.0.0-...-5607193 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2021 License: GPL-3.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoName       = errors.New("plugin metadata does not specify the required 'Name' field")
	ErrNoMaintainer = errors.New("plugin metadata does not specify the required 'Maintainer' field")
)

Errors for base plugin setup/creation.

Functions

func NewSnmpBasePlugin

func NewSnmpBasePlugin(metadata *PluginMetadata) (*sdk.Plugin, error)

NewSnmpBasePlugin creates a new SNMP base plugin.

This base plugin can be used by other plugin implementations to inherit generic SNMP handling. Plugin implementations need only provide plugin metadata for the "subclassed" plugin and info mapping MIB devices to Synse devices.

func SnmpDeviceIdentifier

func SnmpDeviceIdentifier(data map[string]interface{}) string

SnmpDeviceIdentifier is the device identifier function used by the SDK in order to generate unique device IDs for the registered Synse devices.

This function is defined for the base SNMP plugin and is subsequently used by all plugins which use the base.

The expectation is that each device should be uniquely identifiable using a combination of the SNMP device's OID and MIB name. As such, those fields are expected in the device Data. If they are not present, the plugin will panic and terminate.

Additionally, since there may be multiple SNMP-enabled servers configured which use the same MIB, the id generation needs to take the configured host/port into account.

Generally, it is not the responsibility of the plugin writer to ensure that info exists per device because the SNMP base plugin provides utility functions which automatically fill this information in when building Synse devices.

func SnmpDeviceRegistrar

func SnmpDeviceRegistrar(data map[string]interface{}) ([]*sdk.Device, error)

SnmpDeviceRegistrar is the dynamic registration function used by the SDK to build devices at runtime.

This function is defined for the base SNMP plugin and is subsequently used by all plugins which use the base.

It loads all devices for the specified MIB and caches the SNMP configuration for each device. This allows each device to create a new client on demand using this pre-loaded configuration.

Types

type PluginMetadata

type PluginMetadata struct {
	Name        string
	Maintainer  string
	Description string
	VCS         string
}

PluginMetadata holds metadata for the plugin instance. It is used to provide identity to the plugin as well as some high level information about it and its source.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL