X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FDUTSetup.py;h=16acfba7adbc7de8bc14bea4a4ddf4267e907438;hb=HEAD;hp=a9b549a935c0133af8e11a26e2347b149d69a99b;hpb=fb731e12fc85bf225e8917fe068fcc357f9a2158;p=csit.git diff --git a/resources/libraries/python/DUTSetup.py b/resources/libraries/python/DUTSetup.py index a9b549a935..f9758c5f9f 100644 --- a/resources/libraries/python/DUTSetup.py +++ b/resources/libraries/python/DUTSetup.py @@ -16,7 +16,6 @@ from time import sleep from robot.api import logger -from resources.libraries.python.Constants import Constants from resources.libraries.python.ssh import exec_cmd, exec_cmd_no_error from resources.libraries.python.topology import NodeType, Topology @@ -35,11 +34,10 @@ class DUTSetup: """ if DUTSetup.running_in_container(node): return - else: - command = ( - f"journalctl --no-pager _SYSTEMD_INVOCATION_ID=$(systemctl " - f"show -p InvocationID --value {service})" - ) + command = ( + f"journalctl --no-pager _SYSTEMD_INVOCATION_ID=$(systemctl " + f"show -p InvocationID --value {service})" + ) message = f"Node {node[u'host']} failed to get logs from unit {service}" exec_cmd_no_error( @@ -300,19 +298,21 @@ class DUTSetup: return sriov_numvfs @staticmethod - def set_sriov_numvfs(node, pf_pci_addr, numvfs=0): + def set_sriov_numvfs(node, pf_pci_addr, path="devices", numvfs=0): """Init or reset SR-IOV virtual functions by setting its number on PCI device on DUT. Setting to zero removes all VFs. :param node: DUT node. :param pf_pci_addr: Physical Function PCI device address. + :param path: Either device or driver. :param numvfs: Number of VFs to initialize, 0 - removes the VFs. :type node: dict :type pf_pci_addr: str + :type path: str :type numvfs: int :raises RuntimeError: Failed to create VFs on PCI. """ - cmd = f"test -f /sys/bus/pci/devices/{pf_pci_addr}/sriov_numvfs" + cmd = f"test -f /sys/bus/pci/{path}/{pf_pci_addr}/sriov_numvfs" sriov_unsupported, _, _ = exec_cmd(node, cmd) # if sriov_numvfs doesn't exist, then sriov_unsupported != 0 if int(sriov_unsupported): @@ -328,7 +328,7 @@ class DUTSetup: pci = pf_pci_addr.replace(u":", r"\:") command = f"sh -c \"echo {numvfs} | " \ - f"tee /sys/bus/pci/devices/{pci}/sriov_numvfs\"" + f"tee /sys/bus/pci/{path}/{pci}/sriov_numvfs\"" message = f"Failed to create {numvfs} VFs on {pf_pci_addr} device " \ f"on {node[u'host']}"