summaryrefslogtreecommitdiffstats
path: root/scripts/automation
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2017-02-06 11:06:13 +0200
committerYaroslav Brustinov <ybrustin@cisco.com>2017-02-06 11:06:13 +0200
commit1570aea16299122399e14c7c281fe3d4259e63a7 (patch)
tree20d11950288fc2e5e3dd13ad4f0013ab6e09bdba /scripts/automation
parent935de2a8ec8fce9f6b51cf10f7d4d1ed29625420 (diff)
STL API scan6: If error at any port, raise error. If no error, return data per port.
Change-Id: I6592e890835fcbe16d35e6981de76c01999d6883 Signed-off-by: Yaroslav Brustinov <ybrustin@cisco.com>
Diffstat (limited to 'scripts/automation')
-rwxr-xr-xscripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py37
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/common.py5
2 files changed, 33 insertions, 9 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
index 492dba68..b95c190b 100755
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
@@ -3065,8 +3065,18 @@ class STLClient(object):
+ :exe:'STLError'
"""
- ports = ports if ports is not None else self.get_acquired_ports()
- ports = self._validate_port_list(ports)
+
+ if ports is None:
+ ports = self.get_acquired_ports()
+ else:
+ ports = self._validate_port_list(ports)
+ not_acquired = list_difference(ports, self.get_acquired_ports())
+ if not_acquired:
+ raise STLError('Following ports are not acquired: %s' % ', '.join(map(str, not_acquired)))
+
+ not_in_service = list_difference(ports, self.get_service_enabled_ports())
+ if not_in_service:
+ raise STLError('Following ports are not in service mode: %s' % ', '.join(map(str, not_in_service)))
self.logger.pre_cmd('Scanning network for IPv6 nodes on port(s) {0}:'.format(ports))
@@ -3075,13 +3085,22 @@ class STLClient(object):
self.logger.post_cmd(rc_per_port)
+ err = RC()
+ replies_per_port = {}
+ for port, rc in rc_per_port.items():
+ if not rc:
+ err.add(rc)
+ else:
+ replies_per_port[port] = rc.data()
+
+ if err.rc_list:
+ raise STLError(err)
+
if verbose:
- for port, rc in rc_per_port.items():
- if not rc:
- self.logger.log(format_text(rc, 'bold'))
- elif rc.data():
+ for port, replies in replies_per_port.items():
+ if replies:
max_ip_len = 0
- for resp in rc.data():
+ for resp in replies:
max_ip_len = max(max_ip_len, len(resp['ipv6']))
scan_table = TRexTextTable()
scan_table.set_cols_align(['c', 'c', 'l'])
@@ -3091,7 +3110,7 @@ class STLClient(object):
resp = 'Port %s - IPv6 search result:' % port
self.logger.log(format_text(resp, 'bold'))
node_types = defaultdict(list)
- for reply in rc.data():
+ for reply in replies:
node_types[reply['type']].append(reply)
for key in sorted(node_types.keys()):
for reply in node_types[key]:
@@ -3101,7 +3120,7 @@ class STLClient(object):
else:
self.logger.log(format_text('Port %s: no replies! Try to ping with explicit address.' % port, 'bold'))
- return rc_per_port
+ return replies_per_port
@__api_check(True)
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 6b90a3b4..8ba98c71 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
@@ -65,9 +65,14 @@ def get_number(input):
def list_intersect(l1, l2):
return list(filter(lambda x: x in l2, l1))
+# actually first list minus second
def list_difference (l1, l2):
return list(filter(lambda x: x not in l2, l1))
+# symmetric diff
+def list_xor(l1, l2):
+ return list(set(l1) ^ set(l2))
+
def is_sub_list (l1, l2):
return set(l1) <= set(l2)