forked from mirrors/thatmattlove-hyperglass
import formatting imporvements
This commit is contained in:
parent
6841cb65f5
commit
6b188e446c
28 changed files with 31 additions and 4 deletions
|
|
@ -10,4 +10,5 @@ force_single_line = False
|
||||||
import_heading_stdlib = Standard Library
|
import_heading_stdlib = Standard Library
|
||||||
import_heading_thirdparty = Third Party
|
import_heading_thirdparty = Third Party
|
||||||
import_heading_firstparty = Project
|
import_heading_firstparty = Project
|
||||||
|
import_heading_localfolder = Local
|
||||||
known_third_party = starlette,fastapi,inquirer
|
known_third_party = starlette,fastapi,inquirer
|
||||||
|
|
@ -12,6 +12,7 @@ from click import group, option, confirm, help_option
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.util import cpu_count
|
from hyperglass.util import cpu_count
|
||||||
|
|
||||||
|
# Local
|
||||||
from .echo import error, label, success, cmd_help
|
from .echo import error, label, success, cmd_help
|
||||||
from .util import build_ui
|
from .util import build_ui
|
||||||
from .static import LABEL, CLI_HELP, E
|
from .static import LABEL, CLI_HELP, E
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
"""Individual transport driver classes & subclasses."""
|
"""Individual transport driver classes & subclasses."""
|
||||||
|
|
||||||
|
# Local
|
||||||
from .agent import AgentConnection
|
from .agent import AgentConnection
|
||||||
from .ssh_netmiko import NetmikoConnection
|
from .ssh_netmiko import NetmikoConnection
|
||||||
from .ssh_scrapli import ScrapliConnection
|
from .ssh_scrapli import ScrapliConnection
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ from hyperglass.parsing.nos import scrape_parsers, structured_parsers
|
||||||
from hyperglass.parsing.common import parsers
|
from hyperglass.parsing.common import parsers
|
||||||
from hyperglass.models.config.devices import Device
|
from hyperglass.models.config.devices import Device
|
||||||
|
|
||||||
|
# Local
|
||||||
from ._construct import Construct
|
from ._construct import Construct
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ from hyperglass.encode import jwt_decode, jwt_encode
|
||||||
from hyperglass.exceptions import RestError, ResponseEmpty
|
from hyperglass.exceptions import RestError, ResponseEmpty
|
||||||
from hyperglass.configuration import params
|
from hyperglass.configuration import params
|
||||||
|
|
||||||
|
# Local
|
||||||
from ._common import Connection
|
from ._common import Connection
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ from hyperglass.exceptions import ScrapeError
|
||||||
from hyperglass.configuration import params
|
from hyperglass.configuration import params
|
||||||
from hyperglass.compat._sshtunnel import BaseSSHTunnelForwarderError, open_tunnel
|
from hyperglass.compat._sshtunnel import BaseSSHTunnelForwarderError, open_tunnel
|
||||||
|
|
||||||
|
# Local
|
||||||
from ._common import Connection
|
from ._common import Connection
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ from hyperglass.log import log
|
||||||
from hyperglass.exceptions import AuthError, ScrapeError, DeviceTimeout
|
from hyperglass.exceptions import AuthError, ScrapeError, DeviceTimeout
|
||||||
from hyperglass.configuration import params
|
from hyperglass.configuration import params
|
||||||
|
|
||||||
|
# Local
|
||||||
from .ssh import SSHConnection
|
from .ssh import SSHConnection
|
||||||
|
|
||||||
netmiko_nos_globals = {
|
netmiko_nos_globals = {
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ from hyperglass.exceptions import (
|
||||||
)
|
)
|
||||||
from hyperglass.configuration import params
|
from hyperglass.configuration import params
|
||||||
|
|
||||||
|
# Local
|
||||||
from .ssh import SSHConnection
|
from .ssh import SSHConnection
|
||||||
|
|
||||||
SCRAPLI_DRIVER_MAP = {
|
SCRAPLI_DRIVER_MAP = {
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ from hyperglass.exceptions import DeviceTimeout, ResponseEmpty
|
||||||
from hyperglass.models.api import Query
|
from hyperglass.models.api import Query
|
||||||
from hyperglass.configuration import params
|
from hyperglass.configuration import params
|
||||||
|
|
||||||
|
# Local
|
||||||
from .drivers import AgentConnection, NetmikoConnection, ScrapliConnection
|
from .drivers import AgentConnection, NetmikoConnection, ScrapliConnection
|
||||||
|
|
||||||
DRIVER_MAP = {
|
DRIVER_MAP = {
|
||||||
|
|
|
||||||
1
hyperglass/external/__init__.py
vendored
1
hyperglass/external/__init__.py
vendored
|
|
@ -1,4 +1,5 @@
|
||||||
"""Functions & handlers for external data."""
|
"""Functions & handlers for external data."""
|
||||||
|
|
||||||
|
# Local
|
||||||
from .ripestat import RIPEStat # noqa: F401
|
from .ripestat import RIPEStat # noqa: F401
|
||||||
from .webhooks import Webhook # noqa: F401
|
from .webhooks import Webhook # noqa: F401
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
"""All Data Models used by hyperglass."""
|
"""All Data Models used by hyperglass."""
|
||||||
|
|
||||||
|
# Local
|
||||||
from .main import HyperglassModel, HyperglassModelExtra
|
from .main import HyperglassModel, HyperglassModelExtra
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
"""Query & Response Validation Models."""
|
"""Query & Response Validation Models."""
|
||||||
|
# Local
|
||||||
from .query import Query
|
from .query import Query
|
||||||
from .response import (
|
from .response import (
|
||||||
QueryError,
|
QueryError,
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ from pydantic import BaseModel, StrictStr, constr, validator
|
||||||
from hyperglass.exceptions import InputInvalid
|
from hyperglass.exceptions import InputInvalid
|
||||||
from hyperglass.configuration import params, devices
|
from hyperglass.configuration import params, devices
|
||||||
|
|
||||||
|
# Local
|
||||||
from .types import SupportedQuery
|
from .types import SupportedQuery
|
||||||
from .validators import (
|
from .validators import (
|
||||||
validate_ip,
|
validate_ip,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
"""Validate command configuration variables."""
|
"""Validate command configuration variables."""
|
||||||
|
|
||||||
|
# Local
|
||||||
from .vyos import VyosCommands
|
from .vyos import VyosCommands
|
||||||
from ..main import HyperglassModelExtra
|
from ..main import HyperglassModelExtra
|
||||||
from .arista import AristaCommands
|
from .arista import AristaCommands
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
# Third Party
|
# Third Party
|
||||||
from pydantic import StrictStr
|
from pydantic import StrictStr
|
||||||
|
|
||||||
|
# Local
|
||||||
from .common import CommandSet, CommandGroup
|
from .common import CommandSet, CommandGroup
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
# Third Party
|
# Third Party
|
||||||
from pydantic import StrictStr
|
from pydantic import StrictStr
|
||||||
|
|
||||||
|
# Local
|
||||||
from .common import CommandSet, CommandGroup
|
from .common import CommandSet, CommandGroup
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
# Third Party
|
# Third Party
|
||||||
from pydantic import StrictStr
|
from pydantic import StrictStr
|
||||||
|
|
||||||
|
# Local
|
||||||
from .common import CommandSet, CommandGroup
|
from .common import CommandSet, CommandGroup
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
# Third Party
|
# Third Party
|
||||||
from pydantic import StrictStr
|
from pydantic import StrictStr
|
||||||
|
|
||||||
|
# Local
|
||||||
from .common import CommandSet, CommandGroup
|
from .common import CommandSet, CommandGroup
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
# Third Party
|
# Third Party
|
||||||
from pydantic import StrictStr
|
from pydantic import StrictStr
|
||||||
|
|
||||||
|
# Local
|
||||||
from .common import CommandSet, CommandGroup
|
from .common import CommandSet, CommandGroup
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
# Third Party
|
# Third Party
|
||||||
from pydantic import StrictStr
|
from pydantic import StrictStr
|
||||||
|
|
||||||
|
# Local
|
||||||
from ..main import HyperglassModel, HyperglassModelExtra
|
from ..main import HyperglassModel, HyperglassModelExtra
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
# Third Party
|
# Third Party
|
||||||
from pydantic import StrictStr
|
from pydantic import StrictStr
|
||||||
|
|
||||||
|
# Local
|
||||||
from .common import CommandSet, CommandGroup
|
from .common import CommandSet, CommandGroup
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
# Third Party
|
# Third Party
|
||||||
from pydantic import StrictStr
|
from pydantic import StrictStr
|
||||||
|
|
||||||
|
# Local
|
||||||
from .common import CommandSet, CommandGroup
|
from .common import CommandSet, CommandGroup
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
"""Mikrotik RouterOS Commands Model."""
|
"""Mikrotik RouterOS Commands Model."""
|
||||||
|
# Local
|
||||||
from ._mikrotik_base import MikrotikCommands
|
from ._mikrotik_base import MikrotikCommands
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
"""Mikrotik SwitchOS Commands Model."""
|
"""Mikrotik SwitchOS Commands Model."""
|
||||||
|
# Local
|
||||||
from ._mikrotik_base import MikrotikCommands
|
from ._mikrotik_base import MikrotikCommands
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
# Third Party
|
# Third Party
|
||||||
from pydantic import StrictStr
|
from pydantic import StrictStr
|
||||||
|
|
||||||
|
# Local
|
||||||
from .common import CommandSet, CommandGroup
|
from .common import CommandSet, CommandGroup
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ from pydantic import StrictStr, root_validator
|
||||||
# Project
|
# Project
|
||||||
from hyperglass.log import log
|
from hyperglass.log import log
|
||||||
|
|
||||||
|
# Local
|
||||||
from .main import HyperglassModel, HyperglassModelExtra
|
from .main import HyperglassModel, HyperglassModelExtra
|
||||||
|
|
||||||
_WEBHOOK_TITLE = "hyperglass received a valid query with the following data"
|
_WEBHOOK_TITLE = "hyperglass received a valid query with the following data"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
"""Map NOS and Commands to Parsing Functions."""
|
"""Map NOS and Commands to Parsing Functions."""
|
||||||
|
|
||||||
|
# Local
|
||||||
from .juniper import parse_juniper
|
from .juniper import parse_juniper
|
||||||
from .mikrotik import parse_mikrotik
|
from .mikrotik import parse_mikrotik
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -682,7 +682,7 @@ async def build_frontend( # noqa: C901
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def set_app_path(required=False):
|
def set_app_path(required: bool = False) -> Path:
|
||||||
"""Find app directory and set value to environment variable."""
|
"""Find app directory and set value to environment variable."""
|
||||||
|
|
||||||
# Standard Library
|
# Standard Library
|
||||||
|
|
@ -711,15 +711,15 @@ def set_app_path(required=False):
|
||||||
No configuration directories were determined to both exist and be readable
|
No configuration directories were determined to both exist and be readable
|
||||||
by hyperglass. hyperglass is running as user '{un}' (UID '{uid}'), and tried
|
by hyperglass. hyperglass is running as user '{un}' (UID '{uid}'), and tried
|
||||||
to access the following directories:
|
to access the following directories:
|
||||||
{dir}""".format(
|
{dir}""".format(
|
||||||
un=getuser(),
|
un=getuser(),
|
||||||
uid=os.getuid(),
|
uid=os.getuid(),
|
||||||
dir="\n".join([" - " + str(p) for p in config_paths]),
|
dir="\n".join(["\t - " + str(p) for p in config_paths]),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
os.environ["hyperglass_directory"] = str(matched_path)
|
os.environ["hyperglass_directory"] = str(matched_path)
|
||||||
return True
|
return matched_path
|
||||||
|
|
||||||
|
|
||||||
def format_listen_address(listen_address: Union[IPv4Address, IPv6Address, str]) -> str:
|
def format_listen_address(listen_address: Union[IPv4Address, IPv6Address, str]) -> str:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue