1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00

general cleanup

This commit is contained in:
checktheroads
2020-03-22 22:09:03 -07:00
parent 5fc9adf1d4
commit 83eb75b4a7
4 changed files with 9 additions and 9 deletions

View File

@@ -89,15 +89,15 @@ def validate_ip(value, query_type, query_vrf): # noqa: C901
ip_version = valid_ip.version
if getattr(query_vrf, f"ipv{ip_version}") is None:
vrf_afi = getattr(query_vrf, f"ipv{ip_version}")
if vrf_afi is None:
raise InputInvalid(
params.messages.feature_not_enabled,
feature=f"IPv{ip_version}",
device_name=f"VRF {query_vrf.display_name}",
)
vrf_afi = getattr(query_vrf, f"ipv{ip_version}")
for ace in [a for a in vrf_afi.access_list if a.network.version == ip_version]:
if _member_of(valid_ip, ace.network):
if query_type == "bgp_route" and _prefix_range(valid_ip, ace.ge, ace.le):

View File

@@ -143,9 +143,9 @@ async def _config_commands():
async with AIOFile(CONFIG_COMMANDS, "r") as cf:
raw = await cf.read()
config = yaml.safe_load(raw) or {}
log.debug("Unvalidated commands: {c}", c=config)
except (yaml.YAMLError, yaml.MarkedYAMLError) as yaml_error:
raise ConfigError(error_msg=str(yaml_error)) from None
log.debug("Unvalidated commands: {c}", c=config)
return config

View File

@@ -49,17 +49,17 @@ async def get_markdown(config_path, default, params):
Returns:
{str} -- Formatted content
"""
log.debug(f"Getting Markdown content for '{params['title']}'")
log.trace(f"Getting Markdown content for '{params['title']}'")
if config_path.enable and config_path.file is not None:
md = await _get_file(config_path.file)
else:
md = default
log.debug(f"Unformatted Content for '{params['title']}':\n{md}")
log.trace(f"Unformatted Content for '{params['title']}':\n{md}")
md_fmt = await format_markdown(md, params)
log.debug(f"Formatted Content for '{params['title']}':\n{md_fmt}")
log.trace(f"Formatted Content for '{params['title']}':\n{md_fmt}")
return md_fmt

View File

@@ -1,7 +1,7 @@
"""Validate credential configuration variables."""
# Third Party
from pydantic import SecretStr
from pydantic import SecretStr, StrictStr
# Project
from hyperglass.util import clean_name
@@ -11,7 +11,7 @@ from hyperglass.configuration.models._utils import HyperglassModel
class Credential(HyperglassModel):
"""Model for per-credential config in devices.yaml."""
username: str
username: StrictStr
password: SecretStr