1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00

28 lines
825 B
Python
Raw Normal View History

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
# Local
2021-09-13 14:10:32 -07:00
from ._base import DirectivePlugin, DeviceTypePlugin, HyperglassPlugin
2021-09-11 00:47:01 -07:00
if TYPE_CHECKING:
# Project
2021-09-13 02:37:05 -07:00
from hyperglass.models.data import OutputDataModel
from hyperglass.models.config.devices import Device
2021-09-16 15:57:33 -07:00
OutputType = Union["OutputDataModel", Series[str]]
2021-09-11 00:47:01 -07:00
2021-09-13 14:10:32 -07:00
class OutputPlugin(HyperglassPlugin, DirectivePlugin, DeviceTypePlugin):
"""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:
"""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