X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FVPPUtil.py;h=72b61423067838c9f238617fe981f8c5a1ba43b4;hb=3ccfe8cdb3d94182e365f4bfacefbb52fb32cb93;hp=8b7b6891acf2d5cf107d1406d22245a995328a6e;hpb=ceb9df53e2eabc380f1c942c39f2117102742e2a;p=csit.git diff --git a/resources/libraries/python/VPPUtil.py b/resources/libraries/python/VPPUtil.py index 8b7b6891ac..72b6142306 100644 --- a/resources/libraries/python/VPPUtil.py +++ b/resources/libraries/python/VPPUtil.py @@ -17,7 +17,6 @@ from robot.api import logger from resources.libraries.python.Constants import Constants from resources.libraries.python.DUTSetup import DUTSetup -from resources.libraries.python.L2Util import L2Util from resources.libraries.python.PapiExecutor import PapiSocketExecutor from resources.libraries.python.ssh import exec_cmd_no_error from resources.libraries.python.topology import NodeType @@ -113,6 +112,10 @@ class VPPUtil(object): :param node: Topology node. :type node: dict """ + cmd = 'echo "show pci" | sudo socat - UNIX-CONNECT:/run/vpp/cli.sock' + exec_cmd_no_error( + node, cmd, sudo=False, message='VPP failed to start!', retries=120) + cmd = ('vppctl show pci 2>&1 | ' 'fgrep -v "Connection refused" | ' 'fgrep -v "No such file or directory"') @@ -161,8 +164,9 @@ class VPPUtil(object): :returns: VPP version. :rtype: str """ + cmd = 'show_version' with PapiSocketExecutor(node) as papi_exec: - reply = papi_exec.add('show_version').get_reply() + reply = papi_exec.add(cmd).get_reply() return_version = reply['version'].rstrip('\0x00') version = 'VPP version: {ver}\n'.format(ver=return_version) if verbose: @@ -193,16 +197,25 @@ class VPPUtil(object): """ cmd = 'sw_interface_dump' - args = dict(name_filter_valid=0, name_filter='') + args = dict( + name_filter_valid=False, + name_filter='' + ) err_msg = 'Failed to get interface dump on host {host}'.format( host=node['host']) with PapiSocketExecutor(node) as papi_exec: details = papi_exec.add(cmd, **args).get_details(err_msg) for if_dump in details: - if_dump['interface_name'] = if_dump['interface_name'].rstrip('\x00') - if_dump['tag'] = if_dump['tag'].rstrip('\x00') - if_dump['l2_address'] = L2Util.bin_to_mac(if_dump['l2_address']) + if_dump['l2_address'] = str(if_dump['l2_address']) + if_dump['b_dmac'] = str(if_dump['b_dmac']) + if_dump['b_smac'] = str(if_dump['b_smac']) + if_dump['flags'] = if_dump['flags'].value + if_dump['type'] = if_dump['type'].value + if_dump['link_duplex'] = if_dump['link_duplex'].value + if_dump['sub_if_flags'] = if_dump['sub_if_flags'].value \ + if hasattr(if_dump['sub_if_flags'], 'value') \ + else int(if_dump['sub_if_flags']) # TODO: return only base data logger.trace('Interface data of host {host}:\n{details}'.format( host=node['host'], details=details)) @@ -246,10 +259,10 @@ class VPPUtil(object): VPPUtil.vpp_enable_traces_on_dut(node, fail_on_error) @staticmethod - def vpp_enable_elog_traces_on_dut(node): - """Enable API/CLI/Barrier traces on the DUT node. + def vpp_enable_elog_traces(node): + """Enable API/CLI/Barrier traces on the specified topology node. - :param node: DUT node to set up. + :param node: Topology node. :type node: dict """ PapiSocketExecutor.run_cli_cmd(node, "elog trace api cli barrier") @@ -263,13 +276,13 @@ class VPPUtil(object): """ for node in nodes.values(): if node['type'] == NodeType.DUT: - VPPUtil.vpp_enable_elog_traces_on_dut(node) + VPPUtil.vpp_enable_elog_traces(node) @staticmethod - def show_event_logger_on_dut(node): - """Show event logger on the DUT node. + def show_event_logger(node): + """Show event logger on the specified topology node. - :param node: DUT node to show traces on. + :param node: Topology node. :type node: dict """ PapiSocketExecutor.run_cli_cmd(node, "show event-logger") @@ -283,18 +296,27 @@ class VPPUtil(object): """ for node in nodes.values(): if node['type'] == NodeType.DUT: - VPPUtil.show_event_logger_on_dut(node) + VPPUtil.show_event_logger(node) @staticmethod def show_log(node): - """Show log on the specified topology node. + """Show logging on the specified topology node. :param node: Topology node. :type node: dict - :returns: VPP log data. - :rtype: list """ - return PapiSocketExecutor.run_cli_cmd(node, "show log") + PapiSocketExecutor.run_cli_cmd(node, "show logging") + + @staticmethod + def show_log_on_all_duts(nodes): + """Show logging on all DUTs in the given topology. + + :param nodes: Nodes in the topology. + :type nodes: dict + """ + for node in nodes.values(): + if node['type'] == NodeType.DUT: + VPPUtil.show_log(node) @staticmethod def vpp_show_threads(node): @@ -305,8 +327,9 @@ class VPPUtil(object): :returns: VPP thread data. :rtype: list """ + cmd = 'show_threads' with PapiSocketExecutor(node) as papi_exec: - reply = papi_exec.add('show_threads').get_reply() + reply = papi_exec.add(cmd).get_reply() threads_data = list() for thread in reply["thread_data"]: @@ -317,6 +340,6 @@ class VPPUtil(object): thread_data.append(item) threads_data.append(thread_data) - logger.info("show threads:\n{threads}".format(threads=threads_data)) + logger.trace("show threads:\n{threads}".format(threads=threads_data)) return threads_data