1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2020] [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 methods of Session/Connection creation and Subscription to
25 #include "SessionHandler.hpp"
26 #include "InitConfig.hpp"
30 /* Default constructor */
31 SessionHandler::SessionHandler()
37 SessionHandler::~SessionHandler()
41 /**********************************************************************
42 Description : This function will create Connection, Session, and
43 subscribe. These sysrepo class provide netconf connection
46 Return : true - started successful
48 **********************************************************************/
49 bool SessionHandler::init()
53 O1_LOG("\nO1 SessionHandler : Initialization done");
54 mConn = createConnection();
55 O1_LOG("\nO1 SessionHandler : Initialization done");
56 mSess = createSession(mConn);
57 mSub = createSubscribe(mSess);
58 O1_LOG("\nO1 SessionHandler : Initialization done");
59 //InitConfig initConf;
60 InitConfig::instance().init(mSess);
63 catch( const std::exception& e )
65 O1_LOG("\nO1 SessionHandler : Exception : %s", e.what());
70 /**********************************************************************
71 Description : This function will create Connection instance and
74 Return : sysrepo::S_Connection instance
75 **********************************************************************/
76 sysrepo::S_Connection SessionHandler::createConnection()
78 sysrepo::S_Connection conn(new sysrepo::Connection());
83 /**********************************************************************
84 Description : This function will create Session instance and
86 Params[In] : sysrepo::S_Connection
87 Return : sysrepo::S_Session instance
88 **********************************************************************/
89 sysrepo::S_Session SessionHandler::createSession(sysrepo::S_Connection conn)
91 sysrepo::S_Session sess(new sysrepo::Session(conn));
97 /**********************************************************************
98 Description : This function will create Subscribe instance and
100 Params[In] : sysrepo::S_Session
101 Return : sysrepo::S_Subscribe instance
102 **********************************************************************/
103 sysrepo::S_Subscribe SessionHandler::createSubscribe(sysrepo::S_Session sess)
105 sysrepo::S_Subscribe subscrb(new sysrepo::Subscribe(sess));
106 if(subscribeModule(subscrb))
108 O1_LOG("\nO1 SessionHandler : Subscription done successfully");
114 /**********************************************************************
115 Description : This function will create a callback object and register
117 Params[In] : sysrepo::S_Subscribe
118 Return : true - on success
119 **********************************************************************/
120 bool SessionHandler::subscribeModule(sysrepo::S_Subscribe subscrb)
122 sysrepo::S_Callback alarmOranCb(new AlarmOranYangModel());
124 subscrb->oper_get_items_subscribe(ALARM_MODULE_NAME_ORAN, \
125 ALARM_MODULE_PATH_ORAN, \
130 /**********************************************************************
132 **********************************************************************/