forked from mirrors/thatmattlove-hyperglass
fix import sorting
This commit is contained in:
parent
74827c02b9
commit
a8476f2ea9
44 changed files with 68 additions and 76 deletions
|
|
@ -1,12 +1,11 @@
|
||||||
"""API Error Handlers."""
|
"""API Error Handlers."""
|
||||||
|
|
||||||
from hyperglass.log import log
|
|
||||||
|
|
||||||
# Third Party
|
# Third Party
|
||||||
from fastapi import Request
|
from fastapi import Request
|
||||||
from starlette.responses import JSONResponse
|
from starlette.responses import JSONResponse
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
|
from hyperglass.log import log
|
||||||
from hyperglass.state import use_state
|
from hyperglass.state import use_state
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ def build_ui(timeout: int) -> None:
|
||||||
"""Create a new UI build."""
|
"""Create a new UI build."""
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.state import use_state
|
from hyperglass.state import use_state
|
||||||
from hyperglass.configuration import init_user_config
|
|
||||||
from hyperglass.frontend import build_frontend
|
from hyperglass.frontend import build_frontend
|
||||||
|
from hyperglass.configuration import init_user_config
|
||||||
|
|
||||||
# Populate configuration to Redis prior to accessing it.
|
# Populate configuration to Redis prior to accessing it.
|
||||||
init_user_config()
|
init_user_config()
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.models.directive import (
|
from hyperglass.models.directive import (
|
||||||
BuiltinDirective,
|
Text,
|
||||||
RuleWithIPv4,
|
RuleWithIPv4,
|
||||||
RuleWithIPv6,
|
RuleWithIPv6,
|
||||||
RuleWithPattern,
|
RuleWithPattern,
|
||||||
Text,
|
BuiltinDirective,
|
||||||
)
|
)
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.models.directive import (
|
from hyperglass.models.directive import (
|
||||||
|
Text,
|
||||||
RuleWithIPv4,
|
RuleWithIPv4,
|
||||||
RuleWithIPv6,
|
RuleWithIPv6,
|
||||||
RuleWithPattern,
|
RuleWithPattern,
|
||||||
Text,
|
|
||||||
BuiltinDirective,
|
BuiltinDirective,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.models.directive import (
|
from hyperglass.models.directive import (
|
||||||
|
Text,
|
||||||
RuleWithIPv4,
|
RuleWithIPv4,
|
||||||
RuleWithIPv6,
|
RuleWithIPv6,
|
||||||
RuleWithPattern,
|
RuleWithPattern,
|
||||||
Text,
|
|
||||||
BuiltinDirective,
|
BuiltinDirective,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.models.directive import (
|
from hyperglass.models.directive import (
|
||||||
|
Text,
|
||||||
RuleWithIPv4,
|
RuleWithIPv4,
|
||||||
RuleWithIPv6,
|
RuleWithIPv6,
|
||||||
RuleWithPattern,
|
RuleWithPattern,
|
||||||
Text,
|
|
||||||
BuiltinDirective,
|
BuiltinDirective,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.models.directive import (
|
from hyperglass.models.directive import (
|
||||||
|
Text,
|
||||||
RuleWithIPv4,
|
RuleWithIPv4,
|
||||||
RuleWithIPv6,
|
RuleWithIPv6,
|
||||||
RuleWithPattern,
|
RuleWithPattern,
|
||||||
Text,
|
|
||||||
BuiltinDirective,
|
BuiltinDirective,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.models.directive import (
|
from hyperglass.models.directive import (
|
||||||
|
Text,
|
||||||
RuleWithIPv4,
|
RuleWithIPv4,
|
||||||
RuleWithIPv6,
|
RuleWithIPv6,
|
||||||
RuleWithPattern,
|
RuleWithPattern,
|
||||||
Text,
|
|
||||||
BuiltinDirective,
|
BuiltinDirective,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.models.directive import (
|
from hyperglass.models.directive import (
|
||||||
|
Text,
|
||||||
RuleWithIPv4,
|
RuleWithIPv4,
|
||||||
RuleWithIPv6,
|
RuleWithIPv6,
|
||||||
RuleWithPattern,
|
RuleWithPattern,
|
||||||
Text,
|
|
||||||
BuiltinDirective,
|
BuiltinDirective,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.models.directive import (
|
from hyperglass.models.directive import (
|
||||||
|
Text,
|
||||||
RuleWithIPv4,
|
RuleWithIPv4,
|
||||||
RuleWithIPv6,
|
RuleWithIPv6,
|
||||||
RuleWithPattern,
|
RuleWithPattern,
|
||||||
Text,
|
|
||||||
BuiltinDirective,
|
BuiltinDirective,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.models.directive import (
|
from hyperglass.models.directive import (
|
||||||
|
Text,
|
||||||
RuleWithIPv4,
|
RuleWithIPv4,
|
||||||
RuleWithIPv6,
|
RuleWithIPv6,
|
||||||
RuleWithPattern,
|
RuleWithPattern,
|
||||||
Text,
|
|
||||||
BuiltinDirective,
|
BuiltinDirective,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.models.directive import (
|
from hyperglass.models.directive import (
|
||||||
|
Text,
|
||||||
RuleWithIPv4,
|
RuleWithIPv4,
|
||||||
RuleWithIPv6,
|
RuleWithIPv6,
|
||||||
RuleWithPattern,
|
RuleWithPattern,
|
||||||
Text,
|
|
||||||
BuiltinDirective,
|
BuiltinDirective,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.models.directive import (
|
from hyperglass.models.directive import (
|
||||||
|
Text,
|
||||||
RuleWithIPv4,
|
RuleWithIPv4,
|
||||||
RuleWithIPv6,
|
RuleWithIPv6,
|
||||||
RuleWithPattern,
|
RuleWithPattern,
|
||||||
Text,
|
|
||||||
BuiltinDirective,
|
BuiltinDirective,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.models.directive import (
|
from hyperglass.models.directive import (
|
||||||
|
Text,
|
||||||
RuleWithIPv4,
|
RuleWithIPv4,
|
||||||
RuleWithIPv6,
|
RuleWithIPv6,
|
||||||
RuleWithPattern,
|
RuleWithPattern,
|
||||||
Text,
|
|
||||||
BuiltinDirective,
|
BuiltinDirective,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.models.directive import (
|
from hyperglass.models.directive import (
|
||||||
|
Text,
|
||||||
RuleWithIPv4,
|
RuleWithIPv4,
|
||||||
RuleWithIPv6,
|
RuleWithIPv6,
|
||||||
RuleWithPattern,
|
RuleWithPattern,
|
||||||
Text,
|
|
||||||
BuiltinDirective,
|
BuiltinDirective,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,7 @@ class PublicHyperglassError(HyperglassError):
|
||||||
|
|
||||||
def __init__(self, **kwargs: str) -> None:
|
def __init__(self, **kwargs: str) -> None:
|
||||||
"""Format error message with keyword arguments."""
|
"""Format error message with keyword arguments."""
|
||||||
|
# Project
|
||||||
from hyperglass.state import use_state
|
from hyperglass.state import use_state
|
||||||
|
|
||||||
if "error" in kwargs:
|
if "error" in kwargs:
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
# Standard Library
|
# Standard Library
|
||||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||||
|
|
||||||
|
|
||||||
# Local
|
# Local
|
||||||
from ._common import PublicHyperglassError
|
from ._common import PublicHyperglassError
|
||||||
|
|
||||||
|
|
@ -82,6 +81,7 @@ class QueryLocationNotFound(NotFound):
|
||||||
|
|
||||||
def __init__(self, location: Any, **kwargs: Dict[str, Any]) -> None:
|
def __init__(self, location: Any, **kwargs: Dict[str, Any]) -> None:
|
||||||
"""Initialize a NotFound error for a query location."""
|
"""Initialize a NotFound error for a query location."""
|
||||||
|
# Project
|
||||||
from hyperglass.state import use_state
|
from hyperglass.state import use_state
|
||||||
|
|
||||||
(text := use_state("params").web.text)
|
(text := use_state("params").web.text)
|
||||||
|
|
@ -94,6 +94,7 @@ class QueryTypeNotFound(NotFound):
|
||||||
|
|
||||||
def __init__(self, query_type: Any, **kwargs: Dict[str, Any]) -> None:
|
def __init__(self, query_type: Any, **kwargs: Dict[str, Any]) -> None:
|
||||||
"""Initialize a NotFound error for a query type."""
|
"""Initialize a NotFound error for a query type."""
|
||||||
|
# Project
|
||||||
from hyperglass.state import use_state
|
from hyperglass.state import use_state
|
||||||
|
|
||||||
(text := use_state("params").web.text)
|
(text := use_state("params").web.text)
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,22 @@
|
||||||
# Project
|
# Standard Library
|
||||||
import typing as t
|
import typing as t
|
||||||
|
|
||||||
|
# Third Party
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
# Project
|
||||||
|
from hyperglass.state import use_state
|
||||||
from hyperglass.models.api import Query
|
from hyperglass.models.api import Query
|
||||||
from hyperglass.configuration import init_ui_params
|
from hyperglass.configuration import init_ui_params
|
||||||
from hyperglass.models.config.params import Params
|
|
||||||
from hyperglass.models.directive import Directives
|
from hyperglass.models.directive import Directives
|
||||||
|
from hyperglass.models.config.params import Params
|
||||||
from hyperglass.models.config.devices import Devices
|
from hyperglass.models.config.devices import Devices
|
||||||
from hyperglass.state import use_state
|
|
||||||
|
|
||||||
# Local
|
# Local
|
||||||
from .._construct import Construct
|
from .._construct import Construct
|
||||||
|
|
||||||
if t.TYPE_CHECKING:
|
if t.TYPE_CHECKING:
|
||||||
|
# Project
|
||||||
from hyperglass.state import HyperglassState
|
from hyperglass.state import HyperglassState
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ from hyperglass.log import log
|
||||||
from hyperglass.util import copyfiles, check_path, dotenv_to_dict
|
from hyperglass.util import copyfiles, check_path, dotenv_to_dict
|
||||||
from hyperglass.state import use_state
|
from hyperglass.state import use_state
|
||||||
|
|
||||||
|
|
||||||
if t.TYPE_CHECKING:
|
if t.TYPE_CHECKING:
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.models.ui import UIParameters
|
from hyperglass.models.ui import UIParameters
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,6 @@ from .util import cpu_count
|
||||||
from .state import use_state
|
from .state import use_state
|
||||||
from .settings import Settings
|
from .settings import Settings
|
||||||
|
|
||||||
|
|
||||||
log_level = "INFO" if Settings.debug is False else "DEBUG"
|
log_level = "INFO" if Settings.debug is False else "DEBUG"
|
||||||
|
|
||||||
setup_lib_logging(log_level)
|
setup_lib_logging(log_level)
|
||||||
|
|
@ -43,6 +42,7 @@ init_logger(log_level)
|
||||||
|
|
||||||
async def build_ui() -> bool:
|
async def build_ui() -> bool:
|
||||||
"""Perform a UI build prior to starting the application."""
|
"""Perform a UI build prior to starting the application."""
|
||||||
|
# Local
|
||||||
from .frontend import build_frontend
|
from .frontend import build_frontend
|
||||||
|
|
||||||
state = use_state()
|
state = use_state()
|
||||||
|
|
@ -59,6 +59,7 @@ async def build_ui() -> bool:
|
||||||
def register_all_plugins() -> None:
|
def register_all_plugins() -> None:
|
||||||
"""Validate and register configured plugins."""
|
"""Validate and register configured plugins."""
|
||||||
|
|
||||||
|
# Local
|
||||||
from .plugins import register_plugin, init_builtin_plugins
|
from .plugins import register_plugin, init_builtin_plugins
|
||||||
|
|
||||||
state = use_state()
|
state = use_state()
|
||||||
|
|
@ -85,6 +86,7 @@ def register_all_plugins() -> None:
|
||||||
|
|
||||||
def unregister_all_plugins() -> None:
|
def unregister_all_plugins() -> None:
|
||||||
"""Unregister all plugins."""
|
"""Unregister all plugins."""
|
||||||
|
# Local
|
||||||
from .plugins import InputPluginManager, OutputPluginManager
|
from .plugins import InputPluginManager, OutputPluginManager
|
||||||
|
|
||||||
for manager in (InputPluginManager, OutputPluginManager):
|
for manager in (InputPluginManager, OutputPluginManager):
|
||||||
|
|
@ -156,6 +158,7 @@ class HyperglassWSGI(BaseApplication):
|
||||||
def start(*, log_level: str, workers: int, **kwargs) -> None:
|
def start(*, log_level: str, workers: int, **kwargs) -> None:
|
||||||
"""Start hyperglass via gunicorn."""
|
"""Start hyperglass via gunicorn."""
|
||||||
|
|
||||||
|
# Local
|
||||||
from .log import CustomGunicornLogger
|
from .log import CustomGunicornLogger
|
||||||
|
|
||||||
HyperglassWSGI(
|
HyperglassWSGI(
|
||||||
|
|
@ -181,6 +184,7 @@ def start(*, log_level: str, workers: int, **kwargs) -> None:
|
||||||
|
|
||||||
def run(_workers: int = None):
|
def run(_workers: int = None):
|
||||||
"""Run hyperglass."""
|
"""Run hyperglass."""
|
||||||
|
# Local
|
||||||
from .configuration import init_user_config
|
from .configuration import init_user_config
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import secrets
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
# Third Party
|
# Third Party
|
||||||
from pydantic import BaseModel, constr, field_validator, ConfigDict
|
from pydantic import BaseModel, ConfigDict, constr, field_validator
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.log import log
|
from hyperglass.log import log
|
||||||
|
|
@ -20,7 +20,6 @@ from hyperglass.exceptions.private import InputValidationError
|
||||||
# Local
|
# Local
|
||||||
from ..config.devices import Device
|
from ..config.devices import Device
|
||||||
|
|
||||||
|
|
||||||
QueryLocation = constr(strip_whitespace=True, strict=True, min_length=1)
|
QueryLocation = constr(strip_whitespace=True, strict=True, min_length=1)
|
||||||
QueryTarget = constr(strip_whitespace=True, min_length=1)
|
QueryTarget = constr(strip_whitespace=True, min_length=1)
|
||||||
QueryType = constr(strip_whitespace=True, strict=True, min_length=1)
|
QueryType = constr(strip_whitespace=True, strict=True, min_length=1)
|
||||||
|
|
|
||||||
|
|
@ -4,15 +4,7 @@
|
||||||
import typing as t
|
import typing as t
|
||||||
|
|
||||||
# Third Party
|
# Third Party
|
||||||
from pydantic import (
|
from pydantic import Field, BaseModel, StrictInt, StrictStr, ConfigDict, StrictBool, field_validator
|
||||||
BaseModel,
|
|
||||||
StrictInt,
|
|
||||||
StrictStr,
|
|
||||||
StrictBool,
|
|
||||||
field_validator,
|
|
||||||
Field,
|
|
||||||
ConfigDict,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.state import use_state
|
from hyperglass.state import use_state
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,12 @@
|
||||||
# Standard Library
|
# Standard Library
|
||||||
# flake8: noqa
|
# flake8: noqa
|
||||||
import math
|
import math
|
||||||
import secrets
|
|
||||||
import typing as t
|
import typing as t
|
||||||
|
import secrets
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
# Third Party
|
# Third Party
|
||||||
from pydantic import BaseModel, field_validator, ConfigDict, Field
|
from pydantic import Field, BaseModel, ConfigDict, field_validator
|
||||||
|
|
||||||
"""Patterns:
|
"""Patterns:
|
||||||
GET /.well-known/looking-glass/v1/ping/2001:DB8::35?protocol=2,1
|
GET /.well-known/looking-glass/v1/ping/2001:DB8::35?protocol=2,1
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
"""Custom validation types."""
|
"""Custom validation types."""
|
||||||
|
|
||||||
|
# Standard Library
|
||||||
import typing as t
|
import typing as t
|
||||||
|
|
||||||
|
# Third Party
|
||||||
from pydantic import AfterValidator
|
from pydantic import AfterValidator
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ from pathlib import Path
|
||||||
from ipaddress import IPv4Address, IPv6Address
|
from ipaddress import IPv4Address, IPv6Address
|
||||||
|
|
||||||
# Third Party
|
# Third Party
|
||||||
from pydantic import FilePath, field_validator, ValidationInfo
|
from pydantic import FilePath, ValidationInfo, field_validator
|
||||||
from netmiko.ssh_dispatcher import CLASS_MAPPER # type: ignore
|
from netmiko.ssh_dispatcher import CLASS_MAPPER # type: ignore
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
"""Configuration for API docs feature."""
|
"""Configuration for API docs feature."""
|
||||||
|
|
||||||
|
# Standard Library
|
||||||
import typing as t
|
import typing as t
|
||||||
|
|
||||||
# Third Party
|
# Third Party
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,7 @@ import typing as t
|
||||||
|
|
||||||
# Third Party
|
# Third Party
|
||||||
import httpx
|
import httpx
|
||||||
from pydantic import (
|
from pydantic import FilePath, SecretStr, PrivateAttr, IPvAnyAddress
|
||||||
FilePath,
|
|
||||||
SecretStr,
|
|
||||||
PrivateAttr,
|
|
||||||
IPvAnyAddress,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.models import HyperglassModel
|
from hyperglass.models import HyperglassModel
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,7 @@ import typing as t
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
# Third Party
|
# Third Party
|
||||||
from pydantic import (
|
from pydantic import ByteSize, SecretStr, AnyHttpUrl, DirectoryPath, field_validator
|
||||||
ByteSize,
|
|
||||||
SecretStr,
|
|
||||||
AnyHttpUrl,
|
|
||||||
DirectoryPath,
|
|
||||||
field_validator,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.constants import __version__
|
from hyperglass.constants import __version__
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import typing as t
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
# Third Party
|
# Third Party
|
||||||
from pydantic import Field, field_validator, ValidationInfo, ConfigDict
|
from pydantic import Field, ConfigDict, ValidationInfo, field_validator
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.settings import Settings
|
from hyperglass.settings import Settings
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import typing as t
|
||||||
from ipaddress import IPv4Address, IPv6Address
|
from ipaddress import IPv4Address, IPv6Address
|
||||||
|
|
||||||
# Third Party
|
# Third Party
|
||||||
from pydantic import field_validator, ValidationInfo
|
from pydantic import ValidationInfo, field_validator
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.util import resolve_hostname
|
from hyperglass.util import resolve_hostname
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
# Standard Library
|
# Standard Library
|
||||||
import typing as t
|
import typing as t
|
||||||
|
|
||||||
|
|
||||||
# Local
|
# Local
|
||||||
from ..main import HyperglassModel
|
from ..main import HyperglassModel
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import typing as t
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
# Third Party
|
# Third Party
|
||||||
from pydantic import HttpUrl, FilePath, constr, field_validator, model_validator, ValidationInfo
|
from pydantic import HttpUrl, FilePath, ValidationInfo, constr, field_validator, model_validator
|
||||||
from pydantic_extra_types.color import Color
|
from pydantic_extra_types.color import Color
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,7 @@ import typing as t
|
||||||
from ipaddress import IPv4Network, IPv6Network, ip_network
|
from ipaddress import IPv4Network, IPv6Network, ip_network
|
||||||
|
|
||||||
# Third Party
|
# Third Party
|
||||||
from pydantic import (
|
from pydantic import Field, FilePath, PrivateAttr, IPvAnyNetwork, field_validator
|
||||||
field_validator,
|
|
||||||
Field,
|
|
||||||
FilePath,
|
|
||||||
IPvAnyNetwork,
|
|
||||||
PrivateAttr,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.log import log
|
from hyperglass.log import log
|
||||||
|
|
@ -24,7 +18,6 @@ from hyperglass.exceptions.private import InputValidationError
|
||||||
from .main import MultiModel, HyperglassModel, HyperglassUniqueModel
|
from .main import MultiModel, HyperglassModel, HyperglassUniqueModel
|
||||||
from .fields import Action
|
from .fields import Action
|
||||||
|
|
||||||
|
|
||||||
StringOrArray = t.Union[str, t.List[str]]
|
StringOrArray = t.Union[str, t.List[str]]
|
||||||
Condition = t.Union[IPvAnyNetwork, str]
|
Condition = t.Union[IPvAnyNetwork, str]
|
||||||
RuleValidation = t.Union[t.Literal["ipv4", "ipv6", "pattern"], None]
|
RuleValidation = t.Union[t.Literal["ipv4", "ipv6", "pattern"], None]
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import typing as t
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
# Third Party
|
# Third Party
|
||||||
from pydantic import HttpUrl, BaseModel, PrivateAttr, RootModel, ConfigDict
|
from pydantic import HttpUrl, BaseModel, RootModel, ConfigDict, PrivateAttr
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.log import log
|
from hyperglass.log import log
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
import typing as t
|
import typing as t
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
# Third Party
|
||||||
from pydantic import ConfigDict
|
from pydantic import ConfigDict
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import typing as t
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
# Third Party
|
# Third Party
|
||||||
from pydantic import model_validator, ConfigDict
|
from pydantic import ConfigDict, model_validator
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.log import log
|
from hyperglass.log import log
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
import typing as t
|
import typing as t
|
||||||
|
|
||||||
# Third Party
|
# Third Party
|
||||||
from pydantic import field_validator, model_validator, ConfigDict
|
from pydantic import ConfigDict, field_validator, model_validator
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.log import log
|
from hyperglass.log import log
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,9 @@ from pydantic import (
|
||||||
SecretStr,
|
SecretStr,
|
||||||
DirectoryPath,
|
DirectoryPath,
|
||||||
IPvAnyAddress,
|
IPvAnyAddress,
|
||||||
field_validator,
|
|
||||||
ValidationInfo,
|
ValidationInfo,
|
||||||
|
field_validator,
|
||||||
)
|
)
|
||||||
|
|
||||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import typing as t
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
# Third Party
|
# Third Party
|
||||||
from pydantic import model_validator, ConfigDict
|
from pydantic import ConfigDict, model_validator
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.log import log
|
from hyperglass.log import log
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
# Project
|
||||||
from hyperglass.models.config.devices import Device
|
from hyperglass.models.config.devices import Device
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,19 @@
|
||||||
"""Test BGP Community validation."""
|
"""Test BGP Community validation."""
|
||||||
|
# Standard Library
|
||||||
import typing as t
|
import typing as t
|
||||||
|
|
||||||
|
# Third Party
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
# Project
|
||||||
|
from hyperglass.state import use_state
|
||||||
|
from hyperglass.models.config.params import Params
|
||||||
|
|
||||||
# Local
|
# Local
|
||||||
from .._builtin.bgp_community import ValidateBGPCommunity
|
from .._builtin.bgp_community import ValidateBGPCommunity
|
||||||
|
|
||||||
from hyperglass.state import use_state
|
|
||||||
from hyperglass.models.config.params import Params
|
|
||||||
|
|
||||||
if t.TYPE_CHECKING:
|
if t.TYPE_CHECKING:
|
||||||
|
# Project
|
||||||
from hyperglass.state import HyperglassState
|
from hyperglass.state import HyperglassState
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ from hyperglass.models.config.devices import Device
|
||||||
from hyperglass.models.data.bgp_route import BGPRouteTable
|
from hyperglass.models.data.bgp_route import BGPRouteTable
|
||||||
|
|
||||||
# Local
|
# Local
|
||||||
from .._builtin.bgp_route_arista import BGPRoutePluginArista
|
|
||||||
from ._fixtures import MockDevice
|
from ._fixtures import MockDevice
|
||||||
|
from .._builtin.bgp_route_arista import BGPRoutePluginArista
|
||||||
|
|
||||||
DEPENDS_KWARGS = {
|
DEPENDS_KWARGS = {
|
||||||
"depends": [
|
"depends": [
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@ from hyperglass.models.api.query import Query
|
||||||
from hyperglass.models.data.bgp_route import BGPRouteTable
|
from hyperglass.models.data.bgp_route import BGPRouteTable
|
||||||
|
|
||||||
# Local
|
# Local
|
||||||
from .._builtin.bgp_route_juniper import BGPRoutePluginJuniper
|
|
||||||
from ._fixtures import MockDevice
|
from ._fixtures import MockDevice
|
||||||
|
from .._builtin.bgp_route_juniper import BGPRoutePluginJuniper
|
||||||
|
|
||||||
DEPENDS_KWARGS = {
|
DEPENDS_KWARGS = {
|
||||||
"depends": [
|
"depends": [
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,20 @@
|
||||||
"""Test state hooks."""
|
"""Test state hooks."""
|
||||||
|
|
||||||
|
# Standard Library
|
||||||
import typing as t
|
import typing as t
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
# Third Party
|
||||||
|
import pytest
|
||||||
|
|
||||||
if t.TYPE_CHECKING:
|
if t.TYPE_CHECKING:
|
||||||
from hyperglass.state import HyperglassState
|
from hyperglass.state import HyperglassState
|
||||||
|
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.models.ui import UIParameters
|
from hyperglass.models.ui import UIParameters
|
||||||
from hyperglass.models.config.devices import Devices
|
|
||||||
from hyperglass.configuration import init_ui_params
|
from hyperglass.configuration import init_ui_params
|
||||||
from hyperglass.models.config.params import Params
|
|
||||||
from hyperglass.models.directive import Directives
|
from hyperglass.models.directive import Directives
|
||||||
|
from hyperglass.models.config.params import Params
|
||||||
|
from hyperglass.models.config.devices import Devices
|
||||||
|
|
||||||
# Local
|
# Local
|
||||||
from ..hooks import use_state
|
from ..hooks import use_state
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue