summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/console/trex_console.py
diff options
context:
space:
mode:
authorDan Klein <danklein10@gmail.com>2015-11-03 09:37:58 +0200
committerDan Klein <danklein10@gmail.com>2015-11-03 09:37:58 +0200
commitc5078068c4659f5445d9c684c67b55ee2c7e10d6 (patch)
tree124c04254f8e79e3ab1792b256e4cb113f81e3a4 /scripts/automation/trex_control_plane/console/trex_console.py
parent2636c09cfb74c7981c27d84bcc72d00929fdbbbb (diff)
parent0ceddc74c938a023c515be4ed2c37198fd66e87e (diff)
Merge branch 'rpc_intg1' into dan_stateless
Diffstat (limited to 'scripts/automation/trex_control_plane/console/trex_console.py')
-rwxr-xr-xscripts/automation/trex_control_plane/console/trex_console.py26
1 files changed, 16 insertions, 10 deletions
diff --git a/scripts/automation/trex_control_plane/console/trex_console.py b/scripts/automation/trex_control_plane/console/trex_console.py
index 51a1f8cc..e707a9e1 100755
--- a/scripts/automation/trex_control_plane/console/trex_console.py
+++ b/scripts/automation/trex_control_plane/console/trex_console.py
@@ -31,10 +31,8 @@ import trex_root_path
from common.trex_streams import *
from client.trex_stateless_client import CTRexStatelessClient
from common.text_opts import *
-from client_utils.general_utils import user_input
+from client_utils.general_utils import user_input, get_current_user
-
-from client_utils.jsonrpc_client import TrexStatelessClient
import trex_status
from collections import namedtuple
@@ -177,6 +175,7 @@ class TRexConsole(cmd.Cmd):
dotext = 'do_'+text
return [a[3:]+' ' for a in self.get_names() if a.startswith(dotext)]
+
# set verbose on / off
def do_verbose (self, line):
'''Shows or set verbose mode\n'''
@@ -393,9 +392,9 @@ class TRexConsole(cmd.Cmd):
print "Example: rpc test_add {'x': 12, 'y': 17}\n"
return
- res_ok, msg = self.stateless_client.invoke_rpc_method(method, params)
+ res_ok, msg = self.stateless_client.transmit(method, params)
if res_ok:
- print "\nServer Response:\n\n" + self.stateless_client.pretty_json(json.dumps(msg)) + "\n"
+ print "\nServer Response:\n\n" + pretty_json(json.dumps(msg)) + "\n"
else:
print "\n*** " + msg + "\n"
#print "Please try 'reconnect' to reconnect to server"
@@ -409,6 +408,10 @@ class TRexConsole(cmd.Cmd):
def do_status (self, line):
'''Shows a graphical console\n'''
+ if not self.stateless_client.is_connected():
+ print "Not connected to server\n"
+ return
+
self.do_verbose('off')
trex_status.show_trex_status(self.stateless_client)
@@ -770,8 +773,12 @@ def setParserOptions():
default = 5050,
type = int)
- parser.add_argument("-u", "--user", help = "User Name [default is random generated]\n",
- default = 'user_' + ''.join(random.choice(string.digits) for _ in range(5)),
+ parser.add_argument("-z", "--pub", help = "TRex Async Publisher Port [default is 4500]\n",
+ default = 4500,
+ type = int)
+
+ parser.add_argument("-u", "--user", help = "User Name [default is currently logged in user]\n",
+ default = get_current_user(),
type = str)
parser.add_argument("--verbose", dest="verbose",
@@ -782,11 +789,10 @@ def setParserOptions():
def main():
parser = setParserOptions()
- options = parser.parse_args()#sys.argv[1:])
+ options = parser.parse_args()
# Stateless client connection
- # stateless_client = TrexStatelessClient(options.server, options.port, options.user)
- stateless_client = CTRexStatelessClient(options.user, options.server, options.port)
+ stateless_client = CTRexStatelessClient(options.user, options.server, options.port, options.pub)
# console
try: