commit f7daa79818bfdae1bd664cee1877b18c8dea8ec8
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Wed Jul 17 14:09:44 2013 +0200
NetTestSlave: add kill_command method
The new method will kill the command with a specified id. The id is
either the bg_id of the command or None for foreground
commands, which makes the id a unique identifier. This method will be
used to forcefully kill a running command that has timed out.
This commit also modifies the message logged when killing a command.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Common/NetTestCommand.py | 5 ++++-
lnst/Slave/NetTestSlave.py | 6 ++++++
2 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/lnst/Common/NetTestCommand.py b/lnst/Common/NetTestCommand.py
index 8dc9562..1c34c70 100644
--- a/lnst/Common/NetTestCommand.py
+++ b/lnst/Common/NetTestCommand.py
@@ -147,7 +147,10 @@ class NetTestCommand:
def kill(self):
if os.path.exists("/proc/%d" % self._pid):
- logging.debug("Killing background command with id \"%s\", pid
\"%d\"" % (self._id, self._pid))
+ if self._id:
+ logging.debug("Killing background command with id \"%s\",
pid \"%d\"" % (self._id, self._pid))
+ else:
+ logging.debug("Killing command with pid \"%d\"" %
self._pid)
self._killed = True
os.killpg(os.getpgid(self._pid), signal.SIGKILL)
self._process.join()
diff --git a/lnst/Slave/NetTestSlave.py b/lnst/Slave/NetTestSlave.py
index 7f20b08..77ad679 100644
--- a/lnst/Slave/NetTestSlave.py
+++ b/lnst/Slave/NetTestSlave.py
@@ -233,6 +233,12 @@ class SlaveMethods:
return res
+ def kill_command(self, id):
+ cmd = self._command_context.get_cmd(id)
+ cmd.kill()
+ self._command_context.del_cmd(cmd)
+ return True
+
def machine_cleanup(self):
NetConfigDeviceAllCleanup(self._config)
self._netconfig.cleanup()
Show replies by date