Merge "Restructure O1 module to run as a thread in O-DU High binary [Issue-Id: ODUHIG...
[o-du/l2.git] / src / o1 / SessionHandler.cpp
index f4108c0..1f9c0cf 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 <iostream>
 
-
+using namespace std;
 /* Default constructor */
 SessionHandler::SessionHandler()
 {    
@@ -46,10 +51,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 )
    {