1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2020-2021] [HCL Technologies Ltd.] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /* This file contains the O1App class which is responsible for running/starting
20 all the O1 modules in a thread. It inherits the Thread class and Singleton
25 #include "GlobalDefs.hpp"
26 #include "SessionHandler.hpp"
27 #include "ConfigInterface.h"
30 #include "VesUtils.hpp"
31 #include "VesEventHandler.hpp"
32 /*******************************************************************
41 * - Constructor intialization
45 ******************************************************************/
47 O1App::O1App() : mUxSocketServer(O1::ALARM_SOCK_PATH)
52 /*******************************************************************
65 ******************************************************************/
72 /*******************************************************************
74 * @brief Runs the O1 modules as a thread
81 * - Implements the "run" function of Thread class.
82 * Starts all the O1 modules.
86 * @return true : success
88 ******************************************************************/
93 SessionHandler sessHdlr;
94 /*send ves PNF registration request*/
95 VesEventHandler vesEvtHdr;
96 O1_LOG("\nO1 O1App : Sending VES Event");
97 if(!vesEvtHdr.send(VesEventType::PNF_REGISTRATION))
99 O1_LOG("\nO1 O1App : Could not send VES Request");
103 /* Start Netconf session and subscribe to yang modules */
106 if( !sessHdlr.init() )
108 O1_LOG("\nO1 O1App : SessionHandler initialization failed ");
112 catch( const std::exception& e )
114 O1_LOG("\nO1 O1App : Exception : %s", e.what());
118 /* Start the Unix Socket Server to listen for alarm messages */
119 if( mUxSocketServer.start() )
122 if(mUxSocketServer.setAffinity(O1::CPU_CORE))
124 O1_LOG("\nO1 O1App : CPU affinity set " );
125 mUxSocketServer.printAffinity();
129 if( mUxSocketServer.isRunning() )
131 mStartupStatus = true;
132 O1_LOG("\nO1 O1App : Unix Socket server started\n");
136 O1_LOG("\nO1 O1App : Unix Socket server failed to start\n");
139 /* Wait for the Unix Socket Server thread to end*/
140 mUxSocketServer.join();
144 O1_LOG("\nO1 O1App : Unix Socket server failed to start\n");
150 /*******************************************************************
152 * @brief Check if the O1 Module is fully up and running
156 * Function : getStartupStatus
159 * - Returns the status of O1App whether it is fully up
163 * @return true : started
164 * false : not started
165 ******************************************************************/
167 bool O1App::getStartupStatus() const
169 return mStartupStatus;
172 /*******************************************************************
174 * @brief Cleanup O1App
181 * - Implements the "cleanUp" function of Thread class to
182 * take care of any clean up required for O1 components
183 * before stopping the thread.
187 ******************************************************************/
189 void O1App::cleanUp(void)
191 /* Stop the socket server thread */
192 mUxSocketServer.stop();