aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/model
diff options
context:
space:
mode:
authorpmikus <peter.mikus@protonmail.ch>2022-12-06 12:54:25 +0000
committerpmikus <peter.mikus@protonmail.ch>2022-12-09 10:29:05 +0000
commit420226fcfd8cab460f632c1401d6012dc353f6fd (patch)
treebc86706a812ecd6fa497968bc8f17cb92461af6d /resources/libraries/python/model
parent5466cc69f18a480dbff7e39d28abbbccf683ba2f (diff)
feat(model): Reconf type
Signed-off-by: pmikus <peter.mikus@protonmail.ch> Change-Id: Ibfab25ee82eaa207987f4070cf2386ea9d0781cd
Diffstat (limited to 'resources/libraries/python/model')
-rw-r--r--resources/libraries/python/model/ExportResult.py43
1 files changed, 39 insertions, 4 deletions
diff --git a/resources/libraries/python/model/ExportResult.py b/resources/libraries/python/model/ExportResult.py
index 31840c9deb..b5de27ebe5 100644
--- a/resources/libraries/python/model/ExportResult.py
+++ b/resources/libraries/python/model/ExportResult.py
@@ -143,8 +143,7 @@ def export_search_bound(text, value, unit, bandwidth=None):
upper_or_lower = u"upper" if u"upper" in text else u"lower"
ndr_or_pdr = u"ndr" if u"ndr" in text else u"pdr"
- data = get_export_data()
- result_node = data[u"result"]
+ result_node = get_export_data()[u"result"]
result_node[u"type"] = result_type
rate_item = dict(rate=dict(value=value, unit=unit))
if bandwidth:
@@ -196,8 +195,7 @@ def export_ndrpdr_latency(text, latency):
:type text: str
:type latency: 1-tuple or 2-tuple of str
"""
- data = get_export_data()
- result_node = data[u"result"]
+ result_node = get_export_data()[u"result"]
percent = 0
if u"90" in text:
percent = 90
@@ -211,6 +209,43 @@ def export_ndrpdr_latency(text, latency):
return
_add_latency(result_node, percent, u"reverse", latency[1])
+
+def export_reconf_result(packet_rate, packet_loss, bandwidth):
+ """Export the results from a reconf test.
+
+ :param packet_rate: Aggregate offered load in packets per second.
+ :param packet_loss: How many of the packets were dropped or unsent.
+ :param bandwidth: The offered load recomputed into L1 bits per second.
+ :type packet_rate: float
+ :type packet_loss: int
+ :type bandwidth: float
+ """
+ result_node = get_export_data()["result"]
+ result_node["type"] = "reconf"
+
+ time_loss = int(packet_loss) / float(packet_rate)
+ result_node["aggregate_rate"] = dict(
+ bandwidth=dict(
+ unit="bps",
+ value=float(bandwidth)
+ ),
+ rate=dict(
+ unit="pps",
+ value=float(packet_rate)
+ )
+ )
+ result_node["loss"] = dict(
+ packet=dict(
+ unit="packets",
+ value=int(packet_loss)
+ ),
+ time=dict(
+ unit="s",
+ value=time_loss
+ )
+ )
+
+
def append_telemetry(telemetry_item):
"""Append telemetry entry to proper place so it is dumped into json.