[Epic-ID: ODUHIGH-557][Task-ID: ODUHIGH-560] Enable/Disable core affinity at compile...
[o-du/l2.git] / src / o1 / SessionHandler.cpp
index f4108c0..4fbe390 100644 (file)
 /* This file contains methods of Session/Connection creation and Subscription to
    YANG modules */
 
+#include <stdio.h>
+#include <stdlib.h>
+#include "sysrepo.h"
 #include "SessionHandler.hpp"
+#include "InitConfig.hpp"
+#include "NrCellCb.hpp"
+#include "NrCellDuCb.hpp"
+#include "RrmPolicyCb.hpp"
 
-
+using namespace std;
 /* Default constructor */
 SessionHandler::SessionHandler()
 {    
@@ -30,7 +37,7 @@ SessionHandler::SessionHandler()
 
 /* Destructor */
 SessionHandler::~SessionHandler()
-{  
+{
 }
 
 /********************************************************************** 
@@ -46,10 +53,45 @@ bool SessionHandler::init()
    try
    {
       mConn = createConnection();
-      mSess = createSession(mConn);
-      mSub  = createSubscribe(mSess);
-      O1_LOG("\nO1 SessionHandler : Initialization done");
-      return true;
+      if(mConn != NULL)
+      {
+         O1_LOG("\nO1 SessionHandler : Connection created");
+         //removing nacm module temperary for auth issue resolve
+         //mConn.remove_module("ietf-netconf-acm");
+         mSess = createSession(mConn);
+         if(mSess != NULL)
+         {
+            O1_LOG("\nO1 SessionHandler : Session created");
+            mSub  = createSubscribe(mSess);
+            if(mSub != NULL)
+            {
+               O1_LOG("\nO1 SessionHandler : Subscription created");
+               if(InitConfig::instance().init(mSess))
+               {
+                  return true;
+               }
+               else
+               {
+                  return false;
+               }
+            }
+            else 
+            {
+               O1_LOG("\nO1 SessionHandler : Subscription failed");
+               return false;
+            }
+         }
+         else
+         {
+            O1_LOG("\nO1 SessionHandler : Session failed");
+            return false;
+         }
+      }
+      else
+      {
+         O1_LOG("\nO1 SessionHandler : connection failed");
+         return false;
+      }
    }
    catch( const std::exception& e )
    {
@@ -115,6 +157,26 @@ bool SessionHandler::subscribeModule(sysrepo::S_Subscribe subscrb)
    subscrb->oper_get_items_subscribe(ALARM_MODULE_NAME_ORAN, \
                                      ALARM_MODULE_PATH_ORAN, \
                                      alarmOranCb);
+
+   sysrepo::S_Callback nrCellCb(new NrCellCb());
+
+   subscrb->oper_get_items_subscribe(CELL_STATE_MODULE_NAME, \
+                                     CELL_STATE_MODULE_PATH, \
+                                     nrCellCb);
+   subscrb->module_change_subscribe(CELL_STATE_MODULE_NAME, nrCellCb);
+
+   sysrepo::S_Callback nrCellDuCb(new NrCellDuCb());
+   subscrb->oper_get_items_subscribe(MANAGED_ELEMENT_MODULE_NAME, \
+                                     MANAGED_ELEMENT_MODULE_PATH, \
+                                     nrCellDuCb);
+   subscrb->module_change_subscribe(MANAGED_ELEMENT_MODULE_NAME, nrCellDuCb);
+
+   sysrepo::S_Callback rrmPolicyCb(new RrmPolicyCb());
+   subscrb->oper_get_items_subscribe(RRMPOLICY_MODULE_NAME, \
+                                     RRMPOLICY_MODULE_PATH, \
+                                     rrmPolicyCb);
+   subscrb->module_change_subscribe(RRMPOLICY_MODULE_NAME, rrmPolicyCb);
+
    return true;
 }