summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2015-11-25 06:56:04 -0500
committerimarom <imarom@cisco.com>2015-11-25 06:56:04 -0500
commit92dea3787ab7b2c9877af9cd539d42a6957f7da6 (patch)
tree1cb27bc6eb3ffe3ea06609448e9dfb4dd47d1f5d
parent4a41c26a5cf23635a5b1332af6e806c915cf7e6c (diff)
added events log
-rw-r--r--scripts/automation/trex_control_plane/client/trex_async_client.py11
-rwxr-xr-xscripts/automation/trex_control_plane/client/trex_stateless_client.py35
-rwxr-xr-xscripts/automation/trex_control_plane/console/trex_console.py6
-rwxr-xr-xsrc/main_dpdk.cpp1
-rw-r--r--src/publisher/trex_publisher.h5
5 files changed, 46 insertions, 12 deletions
diff --git a/scripts/automation/trex_control_plane/client/trex_async_client.py b/scripts/automation/trex_control_plane/client/trex_async_client.py
index adb91d97..7641a1e3 100644
--- a/scripts/automation/trex_control_plane/client/trex_async_client.py
+++ b/scripts/automation/trex_control_plane/client/trex_async_client.py
@@ -197,7 +197,6 @@ class CTRexAsyncClient():
return self.stats
def get_raw_snapshot (self):
- #return str(self.stats.global_stats.get('m_total_tx_bytes')) + " / " + str(self.stats.global_stats.get_rel('m_total_tx_bytes'))
return self.raw_snapshot
@@ -208,18 +207,10 @@ class CTRexAsyncClient():
self.stats.update(data)
# events
elif name == "trex-event":
- self.__handle_async_event(type, data)
+ self.stateless_client.handle_async_event(type, data)
else:
- # ignore
pass
- def __handle_async_event (self, type, data):
- # DP stopped
- if (type == 0):
- port_id = int(data['port_id'])
- print format_text("\n[Event] - Port {0} Stopped".format(port_id), 'bold')
- # call the handler
- self.stateless_client.async_event_port_stopped(port_id)
def stop (self):
self.active = False
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 30550ca3..1d0ca606 100755
--- a/scripts/automation/trex_control_plane/client/trex_stateless_client.py
+++ b/scripts/automation/trex_control_plane/client/trex_stateless_client.py
@@ -16,6 +16,7 @@ from collections import namedtuple
from common.text_opts import *
import parsing_opts
import time
+import datetime
from trex_async_client import CTRexAsyncClient
@@ -400,10 +401,44 @@ class CTRexStatelessClient(object):
self.connected = False
+ self.events = []
+
################# events handler ######################
+
+ def handle_async_event (self, type, data):
+ # DP stopped
+
+ ev = "[event] - "
+
+ if (type == 0):
+ 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):
+ ev += "Server has stopped"
+ self.async_event_server_stopped()
+
+ else:
+ # unknown event - ignore
+ return
+
+ 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()
+ def async_event_server_stopped (self):
+ self.disconnect()
+
+ def get_events (self):
+ return self.events
+
############# helper functions section ##############
def validate_port_list(self, port_id_list):
diff --git a/scripts/automation/trex_control_plane/console/trex_console.py b/scripts/automation/trex_control_plane/console/trex_console.py
index dc1515e0..b164af4e 100755
--- a/scripts/automation/trex_control_plane/console/trex_console.py
+++ b/scripts/automation/trex_control_plane/console/trex_console.py
@@ -334,6 +334,12 @@ class TRexConsole(TRexGeneralCmd):
self.stateless_client.cmd_reset()
+ def do_events (self, line):
+ '''shows events recieved from server\n'''
+ events = self.stateless_client.get_events()
+ for ev in events:
+ print ev
+
# tui
def do_tui (self, line):
'''Shows a graphical console\n'''
diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp
index 57a87b71..3e5418b9 100755
--- a/src/main_dpdk.cpp
+++ b/src/main_dpdk.cpp
@@ -3274,6 +3274,7 @@ void CGlobalTRex::try_stop_all_dp(){
delay(100);
}
if ( all_core_finished ){
+ m_zmq_publisher.publish_event(TrexPublisher::EVENT_SERVER_STOPPED);
printf(" All cores stopped !! \n");
}else{
printf(" ERROR one of the DP core is stucked !\n");
diff --git a/src/publisher/trex_publisher.h b/src/publisher/trex_publisher.h
index 82603fda..89336735 100644
--- a/src/publisher/trex_publisher.h
+++ b/src/publisher/trex_publisher.h
@@ -39,10 +39,11 @@ public:
void publish_json(const std::string &s);
enum event_type_e {
- EVENT_PORT_STOPPED = 0
+ EVENT_PORT_STOPPED = 0,
+ EVENT_SERVER_STOPPED = 1
};
- void publish_event(event_type_e type, const Json::Value &data);
+ void publish_event(event_type_e type, const Json::Value &data = Json::nullValue);
private:
void show_zmq_last_error(const std::string &err);