mirror of
https://github.com/checktheroads/hyperglass
synced 2024-05-11 05:55:08 +00:00
fix frr/bird support
This commit is contained in:
@ -52,8 +52,9 @@ class Construct:
|
||||
_target = re.sub(r"\/", r" ", target)
|
||||
else:
|
||||
_target = target
|
||||
log.debug(f"Formatted target: {_target}")
|
||||
return _target
|
||||
target_string = str(_target)
|
||||
log.debug(f"Formatted target: {target_string}")
|
||||
return target_string
|
||||
|
||||
@staticmethod
|
||||
def device_commands(nos, afi, query_type):
|
||||
@ -95,7 +96,8 @@ class Construct:
|
||||
{
|
||||
"query_type": "ping",
|
||||
"vrf": afi.vrf_name,
|
||||
"source": afi.source_address,
|
||||
"afi": query_protocol,
|
||||
"source": afi.source_address.compressed,
|
||||
"target": self.query_target,
|
||||
}
|
||||
)
|
||||
@ -135,7 +137,8 @@ class Construct:
|
||||
{
|
||||
"query_type": "traceroute",
|
||||
"vrf": afi.vrf_name,
|
||||
"source": afi.source_address,
|
||||
"afi": query_protocol,
|
||||
"source": afi.source_address.compressed,
|
||||
"target": self.query_target,
|
||||
}
|
||||
)
|
||||
@ -172,8 +175,9 @@ class Construct:
|
||||
{
|
||||
"query_type": "bgp_route",
|
||||
"vrf": afi.vrf_name,
|
||||
"source": afi.source_address,
|
||||
"target": self.query_target,
|
||||
"afi": query_protocol,
|
||||
"source": afi.source_address.compressed,
|
||||
"target": self.format_target(self.query_target),
|
||||
}
|
||||
)
|
||||
)
|
||||
@ -220,7 +224,8 @@ class Construct:
|
||||
{
|
||||
"query_type": "bgp_community",
|
||||
"vrf": afi_attr.vrf_name,
|
||||
"source": afi_attr.source_address,
|
||||
"afi": query_protocol,
|
||||
"source": afi_attr.source_address.compressed,
|
||||
"target": self.query_target,
|
||||
}
|
||||
)
|
||||
@ -269,7 +274,8 @@ class Construct:
|
||||
{
|
||||
"query_type": "bgp_aspath",
|
||||
"vrf": afi_attr.vrf_name,
|
||||
"source": afi_attr.source_address,
|
||||
"afi": query_protocol,
|
||||
"source": afi_attr.source_address.compressed,
|
||||
"target": self.query_target,
|
||||
}
|
||||
)
|
||||
|
@ -226,7 +226,7 @@ class Connect:
|
||||
http_protocol = protocol_map.get(self.device.port, "http")
|
||||
endpoint = "{protocol}://{addr}:{port}/{uri}".format(
|
||||
protocol=http_protocol,
|
||||
addr=self.device.address.exploded,
|
||||
addr=self.device.address,
|
||||
port=self.device.port,
|
||||
uri=uri,
|
||||
)
|
||||
@ -236,12 +236,17 @@ class Connect:
|
||||
|
||||
try:
|
||||
http_client = httpx.AsyncClient()
|
||||
raw_response = await http_client.post(
|
||||
endpoint, headers=headers, json=self.query, timeout=7
|
||||
)
|
||||
response = raw_response.text
|
||||
responses = []
|
||||
for query in self.query:
|
||||
raw_response = await http_client.post(
|
||||
endpoint, headers=headers, json=query, timeout=7
|
||||
)
|
||||
log.debug(f"HTTP status code: {raw_response.status_code}")
|
||||
|
||||
log.debug(f"HTTP status code: {raw_response.status_code}")
|
||||
raw = raw_response.text
|
||||
responses.append(raw)
|
||||
|
||||
response = "\n\n".join(responses)
|
||||
log.debug(f"Output for query {self.query}:\n{response}")
|
||||
except (
|
||||
httpx.exceptions.ConnectTimeout,
|
||||
|
Reference in New Issue
Block a user