X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FDPDK%2FDPDKTools.py;h=b6c351f3c2d0d6218d2154f59f32be0c941b73d5;hp=b0e67b7ab83608a3aa64024a0271283578d0939e;hb=481c98ddaaaee4559977b0d601083391a44f1a18;hpb=5e7be479eacd4d1085cab152c35dcb6433a146ed diff --git a/resources/libraries/python/DPDK/DPDKTools.py b/resources/libraries/python/DPDK/DPDKTools.py index b0e67b7ab8..b6c351f3c2 100644 --- a/resources/libraries/python/DPDK/DPDKTools.py +++ b/resources/libraries/python/DPDK/DPDKTools.py @@ -14,8 +14,10 @@ """This module implements initialization and cleanup of DPDK environment.""" -from resources.libraries.python.ssh import SSH -from resources.libraries.python.constants import Constants +from robot.api import logger + +from resources.libraries.python.ssh import SSH, exec_cmd_no_error +from resources.libraries.python.Constants import Constants from resources.libraries.python.topology import NodeType, Topology @@ -89,5 +91,42 @@ class DPDKTools(object): ret_code, _, _ = ssh.exec_command_sudo(cmd, timeout=600) if ret_code != 0: - raise RuntimeError('Failed to cleanup the dpdk at node {name}' - .format(name=dut_node['host'])) + raise RuntimeError('Failed to cleanup the dpdk at node {name}'. + format(name=dut_node['host'])) + + @staticmethod + def install_dpdk_test(node): + """ + Prepare the DPDK test environment + + :param node: Dictionary created from topology + :type node: dict + :returns: nothing + :raises RuntimeError: If command returns nonzero return code. + """ + arch = Topology.get_node_arch(node) + + command = ('{fwdir}/tests/dpdk/dpdk_scripts/install_dpdk.sh {arch}'. + format(fwdir=Constants.REMOTE_FW_DIR, arch=arch)) + message = 'Install the DPDK failed!' + exec_cmd_no_error(node, command, timeout=600, message=message) + + command = ('cat {fwdir}/download_dir/dpdk*/VERSION'. + format(fwdir=Constants.REMOTE_FW_DIR)) + message = 'Get DPDK version failed!' + stdout, _ = exec_cmd_no_error(node, command, message=message) + + logger.info('DPDK Version: {version}'.format(version=stdout)) + + @staticmethod + def install_dpdk_test_on_all_duts(nodes): + """ + Prepare the DPDK test environment on all DUTs. + + :param nodes: Nodes from topology file. + :type nodes: dict + :returns: nothing + """ + for node in nodes.values(): + if node['type'] == NodeType.DUT: + DPDKTools.install_dpdk_test(node)