aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/model/ExportResult.py
diff options
context:
space:
mode:
authorTibor Frank <tifrank@cisco.com>2023-10-06 11:27:22 +0000
committerTibor Frank <tifrank@cisco.com>2023-10-09 10:02:58 +0000
commit68f39d30d623b95dfe13a20d73313b7c173eec2a (patch)
tree07ed7800a1723b324a3dc1d35ffef649ecbeeb06 /resources/libraries/python/model/ExportResult.py
parent2bd6962478da3b35602dd77521d32f5fbf3eec8b (diff)
Model: Add bandwidth to mrr
Change-Id: I4277f23d94fa191890041bb43e2fcd4eb5e42019 Signed-off-by: Tibor Frank <tifrank@cisco.com>
Diffstat (limited to 'resources/libraries/python/model/ExportResult.py')
-rw-r--r--resources/libraries/python/model/ExportResult.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/resources/libraries/python/model/ExportResult.py b/resources/libraries/python/model/ExportResult.py
index dd0968419a..f155848913 100644
--- a/resources/libraries/python/model/ExportResult.py
+++ b/resources/libraries/python/model/ExportResult.py
@@ -96,24 +96,32 @@ def export_tg_type_and_version(tg_type="unknown", tg_version="unknown"):
data["tg_version"] = tg_version
-def append_mrr_value(mrr_value, unit):
+def append_mrr_value(mrr_value, mrr_unit, bandwidth_value=None,
+ bandwidth_unit="bps"):
"""Store mrr value to proper place so it is dumped into json.
The value is appended only when unit is not empty.
:param mrr_value: Forwarding rate from MRR trial.
- :param unit: Unit of measurement for the rate.
+ :param mrr_unit: Unit of measurement for the rate.
+ :param bandwidth_value: The same value recomputed into L1 bits per second.
:type mrr_value: float
- :type unit: str
+ :type mrr_unit: str
+ :type bandwidth_value: Optional[float]
+ :type bandwidth_unit: Optional[str]
"""
- if not unit:
+ if not mrr_unit:
return
data = get_export_data()
data["result"]["type"] = "mrr"
- rate_node = descend(descend(data["result"], "receive_rate"), "rate")
- rate_node["unit"] = str(unit)
- values_list = descend(rate_node, "values", list)
- values_list.append(float(mrr_value))
+
+ for node_val, node_unit, node_name in ((mrr_value, mrr_unit, "rate"),
+ (bandwidth_value, bandwidth_unit, "bandwidth")):
+ if node_val is not None:
+ node = descend(descend(data["result"], "receive_rate"), node_name)
+ node["unit"] = str(node_unit)
+ values_list = descend(node, "values", list)
+ values_list.append(float(node_val))
def export_search_bound(text, value, unit, bandwidth=None):