Hi Alberto, You can take a look at https://github.com/Juniper/contrail-controller/blob/master/src/vnsw/agent/uve/mock_generator.cc
which is an example generator that sends some UVEs and flow messages. It has bunch of command line options. It can be compiled by running scons vrouter:mock_gen at the top. Thanks Megh On Apr 14, 2015, at 5:30 PM, Megh Bhatt <me...@juniper.net> wrote: > Hi Alberto, > Can you please share the diffs you made to the test? That will help. > > I tried with the following changes and it worked fine > > diff --git a/library/cpp/test/sandesh_message_test.cc > b/library/cpp/test/sandesh_message_test.cc > index f27a0c1..4aab1b6 100644 > --- a/library/cpp/test/sandesh_message_test.cc > +++ b/library/cpp/test/sandesh_message_test.cc > @@ -475,12 +475,13 @@ protected: > TEST_F(SandeshUVEAlarmTest, UVEAlarm) { > server_->Initialize(0); > thread_->Start(); > - int port = server_->GetPort(); > + //int port = server_->GetPort(); > + int port = 8086; > ASSERT_LT(0, port); > > Sandesh::InitGenerator("SandeshUVEAlarmTest-Client", "localhost", "Test", > "0", evm_.get(), 0, NULL); > - Sandesh::ConnectToCollector("127.0.0.1", port); > + Sandesh::ConnectToCollector("10.84.13.23", port); > TASK_UTIL_EXPECT_TRUE(Sandesh::client()->state() == > SandeshClientSM::ESTABLISHED); > > // add uve > ubuntu-build04@test$ > > Logs from the test below: > > ubuntu-build04@github-icehouse$ > ./build/debug/tools/sandesh/library/cpp/test/sandesh_message_test > --gtest_filter=*Alarm* > Note: Google Test filter = *Alarm* > [==========] Running 1 test from 1 test case. > [----------] Global test environment set-up. > [----------] 1 test from SandeshUVEAlarmTest > [ RUN ] SandeshUVEAlarmTest.UVEAlarm > 2015-04-14 Tue 17:26:49:453.703 PDT ubuntu-build04 [Thread 140071693285312, > Pid 5403]: Server 0.0.0.0:50474 Initialization complete > 2015-04-14 Tue 17:26:49:453.920 PDT ubuntu-build04 [Thread 140071693285312, > Pid 5403]: SANDESH: ROLE : Generator > 2015-04-14 Tue 17:26:49:453.951 PDT ubuntu-build04 [Thread 140071693285312, > Pid 5403]: SANDESH: MODULE : SandeshUVEAlarmTest-Client > 2015-04-14 Tue 17:26:49:453.972 PDT ubuntu-build04 [Thread 140071693285312, > Pid 5403]: SANDESH: SOURCE : localhost > 2015-04-14 Tue 17:26:49:453.991 PDT ubuntu-build04 [Thread 140071693285312, > Pid 5403]: SANDESH: NODE TYPE : Test > 2015-04-14 Tue 17:26:49:454.010 PDT ubuntu-build04 [Thread 140071693285312, > Pid 5403]: SANDESH: INSTANCE ID : 0 > 2015-04-14 Tue 17:26:49:454.029 PDT ubuntu-build04 [Thread 140071693285312, > Pid 5403]: SANDESH: HTTP SERVER PORT : 0 > 2015-04-14 Tue 17:26:49:454.185 PDT ubuntu-build04 [Thread 140071693285312, > Pid 5403]: HTTP Introspect Init > 2015-04-14 Tue 17:26:49:454.327 PDT ubuntu-build04 [Thread 140071693285312, > Pid 5403]: TCP [SYS_DEBUG]: TcpServerMessageLog: Server 0.0.0.0:60366 > Initialization complete controller/src/io/tcp_server.cc 102 > 2015-04-14 Tue 17:26:49:454.388 PDT ubuntu-build04 [Thread 140071693285312, > Pid 5403]: Sandesh Http Server Port 60366 > 2015-04-14 Tue 17:26:49:454.449 PDT ubuntu-build04 [Thread 140071693285312, > Pid 5403]: SANDESH: NOT Writing http_port 60366TO : > /tmp/SandeshUVEAlarmTest-Client.3152.http_port > 2015-04-14 Tue 17:26:49:454.482 PDT ubuntu-build04 [Thread 140071693285312, > Pid 5403]: SANDESH: COLLECTOR : 10.84.13.23 > 2015-04-14 Tue 17:26:49:454.502 PDT ubuntu-build04 [Thread 140071693285312, > Pid 5403]: SANDESH: COLLECTOR PORT : 8086 > 2015-04-14 Tue 17:26:49:454.531 PDT ubuntu-build04 [Thread 140071693285312, > Pid 5403]: SANDESH: CONNECT TO COLLECTOR: 1 > 2015-04-14 Tue 17:26:49:454.665 PDT ubuntu-build04 [Thread 140071693285312, > Pid 5403]: Idle > 2015-04-14 Tue 17:26:49:454.940 PDT ubuntu-build04 [Thread 140071693285312, > Pid 5403]: SANDESH: No Client: 1429057609454838 SandeshModuleClientTrace: > data= [ name = localhost:Test:SandeshUVEAlarmTest-Client:0 client_info= [ > status = Idle successful_connections = 0 pid = 5403 http_port = 60366 > start_time = 1429057609454700 collector_name = primary = 0.0.0.0:0 secondary > = 0.0.0.0:0 rx_socket_stats= [ bytes = 0 calls = 0 average_bytes = 0 > blocked_duration = blocked_count = 0 average_blocked_duration = errors = 0 > ] tx_socket_stats= [ bytes = 0 calls = 0 average_bytes = 0 blocked_duration > = 00:00:00 blocked_count = 0 average_blocked_duration = errors = 0 ] ] ] > 2015-04-14 Tue 17:26:49:455.030 PDT ubuntu-build04 [Thread 140071693285312, > Pid 5403]: primary 10.84.13.23:8086 > 2015-04-14 Tue 17:26:49:455.063 PDT ubuntu-build04 [Thread 140071693285312, > Pid 5403]: secondary 0.0.0.0:0 > 2015-04-14 Tue 17:26:49:471.317 PDT ubuntu-build04 [Thread 140071566153472, > Pid 5403]: Processing scm::EvStart in state Idle > 2015-04-14 Tue 17:26:49:474.202 PDT ubuntu-build04 [Thread 140071566153472, > Pid 5403]: Disconnect > 2015-04-14 Tue 17:26:49:474.582 PDT ubuntu-build04 [Thread 140071566153472, > Pid 5403]: Processing scm::EvDiscUpdate in state Disconnect > 2015-04-14 Tue 17:26:49:475.213 PDT ubuntu-build04 [Thread 140071566153472, > Pid 5403]: Connect : Start Connect timer 10.84.13.23:8086 > 2015-04-14 Tue 17:26:49:475.485 PDT ubuntu-build04 [Thread 140071566153472, > Pid 5403]: Processing scm::EvSandeshSend in state Connect > 2015-04-14 Tue 17:26:49:475.568 PDT ubuntu-build04 [Thread 140071566153472, > Pid 5403]: Wrong state: Connect for event: EvSandeshSend > 2015-04-14 Tue 17:26:49:475.638 PDT ubuntu-build04 [Thread 140071566153472, > Pid 5403]: Processing scm::EvSandeshSend in state Connect > 2015-04-14 Tue 17:26:49:475.650 PDT ubuntu-build04 [Thread 140071574546176, > Pid 5403]: SANDESH: Send FAILED: 1429057609475598 TCP [SYS_DEBUG]: > TcpSessionMessageLog: Session 10.84.5.39:38468::10.84.13.23:8086(-1) < Active > session connection complete controller/src/io/tcp_session.cc 228 > 2015-04-14 Tue 17:26:49:475.711 PDT ubuntu-build04 [Thread 140071566153472, > Pid 5403]: Wrong state: Connect for event: EvSandeshSend > 2015-04-14 Tue 17:26:49:475.832 PDT ubuntu-build04 [Thread 140071574546176, > Pid 5403]: 10.84.5.39:38468::10.84.13.23:8086(-1) OnSessionEvent TCP Connected > 2015-04-14 Tue 17:26:49:475.901 PDT ubuntu-build04 [Thread 140071566153472, > Pid 5403]: Processing scm::EvSandeshSend in state Connect > 2015-04-14 Tue 17:26:49:475.949 PDT ubuntu-build04 [Thread 140071574546176, > Pid 5403]: 10.84.5.39:38468::10.84.13.23:8086(-1):EvTcpConnected > 2015-04-14 Tue 17:26:49:476.022 PDT ubuntu-build04 [Thread 140071566153472, > Pid 5403]: Wrong state: Connect for event: EvSandeshSend > 2015-04-14 Tue 17:26:49:476.152 PDT ubuntu-build04 [Thread 140071566153472, > Pid 5403]: Processing scm::EvTcpConnected in state Connect > 2015-04-14 Tue 17:26:49:476.207 PDT ubuntu-build04 [Thread 140071566153472, > Pid 5403]: Connect : EvTcpConnected : Cancelling Connect timer > 2015-04-14 Tue 17:26:49:476.286 PDT ubuntu-build04 [Thread 140071566153472, > Pid 5403]: ClientInit > 2015-04-14 Tue 17:26:49:476.369 PDT ubuntu-build04 [Thread 140071566153472, > Pid 5403]: Sending Ctrl Message for > localhost:SandeshUVEAlarmTest-Client:0:Test count 1 > 2015-04-14 Tue 17:26:49:476.617 PDT ubuntu-build04 [Thread 140071566153472, > Pid 5403]: Processing scm::EvSandeshSend in state ClientInit > 2015-04-14 Tue 17:26:49:476.691 PDT ubuntu-build04 [Thread 140071566153472, > Pid 5403]: ClientInit : EvSandeshSend : SandeshModuleClientTrace > 2015-04-14 Tue 17:26:49:476.734 PDT ubuntu-build04 [Thread 140071566153472, > Pid 5403]: Received UVE message in wrong state : SandeshModuleClientTrace > 2015-04-14 Tue 17:26:49:483.062 PDT ubuntu-build04 [Thread 140071461193472, > Pid 5403]: OnMessage control in state: ClientInit > 2015-04-14 Tue 17:26:49:483.271 PDT ubuntu-build04 [Thread 140071461193472, > Pid 5403]: Processing scm::EvSandeshMessageRecv in state ClientInit > 2015-04-14 Tue 17:26:49:483.572 PDT ubuntu-build04 [Thread 140071461193472, > Pid 5403]: ClientInit : EvSandeshMessageRecv > 2015-04-14 Tue 17:26:49:483.881 PDT ubuntu-build04 [Thread 140071461193472, > Pid 5403]: Received Ctrl Message with size 0 > 2015-04-14 Tue 17:26:49:484.023 PDT ubuntu-build04 [Thread 140071461193472, > Pid 5403]: SyncUVE Syncing val name = > localhost:Test:SandeshUVEAlarmTest-Client:0 client_info= [ status = > ClientInit successful_connections = 1 pid = 5403 http_port = 60366 start_time > = 1429057609454700 collector_name = primary = 10.84.13.23:8086 secondary = > 0.0.0.0:0 rx_socket_stats= [ bytes = 0 calls = 0 average_bytes = 0 > blocked_duration = blocked_count = 0 average_blocked_duration = errors = 0 > ] tx_socket_stats= [ bytes = 0 calls = 0 average_bytes = 0 blocked_duration > = 00:00:00 blocked_count = 0 average_blocked_duration = errors = 0 ] ] seq 5 > 2015-04-14 Tue 17:26:49:484.111 PDT ubuntu-build04 [Thread 140071461193472, > Pid 5403]: SyncAllMaps for ModuleClientState without seqno , total = 1 > 2015-04-14 Tue 17:26:49:484.156 PDT ubuntu-build04 [Thread 140071461193472, > Pid 5403]: SyncAllMaps for SandeshAlarmData without seqno , total = 0 > 2015-04-14 Tue 17:26:49:484.191 PDT ubuntu-build04 [Thread 140071461193472, > Pid 5403]: SyncAllMaps for SandeshUVEData without seqno , total = 0 > 2015-04-14 Tue 17:26:49:484.290 PDT ubuntu-build04 [Thread 140071461193472, > Pid 5403]: Established > 2015-04-14 Tue 17:26:49:484.754 PDT ubuntu-build04 [Thread 140071693285312, > Pid 5403]: SyncUVE Syncing val name = > localhost:Test:SandeshUVEAlarmTest-Client:0 client_info= [ status = > Established successful_connections = 1 pid = 5403 http_port = 60366 > start_time = 1429057609454700 collector_name = a6s23 primary = > 10.84.13.23:8086 secondary = 0.0.0.0:0 rx_socket_stats= [ bytes = 977 calls > = 1 average_bytes = 977 blocked_duration = blocked_count = 0 > average_blocked_duration = errors = 0 ] tx_socket_stats= [ bytes = 1476 > calls = 1 average_bytes = 1476 blocked_duration = 00:00:00 blocked_count = 0 > average_blocked_duration = errors = 0 ] ] seq 6 > 2015-04-14 Tue 17:26:49:484.974 PDT ubuntu-build04 [Thread 140071693285312, > Pid 5403]: SyncAllMaps for ModuleClientState without seqno , total = 1 > 2015-04-14 Tue 17:26:49:485.089 PDT ubuntu-build04 [Thread 140071693285312, > Pid 5403]: SyncUVE Syncing val name = alarm1 description = alarm1 generated > acknowledged = 1 seq 2 > 2015-04-14 Tue 17:26:49:485.202 PDT ubuntu-build04 [Thread 140071693285312, > Pid 5403]: SyncUVE Syncing val name = alarm2 seq 5 > 2015-04-14 Tue 17:26:49:485.302 PDT ubuntu-build04 [Thread 140071693285312, > Pid 5403]: SyncAllMaps for SandeshAlarmData without seqno , total = 2 > 2015-04-14 Tue 17:26:49:485.368 PDT ubuntu-build04 [Thread 140071693285312, > Pid 5403]: SyncUVE Syncing val name = uve1 x = 55 seq 2 > 2015-04-14 Tue 17:26:49:485.433 PDT ubuntu-build04 [Thread 140071693285312, > Pid 5403]: SyncUVE Syncing val name = uve2 seq 5 > 2015-04-14 Tue 17:26:49:485.496 PDT ubuntu-build04 [Thread 140071693285312, > Pid 5403]: SyncAllMaps for SandeshUVEData without seqno , total = 2 > > As you can see the state did become Established. > > Thanks > > Megh > > > On Apr 14, 2015, at 8:50 AM, <aguti...@ac.upc.edu> <aguti...@ac.upc.edu> > wrote: > >> Hi, >> >> I have established 2 loops after connectToCollector. One that waits the sm >> to change to state 2 (Connected) and one that waits for state 4 >> (Established). Just after connectToCollector the status is 0. Then, >> eventually, it changes to 1 (Disconnected). Then to 2 and stays there. >> >> An extract of log: >> ... >> ]: Processing scm::EvStart in state Idle >> 2015-04-14 Tue 17:42:50:824.700 CEST Mahalanobis [Thread 140712661264128, >> Pid 29117]: Disconnect >> Current STATUS: 0 >> Current STATUS: 1 >> ... >> Current STATUS: 1 >> Handshake done (State 2) >> 2015-04-14 Tue 17:42:50:825.216 CEST Mahalanobis [Thread 140712661264128, >> Pid 29117]: Connect : Start Connect timer 192.168.100.10:8086 >> 2015-04-14 Tue 17:42:50:825.346 CEST Mahalanobis [Thread 140712661264128, >> Pid 29117]: Processing scm::EvSandeshSend in state Connect >> 2015-04-14 Tue 17:42:50:825.367 CEST Mahalanobis [Thread 140712661264128, >> Pid 29117]: Wrong state: Connect for event: EvSandeshSend >> 2015-04-14 Tue 17:42:50:825.391 CEST Mahalanobis [Thread 140712661264128, >> Pid 29117]: Processing scm::EvSandeshSend in state Connect >> 2015-04-14 Tue 17:42:50:825.408 CEST Mahalanobis [Thread 140712661264128, >> Pid 29117]: Wrong state: Connect for event: EvSandeshSend >> 2015-04-14 Tue 17:42:50:825.430 CEST Mahalanobis [Thread 140712661264128, >> Pid 29117]: Processing scm::EvSandeshSend in state Connect >> 2015-04-14 Tue 17:42:50:825.448 CEST Mahalanobis [Thread 140712661264128, >> Pid 29117]: Wrong state: Connect for event: EvSandeshSend >> ... >> Waiting to the connection to be ESTABLISHED. Current status: 2 >> Waiting to the connection to be ESTABLISHED. Current status: 2 >> ... (and keeps looping) >> >> It seems to be sending message in the connect to collector part. It doesn't >> reach the sendUVE because I set a loop that waits for state to be >> ESTABLISHED. >> >> Any guess? There may be something that I'm not doing good. "Wrong state: >> Connect for event: EvSandeshSend" is quite suspicious. >> >> Best regards, >> Alberto. >> >> Quoting Megh Bhatt <me...@juniper.net>: >> >>> Hi Alberto, >>> Please see inline ... >>> >>> On Apr 13, 2015, at 2:03 PM, <aguti...@ac.upc.edu> <aguti...@ac.upc.edu> >>> wrote: >>> >>>> Hi Megh, >>>> >>>> Thank you for the reply. I already went thru client_sm module but didn't >>>> get any clue about when does the state change, thanks. >>>> >>>> You are correct, TASK_UTIL_EXPECT_TRUE is just a conditional print. I >>>> tried to make a loop with that condition (negated) but it seems to stay >>>> forever there, so there must be something failing. >>> [Megh]: Are you saying even having loop with usleep() the condition is not >>> met? >>>> >>>> I explored the traffic using tshark and I found that there was a handshake >>>> on the ConnectToCollector, but at SandeshUVETest::Send(uve_data1) there is >>>> no message because client state machine is not in the correct state. >>>> >>>> Any clue about this? >>> [Megh]: The data will be dropped till the state moves to ESTABLISHED. >>> >>> Thanks >>> >>> Megh >>> >>>> >>>> Thank you once more for your support, >>>> Alberto. >>>> >>>> Quoting Megh Bhatt <me...@juniper.net>: >>>> >>>>> Hi Alberto, >>>>> Sorry for the delay. Please see inline ... >>>>> >>>>> On Apr 13, 2015, at 3:14 AM, <aguti...@ac.upc.edu> <aguti...@ac.upc.edu> >>>>> wrote: >>>>> >>>>>> Hi, >>>>>> >>>>>> I got the following code modifying the test suite available in the >>>>>> Sandesh C++ library folder: >>>>>> >>>>>> int port = 8086; >>>>>> ASSERT_LT(0, port); >>>>>> std::cout << "Initializing Generator" << std::endl; >>>>>> Sandesh::InitGenerator("SandeshUVEAlarmTest-Client", "192.168.100.1", >>>>>> "Test", "0", evm_.get(), 0, NULL); >>>>>> std::cout << "Connecting to collector" << std::endl; >>>>>> Sandesh::ConnectToCollector("192.168.100.10", port); >>>>>> std::cout << "Handshake done" << std::endl; >>>>>> TASK_UTIL_EXPECT_TRUE(Sandesh::client()->state() == >>>>>> SandeshClientSM::ESTABLISHED); >>>>> [Megh]: This should make sure that the client status is ESTABLISHED >>>>> before sending the message below. >>>>>> std::cout << "Connection to collector should be established" << >>>>>> std::endl; >>>>>> // add uve >>>>>> // case 0 >>>>>> SandeshUVEData uve_data1; >>>>>> uve_data1.set_name("uve1"); >>>>>> SandeshUVETest::Send(uve_data1); >>>>>> >>>>>> Here I disabled the sever initialization step as I want to use a real >>>>>> collector node (192.168.100.10). The execution is sent from IP >>>>>> 192.168.100.1. >>>>>> >>>>>> However, when evaluating the client status it's not >>>>>> SandeshClientSM::ESTABLISHED, it's in fact status 2, which is CONNECT. >>>>>> So it seems to be a step missing. >>>>>> >>>>>> On the connector log I get the following output for the execution: >>>>>> 2015-04-13 Mon 10:05:02:264.921 UTC contrail [Thread 140679780972416, >>>>>> Pid 1975]: Session 192.168.100.10:8086::192.168.100.1:54945(15)< >>>>>> Accepted session from 192.168.100.1:54945 >>>>>> >>>>>> 2015-04-13 Mon 10:05:21:736.472 UTC contrail [Thread 140679780972416, >>>>>> Pid 1975]: Session 192.168.100.10:8086::192.168.100.1:54945(15)< Read >>>>>> failed due to error 2 : End of file >>>>>> >>>>>> On the application I get the following: >>>>>> 2015-04-13 Mon 12:11:17:354.925 CEST Mahalanobis [Thread >>>>>> 140662758741952, Pid 5233]: primary 192.168.100.10:8086 >>>>>> 2015-04-13 Mon 12:11:17:354.945 CEST Mahalanobis [Thread >>>>>> 140662758741952, Pid 5233]: secondary 0.0.0.0:0 >>>>>> Handshake done >>>>>> 2015-04-13 Mon 12:11:17:355.309 CEST Mahalanobis [Thread >>>>>> 140662631671552, Pid 5233]: Processing scm::EvStart in state Idle >>>>>> 2015-04-13 Mon 12:11:17:355.415 CEST Mahalanobis [Thread >>>>>> 140662631671552, Pid 5233]: Disconnect >>>>>> 2015-04-13 Mon 12:11:17:355.566 CEST Mahalanobis [Thread >>>>>> 140662631671552, Pid 5233]: Processing scm::EvDiscUpdate in state >>>>>> Disconnect >>>>>> 2015-04-13 Mon 12:11:17:355.850 CEST Mahalanobis [Thread >>>>>> 140662631671552, Pid 5233]: Connect : Start Connect timer >>>>>> 192.168.100.10:8086 >>>>> [Megh]: From the logs it does not seem that the state machine has moved >>>>> to ESTABLISHED. Your code should have failed when checking for the state >>>>> above. >>>>>> 2015-04-13 Mon 12:11:17:355.984 CEST Mahalanobis [Thread >>>>>> 140662631671552, Pid 5233]: Processing scm::EvSandeshSend in state >>>>>> Connect >>>>>> 2015-04-13 Mon 12:11:17:356.012 CEST Mahalanobis [Thread >>>>>> 140662631671552, Pid 5233]: Wrong state: Connect for event: EvSandeshSend >>>>>> 2015-04-13 Mon 12:11:17:356.043 CEST Mahalanobis [Thread >>>>>> 140662631671552, Pid 5233]: Processing scm::EvSandeshSend in state >>>>>> Connect >>>>>> 2015-04-13 Mon 12:11:17:356.065 CEST Mahalanobis [Thread >>>>>> 140662631671552, Pid 5233]: Wrong state: Connect for event: EvSandeshSend >>>>>> 2015-04-13 Mon 12:11:17:356.093 CEST Mahalanobis [Thread >>>>>> 140662631671552, Pid 5233]: Processing scm::EvSandeshSend in state >>>>>> Connect >>>>>> 2015-04-13 Mon 12:11:17:356.116 CEST Mahalanobis [Thread >>>>>> 140662631671552, Pid 5233]: Wrong state: Connect for event: EvSandeshSend >>>>>> >>>>>> >>>>>> >>>>>> So, it seems to connects correctly but fails sending the UVE. >>>>>> >>>>>> >>>>>> >>>>>> Could anyone help me with this? Pointers to documentation would be >>>>>> really valuable. >>>>> My guess is that the TASK_UTIL_EXPECT_TRUE code is not waiting enough. >>>>> Can you please check? >>>>> >>>>> The client state machine after connecting to the collector, sends a >>>>> control message to move to ClientInit state, and after that on receipt of >>>>> the reply from the collector moves to established. You can look at the >>>>> code in sandesh_client_sm.cc for details. >>>>> https://github.com/Juniper/contrail-sandesh/blob/master/library/cpp/sandesh_client_sm.cc >>>>> >>>>> Thanks >>>>> >>>>> Megh >>>>>> >>>>>> Best regards, >>>>>> Alberto. >>>>>> >>>>>> Quoting aguti...@ac.upc.edu: >>>>>> >>>>>>> Hi Megh, >>>>>>> >>>>>>> Thanks for your help. With that I think I got the compilation at hand. >>>>>>> >>>>>>> Now I'm trying to do a small application to send one message and die. >>>>>>> >>>>>>> I defined the following toy sandesh for testing: >>>>>>> struct UveVirtualNetworkAgent { >>>>>>> 1: string name(key="ObjectVNTable") >>>>>>> 2: optional i32 cpu >>>>>>> } >>>>>>> >>>>>>> uve sandesh UveVirtualNetworkAgentTrace { >>>>>>> 1: UveVirtualNetworkAgent data; >>>>>>> } >>>>>>> >>>>>>> Then I did the following code: >>>>>>> int main() { >>>>>>> Sandesh::InitGenerator() >>>>>>> >>>>>>> UveVirtualNetworkAgent a; >>>>>>> a.set_name("TestUnit"); >>>>>>> a.set_cpu(100); >>>>>>> UveVirtualNetworkAgentTrace::Send(a); >>>>>>> } >>>>>>> >>>>>>> However I don't know which of the 2 InitGenerator functions from the >>>>>>> Sandesh module should I use and what is the meaning of each parameter. >>>>>>> >>>>>>> static bool InitGenerator(const std::string &module, >>>>>>> const std::string &source, >>>>>>> const std::string &node_type, >>>>>>> const std::string &instance_id, >>>>>>> EventManager *evm, >>>>>>> unsigned short http_port, >>>>>>> CollectorSubFn csf, >>>>>>> const std::vector<std::string> &collectors, >>>>>>> SandeshContext *client_context = NULL); >>>>>>> >>>>>>> static void InitGenerator(const std::string &module, >>>>>>> const std::string &source, >>>>>>> const std::string &node_type, >>>>>>> const std::string &instance_id, >>>>>>> EventManager *evm, >>>>>>> unsigned short http_port, >>>>>>> SandeshContext *client_context = NULL); >>>>>>> >>>>>>> Is there any source where it explains this part? I haven't found it yet. >>>>>>> >>>>>>> And one more question: Does setting name(key="ObjectVNTable") to >>>>>>> "TestUnit" create a new table in the database that I could query using >>>>>>> de API of the analytics module? >>>>>>> >>>>>>> Thank you for the support. >>>>>>> >>>>>>> Best regards, >>>>>>> Alberto. >>>>>>> >>>>>>> Quoting Megh Bhatt <me...@juniper.net>: >>>>>>> >>>>>>>> Hi Alberto, >>>>>>>> Please see inline .... >>>>>>>> >>>>>>>> On Apr 8, 2015, at 1:54 AM, >>>>>>>> aguti...@ac.upc.edu<mailto:aguti...@ac.upc.edu> wrote: >>>>>>>> >>>>>>>> Dear all, >>>>>>>> >>>>>>>> I'm trying to create a new message to send with Sandesh protocol, >>>>>>>> however I don't know how to compile the generated code. >>>>>>>> >>>>>>>> Just a high level overview which you might already know. The sandesh >>>>>>>> compiler/code generator will be present in build/bin/sandesh after you >>>>>>>> execute scons at the top level. The source code for same is at This is >>>>>>>> used to generate the python/C++ code based on the .sandesh file. The >>>>>>>> generated code - .py files for python and .cpp files for C++ need to >>>>>>>> be used with the pysandesh package for python and libsandesh for C++ >>>>>>>> in client applications to send Sandesh messages to the contrail >>>>>>>> collector. >>>>>>>> >>>>>>>> Are you using C++ or python? >>>>>>>> >>>>>>>> We intend to use this messaging for testing purposes (at the moment) >>>>>>>> by means of an extra application which will send Sandesh messages each >>>>>>>> second. >>>>>>>> >>>>>>>> >>>>>>>> I have found the following explaination for the compilation with Scons: >>>>>>>> -------- >>>>>>>> To use Sandesh, the following needs to be added to the module >>>>>>>> SConscript: >>>>>>>> / >>>>>>>> # Generate the source files >>>>>>>> SandeshGenFiles = env.SandeshGenCpp('VNS.sandesh') >>>>>>>> SandeshGenFiles += env.SandeshGenCpp('VNSwitch.sandesh') >>>>>>>> >>>>>>>> # The above returns VNS_types.h, VNS_types.cpp, VNS_constants.h >>>>>>>> # VNS_constants.cpp, VNSwitch_types.h, VNSwitch_types.cpp, >>>>>>>> # VNSwitch_constants.h, VNSwitch_constants.cpp >>>>>>>> >>>>>>>> # To include the header files above from your module's sources >>>>>>>> env.Append(CPPPATH = env['TOP']) >>>>>>>> >>>>>>>> # Extract the .cpp files to be used as sources >>>>>>>> SandeshGenSrcs = env.ExtractCpp(SandeshGenFiles) >>>>>>>> >>>>>>>> Add SandeshGenSrcs to the module source files >>>>>>>> >>>>>>>> Add libsandesh, and libbase to the module libraries. >>>>>>>> -------- >>>>>>>> >>>>>>>> However I don't really get what's going on (I'm new to Scons). >>>>>>>> >>>>>>>> The SandeshGenCpp function/ scons builder is defined in >>>>>>>> tools/build/rules.py - https://github.com/Juniper/contrail-build >>>>>>>> >>>>>>>> Below is a relevant snippet ... >>>>>>>> >>>>>>>> >>>>>>>> # SandeshGenCpp Methods >>>>>>>> def SandeshCppBuilder(target, source, env): >>>>>>>> opath = target[0].dir.path >>>>>>>> sname = os.path.join(opath, os.path.splitext(source[0].name)[0]) >>>>>>>> >>>>>>>> code = subprocess.call(env['SANDESH'] + ' --gen cpp --gen html -I >>>>>>>> controller/src/ -I tools -out ' >>>>>>>> + opath + " " + source[0].path, shell=True) >>>>>>>> if code != 0: >>>>>>>> raise SCons.Errors.StopError(SandeshCodeGeneratorError, >>>>>>>> 'SandeshCpp code generation failed') >>>>>>>> tname = sname + "_html_template.cpp" >>>>>>>> hname = os.path.basename(sname + ".xml") >>>>>>>> cname = sname + "_html.cpp" >>>>>>>> if not env.Detect('xxd'): >>>>>>>> raise SCons.Errors.StopError(SandeshCodeGeneratorError, >>>>>>>> 'xxd not detected on system') >>>>>>>> os.system("echo \"namespace {\"" + " >> " + cname) >>>>>>>> os.system("(cd " + opath + " ; xxd -i " + hname + " >> " + >>>>>>>> os.path.basename(cname) + " )") >>>>>>>> os.system("echo \"}\"" + " >> " + cname) >>>>>>>> os.system("cat " + tname + " >> " + cname) >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> As you can see, it runs build/bin/sandesh --gen cpp --gen html <other >>>>>>>> options> <.sandesh file> to produce the .cpp, .h files which then need >>>>>>>> to be compiled in the client application. >>>>>>>> >>>>>>>> >>>>>>>> I tried to copy the SConscript of the control module and adapt it but >>>>>>>> without results. >>>>>>>> >>>>>>>> Can anyone help me? >>>>>>>> >>>>>>>> Hope the above helps and please let me know if any more information is >>>>>>>> needed. >>>>>>>> >>>>>>>> Thanks >>>>>>>> >>>>>>>> Megh >>>>>>>> >>>>>>>> >>>>>>>> Best Regards, >>>>>>>> Alberto. >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> _______________________________________________ >>>>>>>> Dev mailing list >>>>>>>> Dev@lists.opencontrail.org<mailto:Dev@lists.opencontrail.org> >>>>>>>> http://lists.opencontrail.org/mailman/listinfo/dev_lists.opencontrail.org >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>> >>>> >>> >>> >> >> > > > _______________________________________________ > Dev mailing list > Dev@lists.opencontrail.org > http://lists.opencontrail.org/mailman/listinfo/dev_lists.opencontrail.org _______________________________________________ Dev mailing list Dev@lists.opencontrail.org http://lists.opencontrail.org/mailman/listinfo/dev_lists.opencontrail.org