1
0
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:
checktheroads
2019-11-16 23:09:43 -07:00
parent 126d86a8c8
commit 386fe3f66a
2 changed files with 25 additions and 14 deletions

View File

@ -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,
}
)

View File

@ -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,