mirror of
https://github.com/thatmattlove/hyperglass.git
synced 2026-01-17 08:48:05 +00:00
Fix fake output handling
This commit is contained in:
parent
56432013e0
commit
5bf69f7923
2 changed files with 7 additions and 9 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue