- pci_address1 = Topology.get_interface_pci_addr(dut_node, dut_if1)
- if1_driver = Topology.get_interface_driver(dut_node, dut_if1)
- pci_address2 = Topology.get_interface_pci_addr(dut_node, dut_if2)
- if2_driver = Topology.get_interface_driver(dut_node, dut_if2)
-
- ssh = SSH()
- ssh.connect(dut_node)
-
- cmd = 'cd {0}/tests/dpdk/dpdk_scripts/ && sudo ./cleanup_dpdk.sh ' \
- '{1} {2} {3} {4}'.format(con.REMOTE_FW_DIR, if1_driver,
- pci_address1, if2_driver, pci_address2)
-
- (ret_code, _, _) = ssh.exec_command(cmd, timeout=600)
- if ret_code != 0:
- raise RuntimeError('Failed to cleanup the dpdk at node {0}'
- .format(dut_node['host']))
+ if dut_node['type'] == NodeType.DUT:
+ pci_address1 = Topology.get_interface_pci_addr(dut_node, dut_if1)
+ if1_driver = Topology.get_interface_driver(dut_node, dut_if1)
+ pci_address2 = Topology.get_interface_pci_addr(dut_node, dut_if2)
+ if2_driver = Topology.get_interface_driver(dut_node, dut_if2)
+
+ ssh = SSH()
+ ssh.connect(dut_node)
+
+ cmd = '{fwdir}/tests/dpdk/dpdk_scripts/cleanup_dpdk.sh ' \
+ '{drv1} {pci1} {drv2} {pci2}'.\
+ format(fwdir=Constants.REMOTE_FW_DIR, drv1=if1_driver,
+ pci1=pci_address1, drv2=if2_driver, pci2=pci_address2)
+
+ 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']))
+
+ @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)