X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FTrafficGenerator.py;fp=resources%2Flibraries%2Fpython%2FTrafficGenerator.py;h=5d9a0568f187d563c6a494e6354accb4ff9d0ca8;hp=03e389095989018d6566e0e1cd1a341e8eebf139;hb=a201f3d3a5fdb9ccb86d57664cfd1de4bf484d36;hpb=93e808cb3e8b5270bec46e2a19d78736e08aa46c 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,