mirror of
https://github.com/checktheroads/hyperglass
synced 2024-05-11 05:55:08 +00:00
Implement global state
This commit is contained in:
@@ -16,8 +16,8 @@ import httpx
|
||||
# Project
|
||||
from hyperglass.log import log
|
||||
from hyperglass.util import parse_exception
|
||||
from hyperglass.state import use_state
|
||||
from hyperglass.encode import jwt_decode, jwt_encode
|
||||
from hyperglass.configuration import params
|
||||
from hyperglass.exceptions.public import RestError, ResponseEmpty
|
||||
|
||||
# Local
|
||||
@@ -38,10 +38,11 @@ class AgentConnection(Connection):
|
||||
async def collect(self) -> Iterable: # noqa: C901
|
||||
"""Connect to a device running hyperglass-agent via HTTP."""
|
||||
log.debug("Query parameters: {}", self.query)
|
||||
state = use_state()
|
||||
|
||||
client_params = {
|
||||
"headers": {"Content-Type": "application/json"},
|
||||
"timeout": params.request_timeout,
|
||||
"timeout": state.params.request_timeout,
|
||||
}
|
||||
if self.device.ssl is not None and self.device.ssl.enable:
|
||||
with self.device.ssl.cert.open("r") as file:
|
||||
@@ -76,7 +77,7 @@ class AgentConnection(Connection):
|
||||
encoded_query = await jwt_encode(
|
||||
payload=query,
|
||||
secret=self.device.credential.password.get_secret_value(),
|
||||
duration=params.request_timeout,
|
||||
duration=state.params.request_timeout,
|
||||
)
|
||||
log.debug("Encoded JWT: {}", encoded_query)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user