summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2016-10-28 14:32:05 +0200
committerYaroslav Brustinov <ybrustin@cisco.com>2016-10-28 14:39:56 +0200
commit111bd3664b91279883d9f8e2483e436cbdcf3d38 (patch)
treeaabbd949a315e5551903e6febd4c0460216d9636 /scripts/automation/trex_control_plane
parent1016c3d481dc9e2eb9ab03332aff441c03239614 (diff)
move port_attr from driver class to physical port class + small fixes according to code review
Signed-off-by: Yaroslav Brustinov <ybrustin@cisco.com>
Diffstat (limited to 'scripts/automation/trex_control_plane')
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py7
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py3
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/common.py14
3 files changed, 5 insertions, 19 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
index 1ce21973..cec3761f 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
@@ -669,10 +669,7 @@ class Port(object):
else:
info['prom'] = "N/A"
- if 'description' in info:
- if len(info['description']) > 18:
- info['description'] = info['description'][:18]
- else:
+ if 'description' not in info:
info['description'] = "N/A"
if 'is_fc_supported' in info:
@@ -710,7 +707,7 @@ class Port(object):
info = self.get_info()
return {"driver": info['driver'],
- "description": info.get('description', 'N/A'),
+ "description": info.get('description', 'N/A')[:18],
"HW src mac": info['hw_macaddr'],
"SW src mac": info['src_macaddr'],
"SW dst mac": info['dst_macaddr'],
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
index 915eabb2..875ad24e 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
@@ -539,8 +539,7 @@ class CTRexInfoGenerator(object):
stats_table.set_cols_dtype(['t'] * (len(relevant_ports) + 1))
for key, arr in xstats_data.items():
if include_zero_lines or list(filter(None, arr)):
- if len(key) > 28:
- key = key[:28]
+ key = key[:28]
stats_table.add_row([key] + arr)
return {'xstats:': ExportableStats(None, stats_table)}
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/common.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/common.py
index 0214d7d7..72ee8972 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/common.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/common.py
@@ -27,9 +27,9 @@ def user_input():
return raw_input()
-def random_id_gen_unsafe(length=8):
+class random_id_gen:
"""
- A generator for creating a random chars id of specific length
+ Emulated generator for creating a random chars id of specific length
:parameters:
length : int
@@ -40,16 +40,6 @@ def random_id_gen_unsafe(length=8):
:return:
a random id with each next() request.
"""
- id_chars = string.ascii_lowercase + string.digits
- while True:
- return_id = ''
- for i in range(length):
- return_id += random.choice(id_chars)
- yield return_id
-
-
-class random_id_gen:
- """ Thread safe version of random_id_gen_unsafe """
def __init__(self, length=8):
self.id_chars = string.ascii_lowercase + string.digits
self.length = length