summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/automation/trex_control_plane/client/trex_stateless_client.py30
-rwxr-xr-xscripts/automation/trex_control_plane/console/parsing_opts.py2
-rwxr-xr-xscripts/automation/trex_control_plane/console/trex_console.py22
-rw-r--r--src/publisher/trex_publisher.h6
-rw-r--r--src/stateless/cp/trex_stateless_port.cpp9
5 files changed, 63 insertions, 6 deletions
diff --git a/scripts/automation/trex_control_plane/client/trex_stateless_client.py b/scripts/automation/trex_control_plane/client/trex_stateless_client.py
index 1d0ca606..149d2855 100755
--- a/scripts/automation/trex_control_plane/client/trex_stateless_client.py
+++ b/scripts/automation/trex_control_plane/client/trex_stateless_client.py
@@ -410,26 +410,49 @@ class CTRexStatelessClient(object):
ev = "[event] - "
+ show_event = False
+
+ # port started
if (type == 0):
port_id = int(data['port_id'])
+ ev += "Port {0} has started".format(port_id)
+
+ # port stopped
+ elif (type == 1):
+ port_id = int(data['port_id'])
ev += "Port {0} has stopped".format(port_id)
+
# call the handler
self.async_event_port_stopped(port_id)
+
- elif (type == 1):
+ # server stopped
+ elif (type == 2):
ev += "Server has stopped"
self.async_event_server_stopped()
+ show_event = True
+
+ # port finished traffic
+ elif (type == 3):
+ port_id = int(data['port_id'])
+ ev += "Port {0} job done".format(port_id)
+
+ # call the handler
+ self.async_event_port_stopped(port_id)
+ show_event = True
else:
# unknown event - ignore
return
- print format_text("\n" + ev, 'bold')
+ if show_event:
+ print format_text("\n" + ev, 'bold')
ts = time.time()
st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
self.events.append("{0} - ".format(st) + format_text(ev, 'bold'))
+
def async_event_port_stopped (self, port_id):
self.ports[port_id].async_event_port_stopped()
@@ -439,6 +462,9 @@ class CTRexStatelessClient(object):
def get_events (self):
return self.events
+ def clear_events (self):
+ self.events = []
+
############# helper functions section ##############
def validate_port_list(self, port_id_list):
diff --git a/scripts/automation/trex_control_plane/console/parsing_opts.py b/scripts/automation/trex_control_plane/console/parsing_opts.py
index d2484a83..0bcdce84 100755
--- a/scripts/automation/trex_control_plane/console/parsing_opts.py
+++ b/scripts/automation/trex_control_plane/console/parsing_opts.py
@@ -121,7 +121,7 @@ def is_valid_file(filename):
OPTIONS_DB = {MULTIPLIER: ArgumentPack(['-m', '--multiplier'],
{'help': match_multiplier_help,
'dest': "mult",
- 'default': 1.0,
+ 'default': {'type':'raw', 'max':1},
'type': match_multiplier}),
diff --git a/scripts/automation/trex_control_plane/console/trex_console.py b/scripts/automation/trex_control_plane/console/trex_console.py
index b164af4e..fc2c845a 100755
--- a/scripts/automation/trex_control_plane/console/trex_console.py
+++ b/scripts/automation/trex_control_plane/console/trex_console.py
@@ -334,12 +334,34 @@ class TRexConsole(TRexGeneralCmd):
self.stateless_client.cmd_reset()
+ def help_events (self):
+ self.do_events("-h")
+
def do_events (self, line):
'''shows events recieved from server\n'''
+
+ x = parsing_opts.ArgumentPack(['-c','--clear'],
+ {'action' : "store_true",
+ 'default': False,
+ 'help': "clear the events log"})
+
+ parser = parsing_opts.gen_parser(self,
+ "events",
+ self.do_events.__doc__,
+ x)
+
+ opts = parser.parse_args(line.split())
+ if opts is None:
+ return
+
events = self.stateless_client.get_events()
for ev in events:
print ev
+ if opts.clear:
+ self.stateless_client.clear_events()
+ print format_text("\n\nEvent log was cleared\n\n")
+
# tui
def do_tui (self, line):
'''Shows a graphical console\n'''
diff --git a/src/publisher/trex_publisher.h b/src/publisher/trex_publisher.h
index 89336735..8d1be064 100644
--- a/src/publisher/trex_publisher.h
+++ b/src/publisher/trex_publisher.h
@@ -39,8 +39,10 @@ public:
void publish_json(const std::string &s);
enum event_type_e {
- EVENT_PORT_STOPPED = 0,
- EVENT_SERVER_STOPPED = 1
+ EVENT_PORT_STARTED = 0,
+ EVENT_PORT_STOPPED = 1,
+ EVENT_SERVER_STOPPED = 2,
+ EVENT_PORT_FINISHED_TX = 3,
};
void publish_event(event_type_e type, const Json::Value &data = Json::nullValue);
diff --git a/src/stateless/cp/trex_stateless_port.cpp b/src/stateless/cp/trex_stateless_port.cpp
index 5f1a3bca..2fd948fd 100644
--- a/src/stateless/cp/trex_stateless_port.cpp
+++ b/src/stateless/cp/trex_stateless_port.cpp
@@ -139,6 +139,9 @@ TrexStatelessPort::start_traffic(double mul, double duration) {
send_message_to_dp(start_msg);
+ Json::Value data;
+ data["port_id"] = m_port_id;
+ get_stateless_obj()->get_publisher()->publish_event(TrexPublisher::EVENT_PORT_STARTED, data);
}
void
@@ -194,6 +197,10 @@ TrexStatelessPort::stop_traffic(void) {
change_state(PORT_STATE_STREAMS);
+ Json::Value data;
+ data["port_id"] = m_port_id;
+ get_stateless_obj()->get_publisher()->publish_event(TrexPublisher::EVENT_PORT_STOPPED, data);
+
}
void
@@ -366,7 +373,7 @@ TrexStatelessPort::on_dp_event_occured(TrexDpPortEvent::event_e event_type) {
/* send a ZMQ event */
data["port_id"] = m_port_id;
- get_stateless_obj()->get_publisher()->publish_event(TrexPublisher::EVENT_PORT_STOPPED, data);
+ get_stateless_obj()->get_publisher()->publish_event(TrexPublisher::EVENT_PORT_FINISHED_TX, data);
break;
default: