summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/console
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/automation/trex_control_plane/console')
-rwxr-xr-xscripts/automation/trex_control_plane/console/trex_console.py96
1 files changed, 58 insertions, 38 deletions
diff --git a/scripts/automation/trex_control_plane/console/trex_console.py b/scripts/automation/trex_control_plane/console/trex_console.py
index 06ae762a..2be643ab 100755
--- a/scripts/automation/trex_control_plane/console/trex_console.py
+++ b/scripts/automation/trex_control_plane/console/trex_console.py
@@ -160,7 +160,51 @@ class TRexConsole(cmd.Cmd):
for x in os.listdir(path)
if x.startswith(start_string)]
+ # annotation method
+ @staticmethod
+ def annotate (desc, rc = None, err_log = None, ext_err_msg = None):
+ print format_text('\n{:<40}'.format(desc), 'bold'),
+ if rc == None:
+ print "\n"
+ return
+
+ if rc == False:
+ # do we have a complex log object ?
+ if isinstance(err_log, list):
+ print ""
+ for func in err_log:
+ if func:
+ print func
+ print ""
+
+ elif isinstance(err_log, str):
+ print "\n" + err_log + "\n"
+
+ print format_text("[FAILED]\n", 'red', 'bold')
+ if ext_err_msg:
+ print format_text(ext_err_msg + "\n", 'blue', 'bold')
+
+ return False
+
+ else:
+ print format_text("[SUCCESS]\n", 'green', 'bold')
+ return True
+
+
####################### shell commands #######################
+ def do_ping (self, line):
+ '''Ping the server\n'''
+
+ rc = self.stateless_client.ping()
+ if rc.good():
+ print format_text("[SUCCESS]\n", 'green', 'bold')
+ else:
+ print "\n*** " + rc.err() + "\n"
+ print format_text("[FAILED]\n", 'red', 'bold')
+ return
+
+ def do_test (self, line):
+ print self.stateless_client.get_acquired_ports()
# set verbose on / off
def do_verbose(self, line):
@@ -171,65 +215,41 @@ class TRexConsole(cmd.Cmd):
elif line == "on":
self.verbose = True
self.stateless_client.set_verbose(True)
- print green("\nverbose set to on\n")
+ print format_text("\nverbose set to on\n", 'green', 'bold')
elif line == "off":
self.verbose = False
self.stateless_client.set_verbose(False)
- print green("\nverbose set to off\n")
+ print format_text("\nverbose set to off\n", 'green', 'bold')
else:
- print magenta("\nplease specify 'on' or 'off'\n")
+ print format_text("\nplease specify 'on' or 'off'\n", 'bold')
+
############### connect
def do_connect (self, line):
'''Connects to the server\n'''
- res_ok, msg = self.stateless_client.connect()
- if res_ok:
+ rc = self.stateless_client.connect()
+ if rc.good():
print format_text("[SUCCESS]\n", 'green', 'bold')
else:
- print "\n*** " + msg + "\n"
+ print "\n*** " + rc.err() + "\n"
print format_text("[FAILED]\n", 'red', 'bold')
return
- self.supported_rpc = self.stateless_client.get_supported_cmds().data
- if self.acquire_all_ports:
- res_ok, log = self.stateless_client.acquire(self.stateless_client.get_port_ids())
- if not res_ok:
- print "\n*** Failed to acquire all ports... exiting..."""
+ def do_disconnect (self, line):
+ '''Disconnect from the server\n'''
- @staticmethod
- def annotate (desc, rc = None, err_log = None, ext_err_msg = None):
- print format_text('\n{:<40}'.format(desc), 'bold'),
- if rc == None:
- print "\n"
+ if not self.stateless_client.is_connected():
+ print "Not connected to server\n"
return
- if rc == False:
- # do we have a complex log object ?
- if isinstance(err_log, list):
- print ""
- for func in err_log:
- if func:
- print func
- print ""
-
- elif isinstance(err_log, str):
- print "\n" + err_log + "\n"
-
- print format_text("[FAILED]\n", 'red', 'bold')
- if ext_err_msg:
- print format_text(ext_err_msg + "\n", 'blue', 'bold')
-
- return False
-
- else:
- print format_text("[SUCCESS]\n", 'green', 'bold')
- return True
-
+ self.stateless_client.disconnect()
+ print format_text("[SUCCESS]\n", 'green', 'bold')
+
############### start
def complete_start(self, text, line, begidx, endidx):