X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FDPDK%2FDPDKTools.py;h=25d221772cfc74fa19928184f484d6ceb3259a95;hb=da799981f5373b09398319df12e77e2efc75caa6;hp=a256ae5ddc98d17e63ca7b9a8dcb41c01c87a11b;hpb=0f585d16c7f9c0425ae17544ce9c688cb7f6998b;p=csit.git diff --git a/resources/libraries/python/DPDK/DPDKTools.py b/resources/libraries/python/DPDK/DPDKTools.py index a256ae5ddc..25d221772c 100644 --- a/resources/libraries/python/DPDK/DPDKTools.py +++ b/resources/libraries/python/DPDK/DPDKTools.py @@ -15,7 +15,7 @@ """This module implements initialization and cleanup of DPDK environment.""" from resources.libraries.python.ssh import SSH -from resources.libraries.python.constants import Constants +from resources.libraries.python.Constants import Constants from resources.libraries.python.topology import NodeType, Topology @@ -37,7 +37,6 @@ class DPDKTools(object): :type dut_node: dict :type dut_if1: str :type dut_if2: str - :returns: none :raises RuntimeError: If it fails to bind the interfaces to igb_uio. """ if dut_node['type'] == NodeType.DUT: @@ -72,7 +71,6 @@ class DPDKTools(object): :type dut_node: dict :type dut_if1: str :type dut_if2: str - :returns: none :raises RuntimeError: If it fails to cleanup the dpdk. """ if dut_node['type'] == NodeType.DUT: @@ -91,5 +89,40 @@ 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) + + ssh = SSH() + ssh.connect(node) + + ret_code, _, _ = ssh.exec_command( + '{fwdir}/tests/dpdk/dpdk_scripts/install_dpdk.sh {arch}'. + format(fwdir=Constants.REMOTE_FW_DIR, arch=arch), timeout=600) + + if ret_code != 0: + raise RuntimeError('Install the DPDK failed') + + @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)