summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stf
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2016-04-24 15:54:07 +0300
committerYaroslav Brustinov <ybrustin@cisco.com>2016-04-24 15:54:07 +0300
commitcc53c3d2d4b928221f2d51d3f1ace64f34029f1e (patch)
treed5f3c2bd3840a096090e32ae80d149fc66088a45 /scripts/automation/trex_control_plane/stf
parent19f6e9305ae851214c63e2dd45be9965faef6413 (diff)
stateful API: add get_ports_count based on result
regression: be per core takes into account number of ports
Diffstat (limited to 'scripts/automation/trex_control_plane/stf')
-rwxr-xr-xscripts/automation/trex_control_plane/stf/trex_stf_lib/trex_client.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_client.py b/scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_client.py
index 27428e69..f5887120 100755
--- a/scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_client.py
+++ b/scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_client.py
@@ -1094,7 +1094,7 @@ class CTRexResult(object):
if not self.is_valid_hist():
return None
else:
- return CTRexResult.__get_value_by_path(self._history[len(self._history)-1], tree_path_to_key, regex)
+ return CTRexResult.__get_value_by_path(self._history[-1], tree_path_to_key, regex)
def get_value_list (self, tree_path_to_key, regex = None, filter_none = True):
"""
@@ -1145,11 +1145,23 @@ class CTRexResult(object):
+ an empty dictionary if history is empty.
"""
- history_size = len(self._history)
- if history_size != 0:
- return self._history[len(self._history) - 1]
- else:
- return {}
+ if len(self._history):
+ return self._history[-1]
+ return {}
+
+ def get_ports_count(self):
+ """
+ Returns number of ports based on TRex result
+
+ :return:
+ + number of ports in TRex result
+ + -1 if history is empty.
+ """
+
+ if not len(self._history):
+ return -1
+ return len(self.__get_value_by_path(self._history[-1], 'trex-global.data', 'opackets-\d+'))
+
def update_result_data (self, latest_dump):
"""