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"
27 #include "NrCellCb.hpp"
28 #include "NrCellDuCb.hpp"
29 #include "RrmPolicyCb.hpp"
32 /* Default constructor */
33 SessionHandler::SessionHandler()
39 SessionHandler::~SessionHandler()
43 /**********************************************************************
44 Description : This function will create Connection, Session, and
45 subscribe. These sysrepo class provide netconf connection
48 Return : true - started successful
50 **********************************************************************/
51 bool SessionHandler::init()
55 mConn = createConnection();
58 O1_LOG("\nO1 SessionHandler : Connection created");
59 //removing nacm module temperary for auth issue resolve
60 //mConn.remove_module("ietf-netconf-acm");
61 mSess = createSession(mConn);
64 O1_LOG("\nO1 SessionHandler : Session created");
65 mSub = createSubscribe(mSess);
68 O1_LOG("\nO1 SessionHandler : Subscription created");
69 if(InitConfig::instance().init(mSess))
80 O1_LOG("\nO1 SessionHandler : Subscription failed");
86 O1_LOG("\nO1 SessionHandler : Session failed");
92 O1_LOG("\nO1 SessionHandler : connection failed");
96 catch( const std::exception& e )
98 O1_LOG("\nO1 SessionHandler : Exception : %s", e.what());
103 /**********************************************************************
104 Description : This function will create Connection instance and
107 Return : sysrepo::S_Connection instance
108 **********************************************************************/
109 sysrepo::S_Connection SessionHandler::createConnection()
111 sysrepo::S_Connection conn(new sysrepo::Connection());
116 /**********************************************************************
117 Description : This function will create Session instance and
119 Params[In] : sysrepo::S_Connection
120 Return : sysrepo::S_Session instance
121 **********************************************************************/
122 sysrepo::S_Session SessionHandler::createSession(sysrepo::S_Connection conn)
124 sysrepo::S_Session sess(new sysrepo::Session(conn));
130 /**********************************************************************
131 Description : This function will create Subscribe instance and
133 Params[In] : sysrepo::S_Session
134 Return : sysrepo::S_Subscribe instance
135 **********************************************************************/
136 sysrepo::S_Subscribe SessionHandler::createSubscribe(sysrepo::S_Session sess)
138 sysrepo::S_Subscribe subscrb(new sysrepo::Subscribe(sess));
139 if(subscribeModule(subscrb))
141 O1_LOG("\nO1 SessionHandler : Subscription done successfully");
147 /**********************************************************************
148 Description : This function will create a callback object and register
150 Params[In] : sysrepo::S_Subscribe
151 Return : true - on success
152 **********************************************************************/
153 bool SessionHandler::subscribeModule(sysrepo::S_Subscribe subscrb)
155 sysrepo::S_Callback alarmOranCb(new AlarmOranYangModel());
157 subscrb->oper_get_items_subscribe(ALARM_MODULE_NAME_ORAN, \
158 ALARM_MODULE_PATH_ORAN, \
161 sysrepo::S_Callback nrCellCb(new NrCellCb());
163 subscrb->oper_get_items_subscribe(CELL_STATE_MODULE_NAME, \
164 CELL_STATE_MODULE_PATH, \
166 subscrb->module_change_subscribe(CELL_STATE_MODULE_NAME, nrCellCb);
168 sysrepo::S_Callback nrCellDuCb(new NrCellDuCb());
169 subscrb->oper_get_items_subscribe(MANAGED_ELEMENT_MODULE_NAME, \
170 MANAGED_ELEMENT_MODULE_PATH, \
172 subscrb->module_change_subscribe(MANAGED_ELEMENT_MODULE_NAME, nrCellDuCb);
174 sysrepo::S_Callback rrmPolicyCb(new RrmPolicyCb());
175 subscrb->oper_get_items_subscribe(RRMPOLICY_MODULE_NAME, \
176 RRMPOLICY_MODULE_PATH, \
178 subscrb->module_change_subscribe(RRMPOLICY_MODULE_NAME, rrmPolicyCb);
183 /**********************************************************************
185 **********************************************************************/