2021-09-11 00:47:01 -07:00
|
|
|
"""Device output plugins."""
|
|
|
|
|
|
|
|
# Standard Library
|
2021-09-16 15:57:33 -07:00
|
|
|
from typing import TYPE_CHECKING, Union
|
2021-09-11 00:47:01 -07:00
|
|
|
|
2021-09-13 02:37:05 -07:00
|
|
|
# Project
|
|
|
|
from hyperglass.log import log
|
2021-09-16 15:57:33 -07:00
|
|
|
from hyperglass.types import Series
|
2021-09-13 02:37:05 -07:00
|
|
|
|
2021-09-11 11:17:38 -07:00
|
|
|
# Local
|
2021-09-13 14:10:32 -07:00
|
|
|
from ._base import DirectivePlugin, DeviceTypePlugin, HyperglassPlugin
|
2021-09-11 00:47:01 -07:00
|
|
|
|
2021-09-11 17:55:27 -07:00
|
|
|
if TYPE_CHECKING:
|
|
|
|
# Project
|
2021-09-13 02:37:05 -07:00
|
|
|
from hyperglass.models.data import OutputDataModel
|
2021-09-11 17:55:27 -07:00
|
|
|
from hyperglass.models.config.devices import Device
|
2021-09-12 15:06:34 -07:00
|
|
|
|
2021-09-16 15:57:33 -07:00
|
|
|
OutputType = Union["OutputDataModel", Series[str]]
|
2021-09-11 17:55:27 -07:00
|
|
|
|
2021-09-11 00:47:01 -07:00
|
|
|
|
2021-09-13 14:10:32 -07:00
|
|
|
class OutputPlugin(HyperglassPlugin, DirectivePlugin, DeviceTypePlugin):
|
2021-09-11 11:17:38 -07:00
|
|
|
"""Plugin to interact with device command output."""
|
2021-09-11 00:47:01 -07:00
|
|
|
|
2021-09-13 02:37:05 -07:00
|
|
|
def process(self, output: OutputType, device: "Device") -> OutputType:
|
2021-09-12 15:06:34 -07:00
|
|
|
"""Process or manipulate output from a device."""
|
2021-09-13 02:37:05 -07:00
|
|
|
log.warning("Output plugin '{}' has not implemented a 'process()' method", self.name)
|
|
|
|
return output
|