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:
@@ -1,7 +1,10 @@
|
|||||||
"""Return fake, static data for development purposes."""
|
"""Return fake, static data for development purposes."""
|
||||||
|
|
||||||
# Standard Library
|
# Standard Library
|
||||||
from typing import Dict, Union
|
import typing as t
|
||||||
|
|
||||||
|
# Project
|
||||||
|
from hyperglass.models.data import BGPRouteTable
|
||||||
|
|
||||||
PLAIN = r"""
|
PLAIN = r"""
|
||||||
BGP routing table entry for 4.0.0.0/9, version 1017877672
|
BGP routing table entry for 4.0.0.0/9, version 1017877672
|
||||||
@@ -156,15 +159,10 @@ ROUTES = [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
STRUCTURED = {
|
STRUCTURED = BGPRouteTable(vrf="default", count=len(ROUTES), routes=ROUTES, winning_weight="high")
|
||||||
"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."""
|
"""Bypass the standard execution process and return static, fake output."""
|
||||||
output = PLAIN
|
output = PLAIN
|
||||||
|
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ async def query(
|
|||||||
|
|
||||||
if state.params.fake_output:
|
if state.params.fake_output:
|
||||||
# Return fake, static data for development purposes, if enabled.
|
# 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:
|
else:
|
||||||
# Pass request to execution module
|
# Pass request to execution module
|
||||||
output = await execute(query_data)
|
output = await execute(query_data)
|
||||||
|
|||||||
Reference in New Issue
Block a user