mirror of
				https://github.com/checktheroads/hyperglass
				synced 2024-05-11 05:55:08 +00:00 
			
		
		
		
	Update code formatting - line length
This commit is contained in:
		@@ -32,9 +32,7 @@ class Construct:
 | 
			
		||||
    def __init__(self, device, query):
 | 
			
		||||
        """Initialize command construction."""
 | 
			
		||||
        log.debug(
 | 
			
		||||
            "Constructing '{}' query for '{}'",
 | 
			
		||||
            query.query_type,
 | 
			
		||||
            str(query.query_target),
 | 
			
		||||
            "Constructing '{}' query for '{}'", query.query_type, str(query.query_target),
 | 
			
		||||
        )
 | 
			
		||||
        self.query = query
 | 
			
		||||
        self.device = device
 | 
			
		||||
@@ -73,10 +71,7 @@ class Construct:
 | 
			
		||||
        for key in [k for k in keys if k != "target"]:
 | 
			
		||||
            if key not in attrs:
 | 
			
		||||
                raise ConfigError(
 | 
			
		||||
                    (
 | 
			
		||||
                        "Command '{c}' has attribute '{k}', "
 | 
			
		||||
                        "which is missing from device '{d}'"
 | 
			
		||||
                    ),
 | 
			
		||||
                    ("Command '{c}' has attribute '{k}', " "which is missing from device '{d}'"),
 | 
			
		||||
                    level="danger",
 | 
			
		||||
                    c=self.directive.name,
 | 
			
		||||
                    k=key,
 | 
			
		||||
 
 | 
			
		||||
@@ -80,9 +80,7 @@ class AgentConnection(Connection):
 | 
			
		||||
                    )
 | 
			
		||||
                    log.debug("Encoded JWT: {}", encoded_query)
 | 
			
		||||
 | 
			
		||||
                    raw_response = await http_client.post(
 | 
			
		||||
                        endpoint, json={"encoded": encoded_query}
 | 
			
		||||
                    )
 | 
			
		||||
                    raw_response = await http_client.post(endpoint, json={"encoded": encoded_query})
 | 
			
		||||
                    log.debug("HTTP status code: {}", raw_response.status_code)
 | 
			
		||||
 | 
			
		||||
                    raw = raw_response.text
 | 
			
		||||
 
 | 
			
		||||
@@ -36,9 +36,7 @@ class SSHConnection(Connection):
 | 
			
		||||
            }
 | 
			
		||||
            if proxy.credential._method == "password":
 | 
			
		||||
                # Use password auth if no key is defined.
 | 
			
		||||
                tunnel_kwargs[
 | 
			
		||||
                    "ssh_password"
 | 
			
		||||
                ] = proxy.credential.password.get_secret_value()
 | 
			
		||||
                tunnel_kwargs["ssh_password"] = proxy.credential.password.get_secret_value()
 | 
			
		||||
            else:
 | 
			
		||||
                # Otherwise, use key auth.
 | 
			
		||||
                tunnel_kwargs["ssh_pkey"] = proxy.credential.key.as_posix()
 | 
			
		||||
@@ -53,8 +51,7 @@ class SSHConnection(Connection):
 | 
			
		||||
 | 
			
		||||
            except BaseSSHTunnelForwarderError as scrape_proxy_error:
 | 
			
		||||
                log.error(
 | 
			
		||||
                    f"Error connecting to device {self.device.name} via "
 | 
			
		||||
                    f"proxy {proxy.name}"
 | 
			
		||||
                    f"Error connecting to device {self.device.name} via " f"proxy {proxy.name}"
 | 
			
		||||
                )
 | 
			
		||||
                raise ScrapeError(error=scrape_proxy_error, device=self.device)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -78,9 +78,7 @@ class NetmikoConnection(SSHConnection):
 | 
			
		||||
 | 
			
		||||
        if self.device.credential._method == "password":
 | 
			
		||||
            # Use password auth if no key is defined.
 | 
			
		||||
            driver_kwargs[
 | 
			
		||||
                "password"
 | 
			
		||||
            ] = self.device.credential.password.get_secret_value()
 | 
			
		||||
            driver_kwargs["password"] = self.device.credential.password.get_secret_value()
 | 
			
		||||
        else:
 | 
			
		||||
            # Otherwise, use key auth.
 | 
			
		||||
            driver_kwargs["use_keys"] = True
 | 
			
		||||
@@ -88,9 +86,7 @@ class NetmikoConnection(SSHConnection):
 | 
			
		||||
            if self.device.credential._method == "encrypted_key":
 | 
			
		||||
                # If the key is encrypted, use the password field as the
 | 
			
		||||
                # private key password.
 | 
			
		||||
                driver_kwargs[
 | 
			
		||||
                    "passphrase"
 | 
			
		||||
                ] = self.device.credential.password.get_secret_value()
 | 
			
		||||
                driver_kwargs["passphrase"] = self.device.credential.password.get_secret_value()
 | 
			
		||||
 | 
			
		||||
        try:
 | 
			
		||||
            nm_connect_direct = ConnectHandler(**driver_kwargs)
 | 
			
		||||
 
 | 
			
		||||
@@ -98,9 +98,7 @@ class ScrapliConnection(SSHConnection):
 | 
			
		||||
 | 
			
		||||
        if self.device.credential._method == "password":
 | 
			
		||||
            # Use password auth if no key is defined.
 | 
			
		||||
            driver_kwargs[
 | 
			
		||||
                "auth_password"
 | 
			
		||||
            ] = self.device.credential.password.get_secret_value()
 | 
			
		||||
            driver_kwargs["auth_password"] = self.device.credential.password.get_secret_value()
 | 
			
		||||
        else:
 | 
			
		||||
            # Otherwise, use key auth.
 | 
			
		||||
            driver_kwargs["auth_private_key"] = self.device.credential.key.as_posix()
 | 
			
		||||
@@ -112,9 +110,7 @@ class ScrapliConnection(SSHConnection):
 | 
			
		||||
                ] = self.device.credential.password.get_secret_value()
 | 
			
		||||
 | 
			
		||||
        driver = driver(**driver_kwargs)
 | 
			
		||||
        driver.logger = log.bind(
 | 
			
		||||
            logger_name=f"scrapli.{driver.host}:{driver.port}-driver"
 | 
			
		||||
        )
 | 
			
		||||
        driver.logger = log.bind(logger_name=f"scrapli.{driver.host}:{driver.port}-driver")
 | 
			
		||||
        try:
 | 
			
		||||
            responses = ()
 | 
			
		||||
            async with driver as connection:
 | 
			
		||||
 
 | 
			
		||||
@@ -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, Sequence, TYPE_CHECKING
 | 
			
		||||
from typing import TYPE_CHECKING, Any, Dict, Union, Callable, Sequence
 | 
			
		||||
 | 
			
		||||
# Project
 | 
			
		||||
from hyperglass.log import log
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user