commit 86fa1afe97381a95940b80225b104133603a813e Author: Ondrej Lichtner olichtne@redhat.com Date: Tue Nov 27 08:20:19 2012 +0100
NetTestSlave: check if NetworkManager is running
This commit adds function check_process_running that checks if there is a process with a specified name running on the system.
This function is then used in the slaves rpc method hello() to check if NetworkManager is running. NetworkManager is know for causing problem s during automatic network testing when he interferes with the testing network interfaces. The slave now logs a warning message to point out these potential problems.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com
lnst/Common/Utils.py | 8 ++++++++ lnst/Slave/NetTestSlave.py | 7 +++++++ 2 files changed, 15 insertions(+), 0 deletions(-) --- diff --git a/lnst/Common/Utils.py b/lnst/Common/Utils.py index 00f7428..65d5902 100644 --- a/lnst/Common/Utils.py +++ b/lnst/Common/Utils.py @@ -15,6 +15,7 @@ import re import os import hashlib import tempfile +import subprocess from lnst.Common.ExecCmd import exec_cmd
def die_when_parent_die(): @@ -148,3 +149,10 @@ def has_changed_since(filepath, threshold): def _is_newer_than(f, threshold): stat = os.stat(f) return stat.st_mtime > threshold + +def check_process_running(process_name): + try: + proc = subprocess.check_call(["pgrep", process_name]) + return True + except subprocess.CalledProcessError: + return False diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py index 4106f2d..9d3a9d8 100644 --- a/lnst/Slave/NetTestSlave.py +++ b/lnst/Slave/NetTestSlave.py @@ -28,6 +28,7 @@ from lnst.Common.NetTestCommand import NetTestCommandContext from lnst.Common.NetTestCommand import CommandException, NetTestCommand from lnst.Slave.NetConfig import NetConfig from lnst.Slave.NetConfigDevice import NetConfigDeviceAllCleanup +from lnst.Common.Utils import check_process_running
DefaultRPCPort = 9999
@@ -53,6 +54,12 @@ class NetTestSlaveXMLRPC: self.clear_resource_table() self._cache.del_old_entries() self.reset_file_transfers() + + if check_process_running("NetworkManager"): + logging.error("=============================================") + logging.error("NetworkManager is running on a slave machine!") + logging.error("This might effect test results!") + logging.error("=============================================") return "hello"
def bye(self):