X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Ftools%2Fscripts%2Ftopo_cleanup.py;h=89055944c54ccfa1c8ce0f88408c1b3f23a01263;hb=9d72674a76dc8e81a89fab1bf7ae255bdf4faea4;hp=bf4bdfc5572158f0a1d77ae09965e9f6c9412ca9;hpb=917abf9aec10dc3e8f55ae7f55e1fab1fc44475c;p=csit.git diff --git a/resources/tools/scripts/topo_cleanup.py b/resources/tools/scripts/topo_cleanup.py index bf4bdfc557..89055944c5 100755 --- a/resources/tools/scripts/topo_cleanup.py +++ b/resources/tools/scripts/topo_cleanup.py @@ -46,6 +46,7 @@ def execute_command_ssh(ssh, cmd, sudo=False): return ret, stdout, stdout + def uninstall_package(ssh, package): """If there are packages installed, clean them up. @@ -64,6 +65,7 @@ def uninstall_package(ssh, package): execute_command_ssh(ssh, 'apt-get purge -y "*{package}*"'.format( package=package), sudo=True) + def kill_process(ssh, process): """If there are running processes, kill them. @@ -126,9 +128,9 @@ def main(): for interface in topology[node]['interfaces']: pci = topology[node]['interfaces'][interface]['pci_address'] execute_command_ssh( - ssh, "ip link set " - "$(basename /sys/bus/pci/devices/{pci}/net/*) down". - format(pci=pci), sudo=True) + ssh, "[[ -d {path}/{pci}/net ]] && " + "sudo ip link set $(basename {path}/{pci}/net/*) down". + format(pci=pci, path='/sys/bus/pci/devices')) if __name__ == "__main__":