+ @staticmethod
+ def _run_cli_cmd(node, cmd, log=True):
+ """Run a CLI command.
+
+ :param node: Node to run command on.
+ :param cmd: The CLI command to be run on the node.
+ :param log: If True, the response is logged.
+ :type node: dict
+ :type cmd: str
+ :type log: bool
+ :returns: Verified data from PAPI response.
+ :rtype: dict
+ """
+ cli = 'cli_inband'
+ args = dict(cmd=cmd)
+ err_msg = "Failed to run 'cli_inband {cmd}' PAPI command on host " \
+ "{host}".format(host=node['host'], cmd=cmd)
+
+ with PapiExecutor(node) as papi_exec:
+ data = papi_exec.add(cli, **args).get_replies(err_msg). \
+ verify_reply(err_msg=err_msg)
+
+ if log:
+ logger.info("{cmd}:\n{data}".format(cmd=cmd, data=data["reply"]))
+
+ return data
+
+ @staticmethod
+ def _get_non_zero_items(data):
+ """Extract and return non-zero items from the input data.
+
+ :param data: Data to filter.
+ :type data: dict
+ :returns: Dictionary with non-zero items.
+ :rtype dict
+ """
+ return {k: data[k] for k in data.keys() if sum(data[k])}
+
+ @staticmethod
+ def vpp_show_errors(node):
+ """Run "show errors" debug CLI command.
+
+ :param node: Node to run command on.
+ :type node: dict
+ """
+ VppCounters._run_cli_cmd(node, 'show errors')
+
+ @staticmethod
+ def vpp_show_errors_verbose(node):
+ """Run "show errors verbose" debug CLI command.
+
+ :param node: Node to run command on.
+ :type node: dict
+ """
+ VppCounters._run_cli_cmd(node, 'show errors verbose')
+
+ @staticmethod
+ def vpp_show_errors_on_all_duts(nodes, verbose=False):
+ """Show errors on all DUTs.
+
+ :param nodes: VPP nodes.
+ :param verbose: If True show verbose output.
+ :type nodes: dict
+ :type verbose: bool
+ """
+ for node in nodes.values():
+ if node['type'] == NodeType.DUT:
+ if verbose:
+ VppCounters.vpp_show_errors_verbose(node)
+ else:
+ VppCounters.vpp_show_errors(node)
+
+ @staticmethod
+ def vpp_show_runtime(node, log_zeros=False):
+ """Run "show runtime" CLI command.
+
+ :param node: Node to run command on.
+ :param log_zeros: Log also items with zero values.
+ :type node: dict
+ :type log_zeros: bool
+ """
+ args = dict(path='^/sys/node')
+ with PapiExecutor(node) as papi_exec:
+ stats = papi_exec.add("vpp-stats", **args).get_stats()[0]
+
+ names = stats['/sys/node/names']
+
+ if not names:
+ return
+
+ runtime = []
+ runtime_non_zero = []
+
+ for name in names:
+ runtime.append({'name': name})
+
+ for idx, runtime_item in enumerate(runtime):
+
+ calls_th = []
+ for thread in stats['/sys/node/calls']:
+ calls_th.append(thread[idx])
+ runtime_item["calls"] = calls_th
+
+ vectors_th = []
+ for thread in stats['/sys/node/vectors']:
+ vectors_th.append(thread[idx])
+ runtime_item["vectors"] = vectors_th
+
+ suspends_th = []
+ for thread in stats['/sys/node/suspends']:
+ suspends_th.append(thread[idx])
+ runtime_item["suspends"] = suspends_th
+
+ clocks_th = []
+ for thread in stats['/sys/node/clocks']:
+ clocks_th.append(thread[idx])
+ runtime_item["clocks"] = clocks_th
+
+ if (sum(calls_th) or sum(vectors_th) or
+ sum(suspends_th) or sum(clocks_th)):
+ runtime_non_zero.append(runtime_item)
+
+ if log_zeros:
+ logger.info("Runtime:\n{runtime}".format(
+ runtime=pformat(runtime)))
+ else:
+ logger.info("Runtime:\n{runtime}".format(
+ runtime=pformat(runtime_non_zero)))
+
+ @staticmethod
+ def vpp_show_runtime_verbose(node):
+ """Run "show runtime verbose" CLI command.
+
+ TODO: Remove?
+ Only verbose output is possible to get using VPPStats.
+
+ :param node: Node to run command on.
+ :type node: dict
+ """
+ VppCounters.vpp_show_runtime(node)
+
+ @staticmethod
+ def show_runtime_counters_on_all_duts(nodes):
+ """Clear VPP runtime counters on all DUTs.
+
+ :param nodes: VPP nodes.
+ :type nodes: dict
+ """
+ for node in nodes.values():
+ if node['type'] == NodeType.DUT:
+ VppCounters.vpp_show_runtime(node)
+
+ @staticmethod
+ def vpp_show_hardware_detail(node):
+ """Run "show hardware-interfaces detail" debug CLI command.