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

Fix fake output handling

This commit is contained in:
thatmattlove
2021-12-13 22:15:06 -07:00
parent 56432013e0
commit 5bf69f7923
2 changed files with 7 additions and 9 deletions

View File

@@ -1,7 +1,10 @@
"""Return fake, static data for development purposes."""
# Standard Library
from typing import Dict, Union
import typing as t
# Project
from hyperglass.models.data import BGPRouteTable
PLAIN = r"""
BGP routing table entry for 4.0.0.0/9, version 1017877672
@@ -156,15 +159,10 @@ ROUTES = [
},
]
STRUCTURED = {
"vrf": "default",
"count": len(ROUTES),
"routes": ROUTES,
"winning_weight": "high",
}
STRUCTURED = BGPRouteTable(vrf="default", count=len(ROUTES), routes=ROUTES, winning_weight="high")
async def fake_output(structured: bool) -> Union[str, Dict]:
async def fake_output(structured: bool) -> t.Union[str, BGPRouteTable]:
"""Bypass the standard execution process and return static, fake output."""
output = PLAIN

View File

@@ -128,7 +128,7 @@ async def query(
if state.params.fake_output:
# Return fake, static data for development purposes, if enabled.
output = await fake_output(True)
output = await fake_output(query_data.device.structured_output or False)
else:
# Pass request to execution module
output = await execute(query_data)