From 73a01b1a7fc836c964627eea2c08106df0da5aee Mon Sep 17 00:00:00 2001 From: Jan Gelety Date: Thu, 22 Mar 2018 13:51:33 +0100 Subject: CSIT-1009: SRv6 proxy tests - SRv6 with endpoint to SR-unaware Service Function via static proxy - SRv6 with endpoint to SR-unaware Service Function via dynamic proxy - SRv6 with endpoint to SR-unaware Service Function via masquerading proxy Change-Id: I6a6062cb41d810bf9e27dacfd866181bfde4c693 Signed-off-by: Jan Gelety --- resources/libraries/python/DUTSetup.py | 1 + resources/libraries/python/Memif.py | 2 +- resources/libraries/python/SRv6.py | 58 +++++++++++++++++++++++++++++----- resources/libraries/python/Trace.py | 13 +++++--- 4 files changed, 61 insertions(+), 13 deletions(-) (limited to 'resources/libraries/python') diff --git a/resources/libraries/python/DUTSetup.py b/resources/libraries/python/DUTSetup.py index 2741eaaf1f..ae42637f52 100644 --- a/resources/libraries/python/DUTSetup.py +++ b/resources/libraries/python/DUTSetup.py @@ -496,6 +496,7 @@ class DUTSetup(object): vat = VatExecutor() vat.execute_script("enable_dpdk_traces.vat", node, json_out=False) vat.execute_script("enable_vhost_user_traces.vat", node, json_out=False) + vat.execute_script("enable_memif_traces.vat", node, json_out=False) @staticmethod def install_vpp_on_all_duts(nodes, vpp_pkg_dir, vpp_rpm_pkgs, vpp_deb_pkgs): diff --git a/resources/libraries/python/Memif.py b/resources/libraries/python/Memif.py index d0ab6c74d1..b4c184e1be 100644 --- a/resources/libraries/python/Memif.py +++ b/resources/libraries/python/Memif.py @@ -175,7 +175,7 @@ class Memif(object): for item in memif_data: if memif_data[item]['sw_if_index'] == str(sw_if_idx): return item - return None + return None @staticmethod def vpp_get_memif_interface_mac(node, sw_if_idx): diff --git a/resources/libraries/python/SRv6.py b/resources/libraries/python/SRv6.py index 03a55a41ed..fe706f5f70 100644 --- a/resources/libraries/python/SRv6.py +++ b/resources/libraries/python/SRv6.py @@ -32,6 +32,12 @@ SRV6BEHAVIOUR_END_DT4 = 'end.dt4' SRV6BEHAVIOUR_END_DX6 = 'end.dx6' # Endpoint with decapsulation and IPv6 table lookup SRV6BEHAVIOUR_END_DT6 = 'end.dt6' +# Endpoint to SR-unaware appliance via static proxy +SRV6BEHAVIOUR_END_AS = 'end.as' +# Endpoint to SR-unaware appliance via dynamic proxy +SRV6BEHAVIOUR_END_AD = 'end.ad' +# Endpoint to SR-unaware appliance via masquerading +SRV6BEHAVIOUR_END_AM = 'end.am' class SRv6(object): @@ -42,7 +48,8 @@ class SRv6(object): @staticmethod def configure_sr_localsid(node, local_sid, behavior, interface=None, - next_hop=None, fib_table=None): + next_hop=None, fib_table=None, out_if=None, + in_if=None, src_addr=None, sid_list=None): """Create SRv6 LocalSID and binds it to a particular behaviour on the given node. @@ -55,12 +62,27 @@ class SRv6(object): xconnects). :param fib_table: FIB table for IPv4/IPv6 lookup (Optional, required for L3 routing). + :param out_if: Interface name of local interface for sending traffic + towards the Service Function (Optional, required for SRv6 endpoint + to SR-unaware appliance). + :param in_if: Interface name of local interface receiving the traffic + coming back from the Service Function (Optional, required for SRv6 + endpoint to SR-unaware appliance). + :param src_addr: Source address on the packets coming back on in_if + interface (Optional, required for SRv6 endpoint to SR-unaware + appliance via static proxy). + :param sid_list: SID list (Optional, required for SRv6 endpoint to + SR-unaware appliance via static proxy). :type node: dict :type local_sid: str :type behavior: str :type interface: str :type next_hop: int :type fib_table: str + :type out_if: str + :type in_if: str + :type src_addr: str + :type sid_list: list :raises ValueError: If unsupported SRv6 LocalSID function used or required parameter is missing. """ @@ -69,20 +91,36 @@ class SRv6(object): elif behavior in [SRV6BEHAVIOUR_END_X, SRV6BEHAVIOUR_END_DX4, SRV6BEHAVIOUR_END_DX6]: if interface is None or next_hop is None: - raise ValueError('Required data missing.\ninterface:{0}\n' - 'next_hop:{1}'.format(interface, next_hop)) + raise ValueError('Required parameter(s) missing.\ninterface:{0}' + '\nnext_hop:{1}'.format(interface, next_hop)) interface_name = Topology.get_interface_name(node, interface) params = '{0} {1}'.format(interface_name, next_hop) elif behavior == SRV6BEHAVIOUR_END_DX2: if interface is None: - raise ValueError('Required data missing.\ninterface:{0}\n'. + raise ValueError('Required parameter missing.\ninterface:{0}'. format(interface)) params = '{0}'.format(interface) elif behavior in [SRV6BEHAVIOUR_END_DT4, SRV6BEHAVIOUR_END_DT6]: if fib_table is None: - raise ValueError('Required data missing.\nfib_table:{0}\n'. + raise ValueError('Required parameter missing.\nfib_table: {0}'. format(fib_table)) params = '{0}'.format(fib_table) + elif behavior == SRV6BEHAVIOUR_END_AS: + if next_hop is None or out_if is None or in_if is None or \ + src_addr is None or sid_list is None: + raise ValueError('Required parameter(s) missing.\nnext_hop:{0}' + '\nout_if:{1}\nin_if:{2}\nsrc_addr:{3}\n' + 'sid_list:{4}'.format(next_hop, out_if, in_if, + src_addr, sid_list)) + sid_conf = 'next ' + ' next '.join(sid_list) + params = 'nh {0} oif {1} iif {2} src {3} {4}'.\ + format(next_hop, out_if, in_if, src_addr, sid_conf) + elif behavior in [SRV6BEHAVIOUR_END_AD, SRV6BEHAVIOUR_END_AM]: + if next_hop is None or out_if is None or in_if is None: + raise ValueError('Required parameter(s) missing.\nnext_hop:{0}' + '\nout_if:{1}\nin_if:{2}'. + format(next_hop, out_if, in_if)) + params = 'nh {0} oif {1} iif {2}'.format(next_hop, out_if, in_if) else: raise ValueError('Unsupported SRv6 LocalSID function: {0}'. format(behavior)) @@ -217,9 +255,13 @@ class SRv6(object): vat.vat_terminal_exec_cmd_from_template( 'srv6/sr_steer_add_del.vat', params=params, bsid=bsid) - if "exec error: Misc" in vat.vat_stdout: - raise RuntimeError('Create SRv6 steering policy for BindingSID {0}' - ' failed on node {1}'.format(bsid, node['host'])) + sr_steer_errors = ("exec error: Misc", + "sr steer: No SR policy specified") + for err in sr_steer_errors: + if err in vat.vat_stdout: + raise RuntimeError('Create SRv6 steering policy for BindingSID' + ' {0} failed on node {1}'. + format(bsid, node['host'])) @staticmethod def delete_sr_steer(node, mode, bsid, interface=None, ip_addr=None, diff --git a/resources/libraries/python/Trace.py b/resources/libraries/python/Trace.py index c61a8deda4..10a55ce140 100644 --- a/resources/libraries/python/Trace.py +++ b/resources/libraries/python/Trace.py @@ -13,7 +13,7 @@ """Packet trace library.""" -from resources.libraries.python.VatExecutor import VatExecutor +from resources.libraries.python.VatExecutor import VatExecutor, VatTerminal from resources.libraries.python.topology import NodeType @@ -21,16 +21,21 @@ class Trace(object): """This class provides methods to manipulate the VPP packet trace.""" @staticmethod - def show_packet_trace_on_all_duts(nodes): + def show_packet_trace_on_all_duts(nodes, maximum=None): """Show VPP packet trace. :param nodes: Nodes from which the packet trace will be displayed. + :param maximum: Maximum number of packet traces to be displayed. :type nodes: list + :type maximum: int """ + maximum = "max {count}".format(count=maximum) if maximum is not None\ + else "" for node in nodes.values(): if node['type'] == NodeType.DUT: - vat = VatExecutor() - vat.execute_script("show_trace.vat", node, json_out=False) + with VatTerminal(node, json_param=False) as vat: + vat.vat_terminal_exec_cmd_from_template( + 'show_trace.vat', maximum=maximum) @staticmethod def clear_packet_trace_on_all_duts(nodes): -- cgit 1.2.3-korg