aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/TrafficGenerator.py
diff options
context:
space:
mode:
authorPeter Mikus <pmikus@cisco.com>2022-05-05 13:08:10 +0200
committerPeter Mikus <pmikus@cisco.com>2022-05-24 08:25:08 +0000
commita201f3d3a5fdb9ccb86d57664cfd1de4bf484d36 (patch)
tree6233cbe5bf30a768505e8677f8b2143ad15e3752 /resources/libraries/python/TrafficGenerator.py
parent93e808cb3e8b5270bec46e2a19d78736e08aa46c (diff)
fix(uti): Add TG type export
- This is actually bug not a feature. - AB to be added later - Tested on TREX and iPerf3 Signed-off-by: Peter Mikus <pmikus@cisco.com> Change-Id: Ib6f2d13e3b9401a9fb5759e42a8a310ee11b9d41
Diffstat (limited to 'resources/libraries/python/TrafficGenerator.py')
-rw-r--r--resources/libraries/python/TrafficGenerator.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/resources/libraries/python/TrafficGenerator.py b/resources/libraries/python/TrafficGenerator.py
index 03e3890959..5d9a0568f1 100644
--- a/resources/libraries/python/TrafficGenerator.py
+++ b/resources/libraries/python/TrafficGenerator.py
@@ -252,7 +252,38 @@ class TrafficGenerator(AbstractMeasurer):
f"{self._node[u'subtype']} not running in {expected_mode} mode!"
)
- # TODO: pylint says disable=too-many-locals.
+ @staticmethod
+ def get_tg_type(tg_node):
+ """Log and return the installed traffic generator type.
+
+ :param tg_node: Node from topology file.
+ :type tg_node: dict
+ :returns: Traffic generator type string.
+ :rtype: str
+ :raises RuntimeError: If command returns nonzero return code.
+ """
+ return str(check_subtype(tg_node))
+
+ @staticmethod
+ def get_tg_version(tg_node):
+ """Log and return the installed traffic generator version.
+
+ :param tg_node: Node from topology file.
+ :type tg_node: dict
+ :returns: Traffic generator version string.
+ :rtype: str
+ :raises RuntimeError: If command returns nonzero return code.
+ """
+ subtype = check_subtype(tg_node)
+ if subtype == NodeSubTypeTG.TREX:
+ command = f"cat {Constants.TREX_INSTALL_DIR}/VERSION"
+ message = u"Get T-Rex version failed!"
+ stdout, _ = exec_cmd_no_error(tg_node, command, message=message)
+ return stdout.strip()
+ else:
+ return "none"
+
+ # TODO: pylint disable=too-many-locals.
def initialize_traffic_generator(
self, tg_node, tg_if1, tg_if2, tg_if1_adj_node, tg_if1_adj_if,
tg_if2_adj_node, tg_if2_adj_if, osi_layer, tg_if1_dst_mac=None,