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
22 #include "SessionHandler.hpp"
25 /* Default constructor */
26 SessionHandler::SessionHandler()
32 SessionHandler::~SessionHandler()
36 /**********************************************************************
37 Description : This function will create Connection, Session, and
38 subscribe. These sysrepo class provide netconf connection
41 Return : true - started successful
43 **********************************************************************/
44 bool SessionHandler::init()
48 mConn = createConnection();
49 mSess = createSession(mConn);
50 mSub = createSubscribe(mSess);
51 O1_LOG("\nO1 SessionHandler : Initialization done");
54 catch( const std::exception& e )
56 O1_LOG("\nO1 SessionHandler : Exception : %s", e.what());
61 /**********************************************************************
62 Description : This function will create Connection instance and
65 Return : sysrepo::S_Connection instance
66 **********************************************************************/
67 sysrepo::S_Connection SessionHandler::createConnection()
69 sysrepo::S_Connection conn(new sysrepo::Connection());
74 /**********************************************************************
75 Description : This function will create Session instance and
77 Params[In] : sysrepo::S_Connection
78 Return : sysrepo::S_Session instance
79 **********************************************************************/
80 sysrepo::S_Session SessionHandler::createSession(sysrepo::S_Connection conn)
82 sysrepo::S_Session sess(new sysrepo::Session(conn));
88 /**********************************************************************
89 Description : This function will create Subscribe instance and
91 Params[In] : sysrepo::S_Session
92 Return : sysrepo::S_Subscribe instance
93 **********************************************************************/
94 sysrepo::S_Subscribe SessionHandler::createSubscribe(sysrepo::S_Session sess)
96 sysrepo::S_Subscribe subscrb(new sysrepo::Subscribe(sess));
97 if(subscribeModule(subscrb))
99 O1_LOG("\nO1 SessionHandler : Subscription done successfully");
105 /**********************************************************************
106 Description : This function will create a callback object and register
108 Params[In] : sysrepo::S_Subscribe
109 Return : true - on success
110 **********************************************************************/
111 bool SessionHandler::subscribeModule(sysrepo::S_Subscribe subscrb)
113 sysrepo::S_Callback alarmOranCb(new AlarmOranYangModel());
115 subscrb->oper_get_items_subscribe(ALARM_MODULE_NAME_ORAN, \
116 ALARM_MODULE_PATH_ORAN, \
121 /**********************************************************************
123 **********************************************************************/