From 27a7103d501e9a0bf005d657cb3f7c51a72eca6b Mon Sep 17 00:00:00 2001 From: imarom Date: Thu, 26 Nov 2015 09:00:58 -0500 Subject: when connection is lost - identify this on the console --- .../trex_control_plane/console/trex_console.py | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'scripts/automation/trex_control_plane/console/trex_console.py') diff --git a/scripts/automation/trex_control_plane/console/trex_console.py b/scripts/automation/trex_control_plane/console/trex_console.py index 9e44daac..e537c306 100755 --- a/scripts/automation/trex_control_plane/console/trex_console.py +++ b/scripts/automation/trex_control_plane/console/trex_console.py @@ -210,6 +210,10 @@ class TRexConsole(TRexGeneralCmd): def do_ping (self, line): '''Ping the server\n''' + if not self.stateless_client.is_connected(): + print format_text("\nNot connected to server\n", 'bold') + return + rc = self.stateless_client.cmd_ping() if rc.bad(): return @@ -302,6 +306,10 @@ class TRexConsole(TRexGeneralCmd): def do_start(self, line): '''Start selected traffic in specified port(s) on TRex\n''' + if not self.stateless_client.is_connected(): + print format_text("\nNot connected to server\n", 'bold') + return + self.stateless_client.cmd_start_line(line) @@ -311,6 +319,11 @@ class TRexConsole(TRexGeneralCmd): ############# stop def do_stop(self, line): '''stops port(s) transmitting traffic\n''' + + if not self.stateless_client.is_connected(): + print format_text("\nNot connected to server\n", 'bold') + return + self.stateless_client.cmd_stop_line(line) def help_stop(self): @@ -319,6 +332,11 @@ class TRexConsole(TRexGeneralCmd): ############# update def do_update(self, line): '''update speed of port(s)currently transmitting traffic\n''' + + if not self.stateless_client.is_connected(): + print format_text("\nNot connected to server\n", 'bold') + return + self.stateless_client.cmd_update_line(line) def help_update (self): @@ -327,11 +345,21 @@ class TRexConsole(TRexGeneralCmd): ############# pause def do_pause(self, line): '''pause port(s) transmitting traffic\n''' + + if not self.stateless_client.is_connected(): + print format_text("\nNot connected to server\n", 'bold') + return + self.stateless_client.cmd_pause_line(line) ############# resume def do_resume(self, line): '''resume port(s) transmitting traffic\n''' + + if not self.stateless_client.is_connected(): + print format_text("\nNot connected to server\n", 'bold') + return + self.stateless_client.cmd_resume_line(line) @@ -339,6 +367,11 @@ class TRexConsole(TRexGeneralCmd): ########## reset def do_reset (self, line): '''force stop all ports\n''' + + if not self.stateless_client.is_connected(): + print format_text("\nNot connected to server\n", 'bold') + return + self.stateless_client.cmd_reset() -- cgit From a48cd6471a2d82e5d78e8abe85b065f66a388e11 Mon Sep 17 00:00:00 2001 From: imarom Date: Tue, 1 Dec 2015 03:46:21 -0500 Subject: 1. fixed ZMQ message limitation 2. added some scale yamls for IMIX (300 streams, 1000 streams) 3. return objects are always complex objects (not strings) - for backward compatability 4. some minor adjustments to ZMQ socket timeouts --- scripts/automation/trex_control_plane/console/trex_console.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/automation/trex_control_plane/console/trex_console.py') diff --git a/scripts/automation/trex_control_plane/console/trex_console.py b/scripts/automation/trex_control_plane/console/trex_console.py index e537c306..be8fb70e 100755 --- a/scripts/automation/trex_control_plane/console/trex_console.py +++ b/scripts/automation/trex_control_plane/console/trex_console.py @@ -372,7 +372,7 @@ class TRexConsole(TRexGeneralCmd): print format_text("\nNot connected to server\n", 'bold') return - self.stateless_client.cmd_reset() + self.stateless_client.cmd_reset_line(line) def help_events (self): -- cgit From a6af2a8e624c62d9a347215321c6562f28879d97 Mon Sep 17 00:00:00 2001 From: imarom Date: Thu, 3 Dec 2015 06:07:20 -0500 Subject: various fixes (each one is a minor one) --- .../trex_control_plane/console/trex_console.py | 65 ++++++++++------------ 1 file changed, 30 insertions(+), 35 deletions(-) (limited to 'scripts/automation/trex_control_plane/console/trex_console.py') diff --git a/scripts/automation/trex_control_plane/console/trex_console.py b/scripts/automation/trex_control_plane/console/trex_console.py index be8fb70e..73f4f612 100755 --- a/scripts/automation/trex_control_plane/console/trex_console.py +++ b/scripts/automation/trex_control_plane/console/trex_console.py @@ -35,7 +35,7 @@ from common.text_opts import * from client_utils.general_utils import user_input, get_current_user import trex_status import parsing_opts - +from functools import wraps __version__ = "1.1" @@ -128,6 +128,18 @@ class TRexConsole(TRexGeneralCmd): ################### internal section ######################## + def verify_connected(f): + @wraps(f) + def wrap(*args): + inst = args[0] + if not inst.stateless_client.is_connected(): + print format_text("\nNot connected to server\n", 'bold') + return + + ret = f(*args) + return ret + + return wrap def get_console_identifier(self): return "{context}_{server}".format(context=self.__class__.__name__, @@ -207,13 +219,9 @@ class TRexConsole(TRexGeneralCmd): ####################### shell commands ####################### + @verify_connected def do_ping (self, line): '''Ping the server\n''' - - if not self.stateless_client.is_connected(): - print format_text("\nNot connected to server\n", 'bold') - return - rc = self.stateless_client.cmd_ping() if rc.bad(): return @@ -303,13 +311,10 @@ class TRexConsole(TRexGeneralCmd): if (l > 2) and (s[l - 2] in file_flags): return TRexConsole.tree_autocomplete(s[l - 1]) + @verify_connected def do_start(self, line): '''Start selected traffic in specified port(s) on TRex\n''' - if not self.stateless_client.is_connected(): - print format_text("\nNot connected to server\n", 'bold') - return - self.stateless_client.cmd_start_line(line) @@ -317,64 +322,57 @@ class TRexConsole(TRexGeneralCmd): self.do_start("-h") ############# stop + @verify_connected def do_stop(self, line): '''stops port(s) transmitting traffic\n''' - if not self.stateless_client.is_connected(): - print format_text("\nNot connected to server\n", 'bold') - return - self.stateless_client.cmd_stop_line(line) def help_stop(self): self.do_stop("-h") ############# update + @verify_connected def do_update(self, line): '''update speed of port(s)currently transmitting traffic\n''' - if not self.stateless_client.is_connected(): - print format_text("\nNot connected to server\n", 'bold') - return - self.stateless_client.cmd_update_line(line) def help_update (self): self.do_update("-h") ############# pause + @verify_connected def do_pause(self, line): '''pause port(s) transmitting traffic\n''' - if not self.stateless_client.is_connected(): - print format_text("\nNot connected to server\n", 'bold') - return - self.stateless_client.cmd_pause_line(line) ############# resume + @verify_connected def do_resume(self, line): '''resume port(s) transmitting traffic\n''' - if not self.stateless_client.is_connected(): - print format_text("\nNot connected to server\n", 'bold') - return - self.stateless_client.cmd_resume_line(line) ########## reset + @verify_connected def do_reset (self, line): '''force stop all ports\n''' - if not self.stateless_client.is_connected(): - print format_text("\nNot connected to server\n", 'bold') - return - self.stateless_client.cmd_reset_line(line) - + + ######### validate + @verify_connected + def do_validate (self, line): + '''validates port(s) stream configuration\n''' + + self.stateless_client.cmd_validate_line(line) + + def help_events (self): self.do_events("-h") @@ -404,13 +402,10 @@ class TRexConsole(TRexGeneralCmd): print format_text("\n\nEvent log was cleared\n\n") # tui + @verify_connected def do_tui (self, line): '''Shows a graphical console\n''' - if not self.stateless_client.is_connected(): - print format_text("\nNot connected to server\n", 'bold') - return - self.do_verbose('off') trex_status.show_trex_status(self.stateless_client) -- cgit From 026f949fbafbb00fd7a21f3d84a632f5745003ea Mon Sep 17 00:00:00 2001 From: imarom Date: Sun, 6 Dec 2015 08:11:42 -0500 Subject: ZMQ bug - connect / disconnect fron another thread on pyhton (not safe !) fixed and more hardening --- scripts/automation/trex_control_plane/console/trex_console.py | 1 + 1 file changed, 1 insertion(+) (limited to 'scripts/automation/trex_control_plane/console/trex_console.py') diff --git a/scripts/automation/trex_control_plane/console/trex_console.py b/scripts/automation/trex_control_plane/console/trex_console.py index 73f4f612..9d855f98 100755 --- a/scripts/automation/trex_control_plane/console/trex_console.py +++ b/scripts/automation/trex_control_plane/console/trex_console.py @@ -153,6 +153,7 @@ class TRexConsole(TRexGeneralCmd): self.__dict__[name] = getattr(self.trex_console, name) def postcmd(self, stop, line): + if self.stateless_client.is_connected(): self.prompt = "TRex > " else: -- cgit From feb152b7d5eb531d439a4950d27cbc44031daf92 Mon Sep 17 00:00:00 2001 From: imarom Date: Tue, 8 Dec 2015 07:43:24 -0500 Subject: text based TUI (does not use ncurses) --- scripts/automation/trex_control_plane/console/trex_console.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'scripts/automation/trex_control_plane/console/trex_console.py') diff --git a/scripts/automation/trex_control_plane/console/trex_console.py b/scripts/automation/trex_control_plane/console/trex_console.py index e187c8c2..8d52b2a4 100755 --- a/scripts/automation/trex_control_plane/console/trex_console.py +++ b/scripts/automation/trex_control_plane/console/trex_console.py @@ -34,8 +34,7 @@ from client.trex_stateless_client import CTRexStatelessClient from common.text_opts import * from client_utils.general_utils import user_input, get_current_user from client_utils import parsing_opts -import trex_status -import parsing_opts +import trex_tui from functools import wraps @@ -119,6 +118,7 @@ class TRexConsole(TRexGeneralCmd): self.stateless_client = stateless_client TRexGeneralCmd.__init__(self) + self.tui = trex_tui.TrexTUI(stateless_client) self.verbose = verbose self.acquire_all_ports = acquire_all_ports @@ -425,7 +425,7 @@ class TRexConsole(TRexGeneralCmd): '''Shows a graphical console\n''' self.do_verbose('off') - trex_status.show_trex_status(self.stateless_client) + self.tui.show() # quit function def do_quit(self, line): -- cgit From 1355327e97e6d5ce5800fa4d6f879695922e8637 Mon Sep 17 00:00:00 2001 From: imarom Date: Tue, 8 Dec 2015 11:42:59 -0500 Subject: some modifications to the tables added clear stats as well --- scripts/automation/trex_control_plane/console/trex_console.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'scripts/automation/trex_control_plane/console/trex_console.py') diff --git a/scripts/automation/trex_control_plane/console/trex_console.py b/scripts/automation/trex_control_plane/console/trex_console.py index 8d52b2a4..9140977a 100755 --- a/scripts/automation/trex_control_plane/console/trex_console.py +++ b/scripts/automation/trex_control_plane/console/trex_console.py @@ -238,12 +238,12 @@ class TRexConsole(TRexGeneralCmd): elif line == "on": self.verbose = True - self.stateless_client.set_verbose(True) + self.stateless_client.set_verbose(self.stateless_client.VERBOSE_HIGH) print format_text("\nverbose set to on\n", 'green', 'bold') elif line == "off": self.verbose = False - self.stateless_client.set_verbose(False) + self.stateless_client.set_verbose(self.stateless_client.VERBOSE_REGULAR) print format_text("\nverbose set to off\n", 'green', 'bold') else: @@ -424,8 +424,11 @@ class TRexConsole(TRexGeneralCmd): def do_tui (self, line): '''Shows a graphical console\n''' - self.do_verbose('off') + save_verbose = self.stateless_client.get_verbose() + + self.stateless_client.set_verbose(self.stateless_client.VERBOSE_SILENCE) self.tui.show() + self.stateless_client.set_verbose(save_verbose) # quit function def do_quit(self, line): -- cgit From 95c2405d6373ca3c6b69efc3faf293cd41a55c76 Mon Sep 17 00:00:00 2001 From: imarom Date: Wed, 9 Dec 2015 15:01:25 -0500 Subject: read only support --- .../trex_control_plane/console/trex_console.py | 78 +++++++++++++++++----- 1 file changed, 62 insertions(+), 16 deletions(-) (limited to 'scripts/automation/trex_control_plane/console/trex_console.py') diff --git a/scripts/automation/trex_control_plane/console/trex_console.py b/scripts/automation/trex_control_plane/console/trex_console.py index 9140977a..495e1c22 100755 --- a/scripts/automation/trex_control_plane/console/trex_console.py +++ b/scripts/automation/trex_control_plane/console/trex_console.py @@ -130,12 +130,17 @@ class TRexConsole(TRexGeneralCmd): ################### internal section ######################## + def verify_connected(f): @wraps(f) def wrap(*args): inst = args[0] + func_name = f.__name__ + if func_name.startswith("do_"): + func_name = func_name[3:] + if not inst.stateless_client.is_connected(): - print format_text("\nNot connected to server\n", 'bold') + print format_text("\n'{0}' cannot be executed on offline mode\n".format(func_name), 'bold') return ret = f(*args) @@ -143,9 +148,32 @@ class TRexConsole(TRexGeneralCmd): return wrap + # TODO: remove this ugly duplication + def verify_connected_and_rw (f): + @wraps(f) + def wrap(*args): + inst = args[0] + func_name = f.__name__ + if func_name.startswith("do_"): + func_name = func_name[3:] + + if not inst.stateless_client.is_connected(): + print format_text("\n'{0}' cannot be executed on offline mode\n".format(func_name), 'bold') + return + + if inst.stateless_client.is_read_only(): + print format_text("\n'{0}' cannot be executed on read only mode\n".format(func_name), 'bold') + return + + ret = f(*args) + return ret + + return wrap + + def get_console_identifier(self): return "{context}_{server}".format(context=self.__class__.__name__, - server=self.stateless_client.get_system_info()['hostname']) + server=self.stateless_client.get_server()) def register_main_console_methods(self): main_names = set(self.trex_console.get_names()).difference(set(dir(self.__class__))) @@ -156,11 +184,17 @@ class TRexConsole(TRexGeneralCmd): def postcmd(self, stop, line): - if self.stateless_client.is_connected(): - self.prompt = "TRex > " - else: - self.supported_rpc = None + if not self.stateless_client.is_connected(): self.prompt = "TRex (offline) > " + self.supported_rpc = None + return stop + + if self.stateless_client.is_read_only(): + self.prompt = "TRex (read only) > " + return stop + + + self.prompt = "TRex > " return stop @@ -287,7 +321,7 @@ class TRexConsole(TRexGeneralCmd): def do_connect (self, line): '''Connects to the server\n''' - rc = self.stateless_client.cmd_connect() + rc = self.stateless_client.cmd_connect_line(line) if rc.bad(): return @@ -314,7 +348,7 @@ class TRexConsole(TRexGeneralCmd): if (l > 2) and (s[l - 2] in file_flags): return TRexConsole.tree_autocomplete(s[l - 1]) - @verify_connected + @verify_connected_and_rw def do_start(self, line): '''Start selected traffic in specified port(s) on TRex\n''' @@ -325,7 +359,7 @@ class TRexConsole(TRexGeneralCmd): self.do_start("-h") ############# stop - @verify_connected + @verify_connected_and_rw def do_stop(self, line): '''stops port(s) transmitting traffic\n''' @@ -335,7 +369,7 @@ class TRexConsole(TRexGeneralCmd): self.do_stop("-h") ############# update - @verify_connected + @verify_connected_and_rw def do_update(self, line): '''update speed of port(s)currently transmitting traffic\n''' @@ -345,14 +379,14 @@ class TRexConsole(TRexGeneralCmd): self.do_update("-h") ############# pause - @verify_connected + @verify_connected_and_rw def do_pause(self, line): '''pause port(s) transmitting traffic\n''' self.stateless_client.cmd_pause_line(line) ############# resume - @verify_connected + @verify_connected_and_rw def do_resume(self, line): '''resume port(s) transmitting traffic\n''' @@ -361,7 +395,7 @@ class TRexConsole(TRexGeneralCmd): ########## reset - @verify_connected + @verify_connected_and_rw def do_reset (self, line): '''force stop all ports\n''' self.stateless_client.cmd_reset_line(line) @@ -375,6 +409,7 @@ class TRexConsole(TRexGeneralCmd): self.stateless_client.cmd_validate_line(line) + @verify_connected def do_stats(self, line): '''Fetch statistics from TRex server by port\n''' self.stateless_client.cmd_stats_line(line) @@ -383,6 +418,7 @@ class TRexConsole(TRexGeneralCmd): def help_stats(self): self.do_stats("-h") + @verify_connected def do_clear(self, line): '''Clear cached local statistics\n''' self.stateless_client.cmd_clear_line(line) @@ -529,9 +565,17 @@ def main(): # Stateless client connection stateless_client = CTRexStatelessClient(options.user, options.server, options.port, options.pub) - rc = stateless_client.cmd_connect() + + print "\nlogged as {0}".format(format_text(options.user, 'bold')) + rc = stateless_client.connect() + + # error can be either no able to connect or a read only if rc.bad(): - return + if not stateless_client.is_connected(): + rc.annotate() + else: + rc.annotate(show_status = False) + if options.batch: cont = stateless_client.run_script_file(options.batch[0]) @@ -544,7 +588,9 @@ def main(): console.cmdloop() except KeyboardInterrupt as e: print "\n\n*** Caught Ctrl + C... Exiting...\n\n" - return + + finally: + stateless_client.shutdown() if __name__ == '__main__': main() -- cgit From 7567166ca52bd136ce08c06dcbd48c0dfd67210f Mon Sep 17 00:00:00 2001 From: imarom Date: Thu, 10 Dec 2015 03:43:55 -0500 Subject: removed session id - not necessary --- scripts/automation/trex_control_plane/console/trex_console.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'scripts/automation/trex_control_plane/console/trex_console.py') diff --git a/scripts/automation/trex_control_plane/console/trex_console.py b/scripts/automation/trex_control_plane/console/trex_console.py index 495e1c22..e8f90186 100755 --- a/scripts/automation/trex_control_plane/console/trex_console.py +++ b/scripts/automation/trex_control_plane/console/trex_console.py @@ -575,6 +575,7 @@ def main(): rc.annotate() else: rc.annotate(show_status = False) + print format_text("Switching to read only mode - only few commands will be available", 'bold') if options.batch: @@ -590,7 +591,7 @@ def main(): print "\n\n*** Caught Ctrl + C... Exiting...\n\n" finally: - stateless_client.shutdown() + stateless_client.disconnect() if __name__ == '__main__': main() -- cgit From fc4b8bddcb4550cbf8d06e414b82a1d082d1d996 Mon Sep 17 00:00:00 2001 From: imarom Date: Thu, 10 Dec 2015 06:56:17 -0500 Subject: added a "--tui" feature to the console it opens in read only mode and runs the TUI --- .../trex_control_plane/console/trex_console.py | 40 +++++++++++++--------- 1 file changed, 23 insertions(+), 17 deletions(-) (limited to 'scripts/automation/trex_control_plane/console/trex_console.py') diff --git a/scripts/automation/trex_control_plane/console/trex_console.py b/scripts/automation/trex_control_plane/console/trex_console.py index e8f90186..0ecfce9c 100755 --- a/scripts/automation/trex_control_plane/console/trex_console.py +++ b/scripts/automation/trex_control_plane/console/trex_console.py @@ -114,14 +114,13 @@ class TRexGeneralCmd(cmd.Cmd): class TRexConsole(TRexGeneralCmd): """Trex Console""" - def __init__(self, stateless_client, acquire_all_ports=True, verbose=False): + def __init__(self, stateless_client, verbose=False): self.stateless_client = stateless_client TRexGeneralCmd.__init__(self) self.tui = trex_tui.TrexTUI(stateless_client) self.verbose = verbose - self.acquire_all_ports = acquire_all_ports self.intro = "\n-=TRex Console v{ver}=-\n".format(ver=__version__) self.intro += "\nType 'help' or '?' for supported actions\n" @@ -321,17 +320,13 @@ class TRexConsole(TRexGeneralCmd): def do_connect (self, line): '''Connects to the server\n''' - rc = self.stateless_client.cmd_connect_line(line) - if rc.bad(): - return + self.stateless_client.cmd_connect_line(line) def do_disconnect (self, line): '''Disconnect from the server\n''' - rc = self.stateless_client.cmd_disconnect() - if rc.bad(): - return + self.stateless_client.cmd_disconnect() ############### start @@ -556,6 +551,10 @@ def setParserOptions(): help = "Run the console in a batch mode with file", default = None) + parser.add_argument("-t", "--tui", dest="tui", + action="store_true", help="Starts with TUI mode", + default = False) + return parser @@ -567,17 +566,20 @@ def main(): stateless_client = CTRexStatelessClient(options.user, options.server, options.port, options.pub) print "\nlogged as {0}".format(format_text(options.user, 'bold')) - rc = stateless_client.connect() - # error can be either no able to connect or a read only + # TUI or no acquire will give us READ ONLY mode + if options.tui or not options.acquire: + rc = stateless_client.connect("RO") + else: + rc = stateless_client.connect("RW") + + # unable to connect - bye if rc.bad(): - if not stateless_client.is_connected(): - rc.annotate() - else: - rc.annotate(show_status = False) - print format_text("Switching to read only mode - only few commands will be available", 'bold') + rc.annotate() + return + # a script mode if options.batch: cont = stateless_client.run_script_file(options.batch[0]) if not cont: @@ -585,8 +587,12 @@ def main(): # console try: - console = TRexConsole(stateless_client, options.acquire, options.verbose) - console.cmdloop() + console = TRexConsole(stateless_client, options.verbose) + if options.tui: + console.do_tui("") + else: + console.cmdloop() + except KeyboardInterrupt as e: print "\n\n*** Caught Ctrl + C... Exiting...\n\n" -- cgit From bae48d6cf8dd59158ffcb488391af8a96fc2e037 Mon Sep 17 00:00:00 2001 From: imarom Date: Mon, 14 Dec 2015 04:47:35 -0500 Subject: TUI v2.0 - now no flickering, state machine for lost of connectivity and TUI can be started in xterm using tui -x --- .../automation/trex_control_plane/console/trex_console.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'scripts/automation/trex_control_plane/console/trex_console.py') diff --git a/scripts/automation/trex_control_plane/console/trex_console.py b/scripts/automation/trex_control_plane/console/trex_console.py index 0ecfce9c..325ba514 100755 --- a/scripts/automation/trex_control_plane/console/trex_console.py +++ b/scripts/automation/trex_control_plane/console/trex_console.py @@ -17,7 +17,7 @@ See the License for the specific language governing permissions and limitations under the License. """ - +import subprocess import cmd import json import ast @@ -455,6 +455,19 @@ class TRexConsole(TRexGeneralCmd): def do_tui (self, line): '''Shows a graphical console\n''' + parser = parsing_opts.gen_parser(self, + "tui", + self.do_tui.__doc__, + parsing_opts.XTERM) + + opts = parser.parse_args(line.split()) + if opts is None: + return + + if opts.xterm: + subprocess.Popen(['xterm', '-geometry', '105x40', '-e', './trex-console', '-t']) + return + save_verbose = self.stateless_client.get_verbose() self.stateless_client.set_verbose(self.stateless_client.VERBOSE_SILENCE) -- cgit From d71dbce9695f348b2e52e00c9efd53cb89c62aa5 Mon Sep 17 00:00:00 2001 From: imarom Date: Mon, 14 Dec 2015 11:03:53 -0500 Subject: bugs fixes 1. ignore your own force acquire of ports 2. TUI fixes --- .../trex_control_plane/console/trex_console.py | 28 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'scripts/automation/trex_control_plane/console/trex_console.py') diff --git a/scripts/automation/trex_control_plane/console/trex_console.py b/scripts/automation/trex_control_plane/console/trex_console.py index 325ba514..fe6dfe12 100755 --- a/scripts/automation/trex_control_plane/console/trex_console.py +++ b/scripts/automation/trex_control_plane/console/trex_console.py @@ -172,7 +172,7 @@ class TRexConsole(TRexGeneralCmd): def get_console_identifier(self): return "{context}_{server}".format(context=self.__class__.__name__, - server=self.stateless_client.get_server()) + server=self.stateless_client.get_server_ip()) def register_main_console_methods(self): main_names = set(self.trex_console.get_names()).difference(set(dir(self.__class__))) @@ -450,6 +450,7 @@ class TRexConsole(TRexGeneralCmd): self.stateless_client.clear_events() print format_text("\n\nEvent log was cleared\n\n") + # tui @verify_connected def do_tui (self, line): @@ -465,15 +466,26 @@ class TRexConsole(TRexGeneralCmd): return if opts.xterm: - subprocess.Popen(['xterm', '-geometry', '105x40', '-e', './trex-console', '-t']) + exe = '' + if os.path.isfile('/usr/bin/wmctrl'): + exe += '/usr/bin/wmctrl -r trex_tui -b add,above;' + + exe += './trex-console -t -q -s {0} -p {1}'.format(self.stateless_client.get_server_ip(), self.stateless_client.get_server_port()) + + cmd = ['xterm', '-geometry', '105x40', '-title', 'trex_tui', '-e', exe] + subprocess.Popen(cmd) + return save_verbose = self.stateless_client.get_verbose() - self.stateless_client.set_verbose(self.stateless_client.VERBOSE_SILENCE) + self.stateless_client.set_verbose(self.stateless_client.VERBOSE_QUIET) self.tui.show() self.stateless_client.set_verbose(save_verbose) + def help_tui (self): + do_tui("-h") + # quit function def do_quit(self, line): '''Exit the client\n''' @@ -568,6 +580,11 @@ def setParserOptions(): action="store_true", help="Starts with TUI mode", default = False) + + parser.add_argument("-q", "--quiet", dest="quiet", + action="store_true", help="Starts with all outputs suppressed", + default = False) + return parser @@ -576,9 +593,10 @@ def main(): options = parser.parse_args() # Stateless client connection - stateless_client = CTRexStatelessClient(options.user, options.server, options.port, options.pub) + stateless_client = CTRexStatelessClient(options.user, options.server, options.port, options.pub, options.quiet) - print "\nlogged as {0}".format(format_text(options.user, 'bold')) + if not options.quiet: + print "\nlogged as {0}".format(format_text(options.user, 'bold')) # TUI or no acquire will give us READ ONLY mode if options.tui or not options.acquire: -- cgit From 419a25e989c47dcc5e94b9e3bc64252fb5197f10 Mon Sep 17 00:00:00 2001 From: imarom Date: Tue, 15 Dec 2015 11:24:07 -0500 Subject: VM: connected control plane to DP --- scripts/automation/trex_control_plane/console/trex_console.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'scripts/automation/trex_control_plane/console/trex_console.py') diff --git a/scripts/automation/trex_control_plane/console/trex_console.py b/scripts/automation/trex_control_plane/console/trex_console.py index 325ba514..f02652d0 100755 --- a/scripts/automation/trex_control_plane/console/trex_console.py +++ b/scripts/automation/trex_control_plane/console/trex_console.py @@ -474,6 +474,11 @@ class TRexConsole(TRexGeneralCmd): self.tui.show() self.stateless_client.set_verbose(save_verbose) + + def help_tui (self): + do_tui("-h") + + # quit function def do_quit(self, line): '''Exit the client\n''' -- cgit From 3f6e247e9ed29e9dbf61dffadfb2a86c2284987e Mon Sep 17 00:00:00 2001 From: Hanoh Haim Date: Wed, 16 Dec 2015 20:54:04 +0200 Subject: add tuple gen command and yaml example --- scripts/automation/trex_control_plane/console/trex_console.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'scripts/automation/trex_control_plane/console/trex_console.py') diff --git a/scripts/automation/trex_control_plane/console/trex_console.py b/scripts/automation/trex_control_plane/console/trex_console.py index 1d94afb7..a3ea6693 100755 --- a/scripts/automation/trex_control_plane/console/trex_console.py +++ b/scripts/automation/trex_control_plane/console/trex_console.py @@ -164,8 +164,8 @@ class TRexConsole(TRexGeneralCmd): print format_text("\n'{0}' cannot be executed on read only mode\n".format(func_name), 'bold') return - ret = f(*args) - return ret + rc = f(*args) + return rc return wrap @@ -349,6 +349,8 @@ class TRexConsole(TRexGeneralCmd): self.stateless_client.cmd_start_line(line) + + def help_start(self): self.do_start("-h") -- cgit