X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FVPPUtil.py;h=3714d3b7805bbd24aaac72ab44b969fdd4f3f798;hb=ada7009a3c826430e83a29c31bdf9a5973986ad9;hp=de3caad916ae8cbd594f39cb5e27d905bc228bcb;hpb=5f7c2bc0f96747dcd37c59971a58f8b838ac2eb8;p=csit.git diff --git a/resources/libraries/python/VPPUtil.py b/resources/libraries/python/VPPUtil.py index de3caad916..3714d3b780 100644 --- a/resources/libraries/python/VPPUtil.py +++ b/resources/libraries/python/VPPUtil.py @@ -12,9 +12,12 @@ # limitations under the License. """VPP util library.""" + +import time + from resources.libraries.python.constants import Constants from resources.libraries.python.DUTSetup import DUTSetup -from resources.libraries.python.ssh import exec_cmd_no_error +from resources.libraries.python.ssh import exec_cmd, exec_cmd_no_error from resources.libraries.python.topology import NodeType from resources.libraries.python.VatExecutor import VatExecutor @@ -52,14 +55,27 @@ class VPPUtil(object): exec_cmd_no_error(node, command, timeout=30, sudo=True) @staticmethod - def start_vpp_service(node): + def start_vpp_service(node, retries=60): """Start VPP service on the specified node. :param node: VPP node. + :param retries: Number of times (default 60) to re-try waiting. :type node: dict + :type retries: int :raises RuntimeError: If VPP service fails to start. """ DUTSetup.start_service(node, Constants.VPP_UNIT) + # Sleep 1 second, up to times, + # and verify if VPP is running. + for _ in range(retries): + time.sleep(1) + command = 'vppctl show pci' + ret, stdout, _ = exec_cmd(node, command, timeout=30, sudo=True) + if not ret and 'Connection refused' not in stdout: + break + else: + raise RuntimeError('VPP failed to start on host {name}'. + format(name=node['host'])) DUTSetup.get_service_logs(node, Constants.VPP_UNIT) @staticmethod @@ -69,7 +85,9 @@ class VPPUtil(object): :param nodes: Nodes in the topology. :type nodes: dict """ - DUTSetup.start_service_on_all_duts(nodes, Constants.VPP_UNIT) + for node in nodes.values(): + if node['type'] == NodeType.DUT: + VPPUtil.start_vpp_service(node) @staticmethod def stop_vpp_service(node): @@ -81,6 +99,17 @@ class VPPUtil(object): """ DUTSetup.stop_service(node, Constants.VPP_UNIT) + @staticmethod + def stop_vpp_service_on_all_duts(nodes): + """Stop VPP service on all nodes. + + :param nodes: Nodes in the topology. + :type nodes: dict + """ + for node in nodes.values(): + if node['type'] == NodeType.DUT: + VPPUtil.stop_vpp_service(node) + @staticmethod def verify_vpp_on_dut(node): """Verify that VPP is installed on DUT node. @@ -102,9 +131,8 @@ class VPPUtil(object): """ for node in nodes.values(): if node['type'] == NodeType.DUT: - DUTSetup.start_service(node, Constants.VPP_UNIT) - VPPUtil.vpp_show_version_verbose(node) - VPPUtil.vpp_show_interfaces(node) + VPPUtil.start_vpp_service(node) + VPPUtil.verify_vpp_on_dut(node) @staticmethod def vpp_show_version_verbose(node): @@ -202,3 +230,46 @@ class VPPUtil(object): for node in nodes.values(): if node['type'] == NodeType.DUT: VPPUtil.vpp_enable_traces_on_dut(node) + + @staticmethod + def vpp_enable_elog_traces_on_dut(node): + """Enable API/CLI/Barrier traces on the DUT node. + + :param node: DUT node to set up. + :type node: dict + """ + vat = VatExecutor() + vat.execute_script("elog_trace_api_cli_barrier.vat", node, + json_out=False) + + @staticmethod + def vpp_enable_elog_traces_on_all_duts(nodes): + """Enable API/CLI/Barrier traces 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.vpp_enable_elog_traces_on_dut(node) + + @staticmethod + def show_event_logger_on_dut(node): + """Show event logger on the DUT node. + + :param node: DUT node to show traces on. + :type node: dict + """ + vat = VatExecutor() + vat.execute_script("show_event_logger.vat", node, json_out=False) + + @staticmethod + def show_event_logger_on_all_duts(nodes): + """Show event logger 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_event_logger_on_dut(node)