diff --git a/hyperglass/plugins/__init__.py b/hyperglass/plugins/__init__.py index 496cef8..1ca2d24 100644 --- a/hyperglass/plugins/__init__.py +++ b/hyperglass/plugins/__init__.py @@ -2,15 +2,17 @@ # Local from .main import init_plugins, register_plugin -from ._input import InputPlugin -from ._output import OutputPlugin +from ._input import InputPlugin, InputPluginReturn +from ._output import OutputType, OutputPlugin from ._manager import InputPluginManager, OutputPluginManager __all__ = ( "init_plugins", "InputPlugin", "InputPluginManager", + "InputPluginReturn", "OutputPlugin", "OutputPluginManager", + "OutputType", "register_plugin", ) diff --git a/hyperglass/plugins/_builtin/__init__.py b/hyperglass/plugins/_builtin/__init__.py index bcf6666..fc2da4f 100644 --- a/hyperglass/plugins/_builtin/__init__.py +++ b/hyperglass/plugins/_builtin/__init__.py @@ -2,5 +2,9 @@ # Local from .remove_command import RemoveCommand +from .bgp_route_juniper import BGPRoutePluginJuniper -__all__ = ("RemoveCommand",) +__all__ = ( + "RemoveCommand", + "BGPRoutePluginJuniper", +) diff --git a/hyperglass/plugins/_manager.py b/hyperglass/plugins/_manager.py index f2a7c5d..9c7e6df 100644 --- a/hyperglass/plugins/_manager.py +++ b/hyperglass/plugins/_manager.py @@ -16,7 +16,7 @@ from hyperglass.exceptions.private import PluginError # Local from ._base import PluginType, HyperglassPlugin from ._input import InputPlugin, InputPluginReturn -from ._output import OutputPlugin, OutputPluginReturn +from ._output import OutputType, OutputPlugin if TYPE_CHECKING: # Project @@ -168,8 +168,8 @@ class OutputPluginManager(PluginManager[OutputPlugin], type="output"): """Manage Output Processing Plugins.""" def execute( - self: "OutputPluginManager", *, directive: "Directive", output: str, device: "Device" - ) -> OutputPluginReturn: + self: "OutputPluginManager", *, directive: "Directive", output: OutputType, device: "Device" + ) -> OutputType: """Execute all output parsing plugins. The result of each plugin is passed to the next plugin. diff --git a/hyperglass/plugins/_output.py b/hyperglass/plugins/_output.py index 7e0f219..8962b14 100644 --- a/hyperglass/plugins/_output.py +++ b/hyperglass/plugins/_output.py @@ -3,22 +3,24 @@ # Standard Library from typing import TYPE_CHECKING, Union, Sequence +# Project +from hyperglass.log import log + # Local from ._base import DirectivePlugin if TYPE_CHECKING: # Project + from hyperglass.models.data import OutputDataModel from hyperglass.models.config.devices import Device - from hyperglass.models.parsing.serialized import ParsedRoutes -OutputPluginReturn = Union[None, "ParsedRoutes", str] +OutputType = Union["OutputDataModel", Sequence[str]] class OutputPlugin(DirectivePlugin): """Plugin to interact with device command output.""" - directive_ids: Sequence[str] = () - - def process(self, output: Union["ParsedRoutes", str], device: "Device") -> OutputPluginReturn: + def process(self, output: OutputType, device: "Device") -> OutputType: """Process or manipulate output from a device.""" - return None + log.warning("Output plugin '{}' has not implemented a 'process()' method", self.name) + return output