diff options
author | 2015-12-20 00:07:44 +0200 | |
---|---|---|
committer | 2015-12-20 00:07:44 +0200 | |
commit | 4ca24cf31919870a684fe78f17c856e0d220e6d5 (patch) | |
tree | f40ab95e52adca3ac713d61eb9fa3fd0d136e4ea /scripts/automation/trex_control_plane/server | |
parent | 1895d21485621c3428d045fa0f5b9daf165c8260 (diff) | |
parent | 5cef472bcdc6c0b7e20e5cc42485ed5570c10f8c (diff) |
Merge branch 'master' into dan_stateless
Diffstat (limited to 'scripts/automation/trex_control_plane/server')
3 files changed, 20 insertions, 20 deletions
diff --git a/scripts/automation/trex_control_plane/server/extended_daemon_runner.py b/scripts/automation/trex_control_plane/server/extended_daemon_runner.py index 734fa22e..7bc25aac 100755 --- a/scripts/automation/trex_control_plane/server/extended_daemon_runner.py +++ b/scripts/automation/trex_control_plane/server/extended_daemon_runner.py @@ -19,7 +19,6 @@ def daemonize_parser(parser_obj, action_funcs, help_menu): parser_obj.usage = None
parser_obj.add_argument("action", choices=action_funcs,
action="store", help=help_menu)
- return
class ExtendedDaemonRunner(runner.DaemonRunner):
@@ -76,7 +75,12 @@ class ExtendedDaemonRunner(runner.DaemonRunner): self.app = app
self.daemon_context = daemon.DaemonContext()
self.daemon_context.stdin = open(app.stdin_path, 'rt')
- self.daemon_context.stdout = open(app.stdout_path, 'w+t')
+ try:
+ self.daemon_context.stdout = open(app.stdout_path, 'w+t')
+ except IOError as err:
+ # catch 'tty' error when launching server from remote location
+ app.stdout_path = "/dev/null"
+ self.daemon_context.stdout = open(app.stdout_path, 'w+t')
self.daemon_context.stderr = open(app.stderr_path,
'a+t', buffering=0)
diff --git a/scripts/automation/trex_control_plane/server/trex_daemon_server.py b/scripts/automation/trex_control_plane/server/trex_daemon_server.py index ec07cb8a..9784d42a 100755 --- a/scripts/automation/trex_control_plane/server/trex_daemon_server.py +++ b/scripts/automation/trex_control_plane/server/trex_daemon_server.py @@ -57,15 +57,7 @@ def main (): print "Launching user must have sudo privileges in order to run TRex daemon.\nTerminating daemon process." exit(-1) - try: - daemon_runner = ExtendedDaemonRunner(trex_app, trex_parser) - except IOError as err: - # catch 'tty' error when launching server from remote location - if err.errno == errno.ENXIO: - trex_app.stdout_path = "/dev/null" - daemon_runner = ExtendedDaemonRunner(trex_app, trex_parser) - else: - raise + daemon_runner = ExtendedDaemonRunner(trex_app, trex_parser) #This ensures that the logger file handle does not get closed during daemonization daemon_runner.daemon_context.files_preserve=[handler.stream] diff --git a/scripts/automation/trex_control_plane/server/trex_server.py b/scripts/automation/trex_control_plane/server/trex_server.py index 7dee89e9..bf788d35 100755 --- a/scripts/automation/trex_control_plane/server/trex_server.py +++ b/scripts/automation/trex_control_plane/server/trex_server.py @@ -26,6 +26,7 @@ from trex_launch_thread import AsynchronousTRexSession from zmq_monitor_thread import ZmqMonitorSession from argparse import ArgumentParser, RawTextHelpFormatter from json import JSONEncoder +import re # setup the logger @@ -167,15 +168,17 @@ class CTRexServer(object): logger.info("Processing get_trex_daemon_log() command.") return self._pull_file('/var/log/trex/trex_daemon_server.log') - # get Trex version from ./t-rex-64 --help (last 4 lines) + # get Trex version from ./t-rex-64 --help (last lines starting with "Version : ...") def get_trex_version (self, base64 = True): try: logger.info("Processing get_trex_version() command.") if not self.trex_version: help_print = subprocess.Popen(['./t-rex-64', '--help'], cwd = self.TREX_PATH, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - help_print.wait() - help_print_stdout = help_print.stdout.read() - self.trex_version = binascii.b2a_base64('\n'.join(help_print_stdout.split('\n')[-5:-1])) + (stdout, stderr) = help_print.communicate() + search_result = re.search('\n\s*(Version\s*:.+)', stdout, re.DOTALL) + if not search_result: + raise Exception('Could not determine version from ./t-rex-64 --help') + self.trex_version = binascii.b2a_base64(search_result.group(1)) if base64: return self.trex_version else: @@ -256,7 +259,7 @@ class CTRexServer(object): return False - def start_trex(self, trex_cmd_options, user, block_to_success = True, timeout = 30): + def start_trex(self, trex_cmd_options, user, block_to_success = True, timeout = 40): with self.start_lock: logger.info("Processing start_trex() command.") if self.is_reserved(): @@ -340,11 +343,12 @@ class CTRexServer(object): Parameters ---------- - trex_cmd_options : str - Defines the exact command to run on the t-rex - Example: "-c 2 -m 0.500000 -d 100 -f cap2/sfr.yaml --nc -p -l 1000" + kwargs: dictionary + Dictionary of parameters for trex. For example: (c=1, nc=True, l_pkt_mode=3). + Notice that when sending command line parameters that has -, you need to replace it with _. + for example, to have on command line "--l-pkt-mode 3", you need to send l_pkt_mode=3 export_path : str - a full system path to which the results of the trex-run will be logged. + Full system path to which the results of the trex-run will be logged. """ if 'results_file_path' in kwargs: |