mirror of
https://github.com/checktheroads/hyperglass
synced 2024-05-11 05:55:08 +00:00
clean up data models [skip ci]
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
"""Base Connection Class."""
|
"""Base Connection Class."""
|
||||||
|
|
||||||
# Standard Library
|
# Standard Library
|
||||||
from typing import Iterable
|
from typing import Dict, Union, Sequence
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.log import log
|
from hyperglass.log import log
|
||||||
@@ -27,8 +27,8 @@ class Connection:
|
|||||||
self.query = self._query.queries()
|
self.query = self._query.queries()
|
||||||
|
|
||||||
async def parsed_response( # noqa: C901 ("too complex")
|
async def parsed_response( # noqa: C901 ("too complex")
|
||||||
self, output: Iterable
|
self, output: Sequence[str]
|
||||||
) -> str:
|
) -> Union[str, Sequence[Dict]]:
|
||||||
"""Send output through common parsers."""
|
"""Send output through common parsers."""
|
||||||
|
|
||||||
log.debug("Pre-parsed responses:\n{}", output)
|
log.debug("Pre-parsed responses:\n{}", output)
|
||||||
|
@@ -8,7 +8,7 @@ hyperglass-frr API calls, returns the output back to the front end.
|
|||||||
|
|
||||||
# Standard Library
|
# Standard Library
|
||||||
import signal
|
import signal
|
||||||
from typing import Any, Dict, Union, Callable
|
from typing import Any, Dict, Union, Callable, Sequence
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.log import log
|
from hyperglass.log import log
|
||||||
@@ -36,7 +36,7 @@ def handle_timeout(**exc_args: Any) -> Callable:
|
|||||||
return handler
|
return handler
|
||||||
|
|
||||||
|
|
||||||
async def execute(query: Query) -> Union[str, Dict]:
|
async def execute(query: Query) -> Union[str, Sequence[Dict]]:
|
||||||
"""Initiate query validation and execution."""
|
"""Initiate query validation and execution."""
|
||||||
|
|
||||||
output = params.messages.general
|
output = params.messages.general
|
||||||
|
@@ -5,8 +5,8 @@ from typing import Union
|
|||||||
# Third Party
|
# Third Party
|
||||||
from pydantic import BaseModel, StrictStr
|
from pydantic import BaseModel, StrictStr
|
||||||
|
|
||||||
# Project
|
# Local
|
||||||
from hyperglass.models.fields import StrictBytes
|
from ..fields import StrictBytes
|
||||||
|
|
||||||
|
|
||||||
class EncodedRequest(BaseModel):
|
class EncodedRequest(BaseModel):
|
||||||
|
@@ -9,8 +9,10 @@ from pydantic import StrictInt, StrictStr, StrictBool, constr, root_validator
|
|||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.log import log
|
from hyperglass.log import log
|
||||||
from hyperglass.models import HyperglassModel
|
|
||||||
from hyperglass.parsing.models.serialized import ParsedRoutes
|
# Local
|
||||||
|
from ..main import HyperglassModel
|
||||||
|
from .serialized import ParsedRoutes
|
||||||
|
|
||||||
FRRPeerType = constr(regex=r"(internal|external)")
|
FRRPeerType = constr(regex=r"(internal|external)")
|
||||||
|
|
@@ -8,8 +8,10 @@ from pydantic import StrictInt, StrictStr, StrictBool, validator, root_validator
|
|||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.log import log
|
from hyperglass.log import log
|
||||||
from hyperglass.models import HyperglassModel
|
|
||||||
from hyperglass.parsing.models.serialized import ParsedRoutes
|
# Local
|
||||||
|
from ..main import HyperglassModel
|
||||||
|
from .serialized import ParsedRoutes
|
||||||
|
|
||||||
RPKI_STATE_MAP = {
|
RPKI_STATE_MAP = {
|
||||||
"invalid": 0,
|
"invalid": 0,
|
@@ -8,10 +8,12 @@ from typing import List
|
|||||||
from pydantic import StrictInt, StrictStr, StrictBool, constr, validator
|
from pydantic import StrictInt, StrictStr, StrictBool, constr, validator
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.models import HyperglassModel
|
|
||||||
from hyperglass.configuration import params
|
from hyperglass.configuration import params
|
||||||
from hyperglass.external.rpki import rpki_state
|
from hyperglass.external.rpki import rpki_state
|
||||||
|
|
||||||
|
# Local
|
||||||
|
from ..main import HyperglassModel
|
||||||
|
|
||||||
WinningWeight = constr(regex=r"(low|high)")
|
WinningWeight = constr(regex=r"(low|high)")
|
||||||
|
|
||||||
|
|
@@ -11,7 +11,7 @@ from pydantic import ValidationError
|
|||||||
from hyperglass.log import log
|
from hyperglass.log import log
|
||||||
from hyperglass.exceptions import ParsingError, ResponseEmpty
|
from hyperglass.exceptions import ParsingError, ResponseEmpty
|
||||||
from hyperglass.configuration import params
|
from hyperglass.configuration import params
|
||||||
from hyperglass.parsing.models.juniper import JuniperRoute
|
from hyperglass.models.parsing.juniper import JuniperRoute
|
||||||
|
|
||||||
|
|
||||||
def parse_juniper(output: Iterable) -> Dict: # noqa: C901
|
def parse_juniper(output: Iterable) -> Dict: # noqa: C901
|
||||||
|
Reference in New Issue
Block a user