diff options
author | Vratko Polak <vrpolak@cisco.com> | 2019-07-17 12:40:49 +0200 |
---|---|---|
committer | Vratko Polak <vrpolak@cisco.com> | 2019-07-17 12:40:49 +0200 |
commit | f88a3d9178dfbd73d0479f9aa2f5224e0c89ca1f (patch) | |
tree | 9963cb06a7f089d815f9ebf5e5ba8d8f1f26a209 /resources/libraries/python/IPUtil.py | |
parent | 248d1a52e06622dc9eb1dfdd6ca9f6670b4c0bc3 (diff) |
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 <vrpolak@cisco.com>
Diffstat (limited to 'resources/libraries/python/IPUtil.py')
-rw-r--r-- | resources/libraries/python/IPUtil.py | 68 |
1 files changed, 31 insertions, 37 deletions
diff --git a/resources/libraries/python/IPUtil.py b/resources/libraries/python/IPUtil.py index 6a8e1a2401..0212ead1d7 100644 --- a/resources/libraries/python/IPUtil.py +++ b/resources/libraries/python/IPUtil.py @@ -16,11 +16,11 @@ import re from enum import IntEnum -from ipaddress import ip_address, IPv4Network, IPv6Network +from ipaddress import ip_address from resources.libraries.python.Constants import Constants from resources.libraries.python.InterfaceUtil import InterfaceUtil -from resources.libraries.python.PapiExecutor import PapiExecutor +from resources.libraries.python.PapiExecutor import PapiSocketExecutor from resources.libraries.python.ssh import exec_cmd_no_error, exec_cmd from resources.libraries.python.topology import Topology from resources.libraries.python.VatExecutor import VatTerminal @@ -112,28 +112,22 @@ class IPUtil(object): """ sw_if_index = InterfaceUtil.get_interface_index(node, interface) - if sw_if_index: - is_ipv6 = 1 if ip_version == 'ipv6' else 0 - - cmd = 'ip_address_dump' - args = dict(sw_if_index=sw_if_index, - is_ipv6=is_ipv6) - err_msg = 'Failed to get L2FIB dump on host {host}'.format( - host=node['host']) - - with PapiExecutor(node) as papi_exec: - details = papi_exec.add(cmd, **args).get_details(err_msg) - - for item in details: - item['ip'] = item['prefix'].split('/')[0] - item['prefix_length'] = int(item['prefix'].split('/')[1]) - item['is_ipv6'] = is_ipv6 - item['netmask'] = \ - str(IPv6Network(unicode('::/{pl}'.format( - pl=item['prefix_length']))).netmask) \ - if is_ipv6 \ - else str(IPv4Network(unicode('0.0.0.0/{pl}'.format( - pl=item['prefix_length']))).netmask) + if not sw_if_index: + return list() + + is_ipv6 = 1 if ip_version == 'ipv6' else 0 + + cmd = 'ip_address_dump' + args = dict(sw_if_index=sw_if_index, + is_ipv6=is_ipv6) + err_msg = 'Failed to get L2FIB dump on host {host}'.format( + host=node['host']) + + with PapiSocketExecutor(node) as papi_exec: + details = papi_exec.add(cmd, **args).get_details(err_msg) + + # TODO: CSIT currently looks only whether the list is empty. + # Add proper value processing if values become important. return details @@ -145,10 +139,10 @@ class IPUtil(object): :type node: dict """ - PapiExecutor.run_cli_cmd(node, 'show ip fib') - PapiExecutor.run_cli_cmd(node, 'show ip fib summary') - PapiExecutor.run_cli_cmd(node, 'show ip6 fib') - PapiExecutor.run_cli_cmd(node, 'show ip6 fib summary') + PapiSocketExecutor.run_cli_cmd(node, 'show ip fib') + PapiSocketExecutor.run_cli_cmd(node, 'show ip fib summary') + PapiSocketExecutor.run_cli_cmd(node, 'show ip6 fib') + PapiSocketExecutor.run_cli_cmd(node, 'show ip6 fib summary') @staticmethod def vpp_get_ip_tables_prefix(node, address): @@ -159,7 +153,7 @@ class IPUtil(object): """ addr = ip_address(unicode(address)) - PapiExecutor.run_cli_cmd( + PapiSocketExecutor.run_cli_cmd( node, 'show {ip_ver} fib {addr}/{addr_len}'.format( ip_ver='ip6' if addr.version == 6 else 'ip', addr=addr, @@ -188,7 +182,7 @@ class IPUtil(object): err_msg = 'Failed to get VRF id assigned to interface {ifc}'.format( ifc=interface) - with PapiExecutor(node) as papi_exec: + with PapiSocketExecutor(node) as papi_exec: reply = papi_exec.add(cmd, **args).get_reply(err_msg) return reply['vrf_id'] @@ -209,7 +203,7 @@ class IPUtil(object): loose=0) err_msg = 'Failed to enable source check on interface {ifc}'.format( ifc=if_name) - with PapiExecutor(node) as papi_exec: + with PapiSocketExecutor(node) as papi_exec: papi_exec.add(cmd, **args).get_reply(err_msg) @staticmethod @@ -230,7 +224,7 @@ class IPUtil(object): err_msg = 'VPP ip probe {dev} {ip} failed on {h}'.format( dev=interface, ip=addr, h=node['host']) - with PapiExecutor(node) as papi_exec: + with PapiSocketExecutor(node) as papi_exec: papi_exec.add(cmd, **args).get_reply(err_msg) @staticmethod @@ -407,7 +401,7 @@ class IPUtil(object): address=ip_addr.packed) err_msg = 'Failed to add IP address on interface {ifc}'.format( ifc=interface) - with PapiExecutor(node) as papi_exec: + with PapiSocketExecutor(node) as papi_exec: papi_exec.add(cmd, **args).get_reply(err_msg) @staticmethod @@ -436,7 +430,7 @@ class IPUtil(object): neighbor=neighbor) err_msg = 'Failed to add IP neighbor on interface {ifc}'.format( ifc=iface_key) - with PapiExecutor(node) as papi_exec: + with PapiSocketExecutor(node) as papi_exec: papi_exec.add(cmd, **args).get_reply(err_msg) @staticmethod @@ -583,7 +577,7 @@ class IPUtil(object): err_msg = 'Failed to add route(s) on host {host}'.format( host=node['host']) - with PapiExecutor(node) as papi_exec: + with PapiSocketExecutor(node) as papi_exec: for i in xrange(kwargs.get('count', 1)): args['route']['prefix']['address']['un'] = \ IPUtil.union_addr(net_addr + i) @@ -608,7 +602,7 @@ class IPUtil(object): del_all=1) err_msg = 'Failed to flush IP address on interface {ifc}'.format( ifc=interface) - with PapiExecutor(node) as papi_exec: + with PapiSocketExecutor(node) as papi_exec: papi_exec.add(cmd, **args).get_reply(err_msg) @staticmethod @@ -631,5 +625,5 @@ class IPUtil(object): is_add=1) err_msg = 'Failed to add FIB table 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) |