From f88a3d9178dfbd73d0479f9aa2f5224e0c89ca1f Mon Sep 17 00:00:00 2001 From: Vratko Polak Date: Wed, 17 Jul 2019 12:40:49 +0200 Subject: Use PapiSocketProvider for most PAPI calls Ticket: CSIT-1541 Ticket: VPP-1722 Ticket: CSIT-1546 + Increase timeout to hide x520 slownes of show hardware detail. - Install sshpass and update ssh client in virl bootstrap. + Added TODOs to remove when CSIT-1546 is fixed. + Enable default socksvr on any startup conf. + Improve OptionString init and repr. - The non-socket executor still kept for stats. + Remove everything unrelated to stats from non-socket executor. - Remove some debug-loooking calls to avoid failures. TODO: Introduce proper parsing to the affected keywords. + Reduce logging from PAPI code to level INFO. - Needs https://gerrit.fd.io/r/20660 to fully work. + Change default values for LocalExecution.run() + Return code check enabled by default. Code is more readable when rc!=0 is allowed explicitly, and the test code will now detect unexpected failures. + Logging disabled by default. Output XML is large already. Important logging can be enabled explicitly. + Restore alphabetical order in common.sh functions. Change-Id: I05882cb6b620ad14638f7404b5ad38c7a5de9e6c Signed-off-by: Vratko Polak --- resources/libraries/python/L2Util.py | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'resources/libraries/python/L2Util.py') diff --git a/resources/libraries/python/L2Util.py b/resources/libraries/python/L2Util.py index 7c575a290e..4ca0c47308 100644 --- a/resources/libraries/python/L2Util.py +++ b/resources/libraries/python/L2Util.py @@ -19,7 +19,7 @@ from textwrap import wrap from enum import IntEnum from resources.libraries.python.Constants import Constants -from resources.libraries.python.PapiExecutor import PapiExecutor +from resources.libraries.python.PapiExecutor import PapiSocketExecutor from resources.libraries.python.topology import Topology from resources.libraries.python.ssh import exec_cmd_no_error @@ -129,7 +129,7 @@ class L2Util(object): static_mac=int(static_mac), filter_mac=int(filter_mac), bvi_mac=int(bvi_mac)) - with PapiExecutor(node) as papi_exec: + with PapiSocketExecutor(node) as papi_exec: papi_exec.add(cmd, **args).get_reply(err_msg) @staticmethod @@ -168,7 +168,7 @@ class L2Util(object): learn=int(learn), arp_term=int(arp_term), is_add=1) - with PapiExecutor(node) as papi_exec: + with PapiSocketExecutor(node) as papi_exec: papi_exec.add(cmd, **args).get_reply(err_msg) @staticmethod @@ -200,7 +200,7 @@ class L2Util(object): shg=int(shg), port_type=int(port_type), enable=1) - with PapiExecutor(node) as papi_exec: + with PapiSocketExecutor(node) as papi_exec: papi_exec.add(cmd, **args).get_reply(err_msg) @staticmethod @@ -248,7 +248,7 @@ class L2Util(object): err_msg = 'Failed to add L2 bridge domain with 2 interfaces on host' \ ' {host}'.format(host=node['host']) - with PapiExecutor(node) as papi_exec: + with PapiSocketExecutor(node) as papi_exec: papi_exec.add(cmd1, **args1).add(cmd2, **args2).add(cmd2, **args3) papi_exec.get_replies(err_msg) @@ -285,7 +285,7 @@ class L2Util(object): err_msg = 'Failed to add L2 cross-connect between two interfaces on' \ ' host {host}'.format(host=node['host']) - with PapiExecutor(node) as papi_exec: + with PapiSocketExecutor(node) as papi_exec: papi_exec.add(cmd, **args1).add(cmd, **args2).get_replies(err_msg) @staticmethod @@ -321,7 +321,7 @@ class L2Util(object): err_msg = 'Failed to add L2 patch between two interfaces on' \ ' host {host}'.format(host=node['host']) - with PapiExecutor(node) as papi_exec: + with PapiSocketExecutor(node) as papi_exec: papi_exec.add(cmd, **args1).add(cmd, **args2).get_replies(err_msg) @staticmethod @@ -391,18 +391,14 @@ class L2Util(object): args = dict(bd_id=int(bd_id)) err_msg = 'Failed to get L2FIB dump on host {host}'.format( host=node['host']) - with PapiExecutor(node) as papi_exec: + with PapiSocketExecutor(node) as papi_exec: details = papi_exec.add(cmd, **args).get_details(err_msg) - bd_data = list() if bd_id == Constants.BITWISE_NON_ZERO else dict() + if bd_id == Constants.BITWISE_NON_ZERO: + return details for bridge_domain in details: - if bd_id == Constants.BITWISE_NON_ZERO: - bd_data.append(bridge_domain) - else: - if bridge_domain['bd_id'] == bd_id: - return bridge_domain - - return bd_data + if bridge_domain['bd_id'] == bd_id: + return bridge_domain @staticmethod def l2_vlan_tag_rewrite(node, interface, tag_rewrite_method, @@ -444,7 +440,7 @@ class L2Util(object): tag2=tag2_id) err_msg = 'Failed to set VLAN TAG rewrite on host {host}'.format( host=node['host']) - with PapiExecutor(node) as papi_exec: + with PapiSocketExecutor(node) as papi_exec: papi_exec.add(cmd, **args).get_reply(err_msg) @staticmethod @@ -463,7 +459,7 @@ class L2Util(object): args = dict(bd_id=int(bd_id)) err_msg = 'Failed to get L2FIB dump on host {host}'.format( host=node['host']) - with PapiExecutor(node) as papi_exec: + with PapiSocketExecutor(node) as papi_exec: details = papi_exec.add(cmd, **args).get_details(err_msg) for fib_item in details: -- cgit 1.2.3-korg