forked from mirrors/thatmattlove-hyperglass
clean up data models [skip ci]
This commit is contained in:
parent
add0a1af48
commit
59e767e501
10 changed files with 19 additions and 13 deletions
|
|
@ -1,7 +1,7 @@
|
|||
"""Base Connection Class."""
|
||||
|
||||
# Standard Library
|
||||
from typing import Iterable
|
||||
from typing import Dict, Union, Sequence
|
||||
|
||||
# Project
|
||||
from hyperglass.log import log
|
||||
|
|
@ -27,8 +27,8 @@ class Connection:
|
|||
self.query = self._query.queries()
|
||||
|
||||
async def parsed_response( # noqa: C901 ("too complex")
|
||||
self, output: Iterable
|
||||
) -> str:
|
||||
self, output: Sequence[str]
|
||||
) -> Union[str, Sequence[Dict]]:
|
||||
"""Send output through common parsers."""
|
||||
|
||||
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
|
||||
import signal
|
||||
from typing import Any, Dict, Union, Callable
|
||||
from typing import Any, Dict, Union, Callable, Sequence
|
||||
|
||||
# Project
|
||||
from hyperglass.log import log
|
||||
|
|
@ -36,7 +36,7 @@ def handle_timeout(**exc_args: Any) -> Callable:
|
|||
return handler
|
||||
|
||||
|
||||
async def execute(query: Query) -> Union[str, Dict]:
|
||||
async def execute(query: Query) -> Union[str, Sequence[Dict]]:
|
||||
"""Initiate query validation and execution."""
|
||||
|
||||
output = params.messages.general
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ from typing import Union
|
|||
# Third Party
|
||||
from pydantic import BaseModel, StrictStr
|
||||
|
||||
# Project
|
||||
from hyperglass.models.fields import StrictBytes
|
||||
# Local
|
||||
from ..fields import StrictBytes
|
||||
|
||||
|
||||
class EncodedRequest(BaseModel):
|
||||
|
|
|
|||
|
|
@ -9,8 +9,10 @@ from pydantic import StrictInt, StrictStr, StrictBool, constr, root_validator
|
|||
|
||||
# Project
|
||||
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)")
|
||||
|
||||
|
|
@ -8,8 +8,10 @@ from pydantic import StrictInt, StrictStr, StrictBool, validator, root_validator
|
|||
|
||||
# Project
|
||||
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 = {
|
||||
"invalid": 0,
|
||||
|
|
@ -8,10 +8,12 @@ from typing import List
|
|||
from pydantic import StrictInt, StrictStr, StrictBool, constr, validator
|
||||
|
||||
# Project
|
||||
from hyperglass.models import HyperglassModel
|
||||
from hyperglass.configuration import params
|
||||
from hyperglass.external.rpki import rpki_state
|
||||
|
||||
# Local
|
||||
from ..main import HyperglassModel
|
||||
|
||||
WinningWeight = constr(regex=r"(low|high)")
|
||||
|
||||
|
||||
|
|
@ -11,7 +11,7 @@ from pydantic import ValidationError
|
|||
from hyperglass.log import log
|
||||
from hyperglass.exceptions import ParsingError, ResponseEmpty
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue