diff options
author | Mark Beierl <mark.beierl@emc.com> | 2016-04-26 13:18:23 -0400 |
---|---|---|
committer | Mark Beierl <mark.beierl@emc.com> | 2016-04-26 13:42:25 -0400 |
commit | 7617c6f079a2926c5d0640c40801fa5cb14023ee (patch) | |
tree | 1b8228f87a7afd090782e2dd4e3eb6d36fad85bd /storperf/fio/fio_invoker.py | |
parent | 311eee3bec00d5acc32b6eba76a7ff0d1990f4b2 (diff) |
Cancel Job API
Add the ability to terminate a running job via the API
JIRA: STORPERF-20
Change-Id: I73a701cff9712207f5e14cfcc6b8fb7e0ab59aed
Signed-off-by: Mark Beierl <mark.beierl@emc.com>
Diffstat (limited to 'storperf/fio/fio_invoker.py')
-rw-r--r-- | storperf/fio/fio_invoker.py | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/storperf/fio/fio_invoker.py b/storperf/fio/fio_invoker.py index fad2546..4f39eb7 100644 --- a/storperf/fio/fio_invoker.py +++ b/storperf/fio/fio_invoker.py @@ -7,10 +7,10 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -from threading import Thread import json import logging import subprocess +from threading import Thread class FIOInvoker(object): @@ -88,11 +88,35 @@ class FIOInvoker(object): stderr=subprocess.PIPE) t = Thread(target=self.stdout_handler, args=()) - t.daemon = False + t.daemon = True t.start() t = Thread(target=self.stderr_handler, args=()) - t.daemon = False + t.daemon = True t.start() + self.logger.debug("Started fio on " + self.remote_host) t.join() + self.logger.debug("Finished fio on " + self.remote_host) + + def terminate(self): + self.logger.debug("Terminating fio on " + self.remote_host) + cmd = ['ssh', '-o', 'StrictHostKeyChecking=no', + '-i', 'storperf/resources/ssh/storperf_rsa', + 'storperf@' + self.remote_host, + 'sudo', 'killall', '-9', 'fio'] + + kill_process = subprocess.Popen(cmd, + universal_newlines=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + + for line in iter(kill_process.stdout.readline, b''): + self.logger.debug("FIO Termination: " + line) + + kill_process.stdout.close() + + for line in iter(kill_process.stderr.readline, b''): + self.logger.debug("FIO Termination: " + line) + + kill_process.stderr.close() |