Edit-conf changes for CLA use case. 51/6151/7
authorHariomGupta <hariom.g@hcl.com>
Thu, 27 May 2021 07:55:42 +0000 (13:25 +0530)
committerHariomGupta <hariom.g@hcl.com>
Mon, 7 Jun 2021 08:31:34 +0000 (14:01 +0530)
Issue-Id: ODUHIGH-328

Signed-off-by: HariomGupta <hariom.g@hcl.com>
Change-Id: I4a3b798ec4c9453fa140f15214df0b245efcd41e

20 files changed:
build/common/o1.mak
build/common/ves.mak
build/config/nacm_config.xml [new file with mode: 0644]
build/yang/o-ran-sc-du-hello-world.yang [new file with mode: 0644]
docs/README
docs/installation-guide.rst
src/du_app/du_cell_mgr.c
src/du_app/du_mgr_main.c
src/du_app/du_msg_hdl.c
src/o1/ConfigInterface.cpp
src/o1/ConfigInterface.h
src/o1/GlobalDefs.hpp
src/o1/InitConfig.hpp
src/o1/NrCellCb.cpp [new file with mode: 0644]
src/o1/NrCellCb.hpp [new file with mode: 0644]
src/o1/NrCellInfo.cpp [new file with mode: 0644]
src/o1/NrCellInfo.hpp [new file with mode: 0644]
src/o1/NrCellList.cpp [new file with mode: 0644]
src/o1/NrCellList.hpp [new file with mode: 0644]
src/o1/SessionHandler.cpp

index 4b27b80..f643f37 100755 (executable)
@@ -25,6 +25,10 @@ CPP_SRCS=$(wildcard $(SRC_DIR)/*.cpp)
 CPP_OBJS=$(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(CPP_SRCS))
 
 PLTFRM_FLAGS=
+ifeq ($(NODE),TEST_STUB)
+PLTFRM_FLAGS+=-DODU_TEST_STUB
+endif
+
 lib: $(LIB_DIR)/libo1.a
 include $(COM_BUILD_DIR)/compile.mak
 
index 4f50d2a..c03ea9b 100644 (file)
@@ -41,14 +41,14 @@ I_OPTS+=-I$(ROOT_DIR)/src/o1
 
 $(LIB_DIR)/libo1.a:$(CPP_OBJS)
                  @echo -e "Creating Archive $(COLOR) $@ $(REVERT_COLOR)"
-                 $(Q)ar -cr $(LIB_DIR)/libo1.a $(CPP_OBJS)
+                 $(Q)ar -cr $(LIB_DIR)/libves.a $(CPP_OBJS)
 
 #-------------------------------------------------------------#
 #Clean macros
 #-------------------------------------------------------------#
 clean:
                  @echo -e "$(COLOR_RED)Cleaning O1$(REVERT_COLOR)"
-                 $(Q)\rm -f $(LIB_DIR)/libo1.a $(CPP_OBJS)
+                 $(Q)\rm -f $(LIB_DIR)/libves.a $(CPP_OBJS)
 
 #**********************************************************************
 #         End of file
diff --git a/build/config/nacm_config.xml b/build/config/nacm_config.xml
new file mode 100644 (file)
index 0000000..8c60f40
--- /dev/null
@@ -0,0 +1,25 @@
+<nacm xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm">
+  <enable-nacm>true</enable-nacm>
+  <read-default>permit</read-default>
+  <write-default>deny</write-default>
+  <exec-default>permit</exec-default>
+  <enable-external-groups>true</enable-external-groups>
+  <groups>
+    <group>
+      <name>sudo</name>
+      <user-name>netconf</user-name>
+    </group>
+  </groups>
+  <rule-list>
+    <name>sudo-rules</name>
+    <group>sudo</group>
+    <rule>
+      <name>allow-all-sudo</name>
+      <module-name>*</module-name>
+      <path>/</path>
+      <access-operations>*</access-operations>
+      <action>permit</action>
+      <comment>Corresponds all the rules under the sudo group as defined in O-RAN.WG4.MP.0-v05.00</comment>
+    </rule>
+  </rule-list>
+</nacm>
diff --git a/build/yang/o-ran-sc-du-hello-world.yang b/build/yang/o-ran-sc-du-hello-world.yang
new file mode 100644 (file)
index 0000000..1106717
--- /dev/null
@@ -0,0 +1,275 @@
+module o-ran-sc-du-hello-world {
+  yang-version 1.1;
+  namespace "urn:o-ran-sc:yang:o-ran-sc-du-hello-world";
+  prefix duhw;
+
+  organization
+    "O-RAN Software Community";
+  contact
+    "www.o-ran-sc.org";
+  description
+    "This module contains the O-RAN Software Community Distributed Unit
+     API description. This schema was created to support the
+     O-RAN-SC D-Release RSAC use case.
+     This standalone model is the absolute minimum and therefore
+     called 'hello-world'.
+
+     Copyright 2021 the O-RAN Software Community.
+
+     Licensed under the Apache License, Version 2.0 (the 'License');
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an 'AS IS' BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.";
+
+  revision 2021-04-08 {
+    description
+      "Updates based on the RSAC call 2021-04-08.";
+    reference
+      "https://wiki.o-ran-sc.org/pages/viewpage.action?pageId=20878423";
+  }
+  revision 2021-03-06 {
+    description
+      "initial revision";
+    reference
+      "https://wiki.o-ran-sc.org/pages/viewpage.action?pageId=20878423";
+  }
+
+  // TypeDefinitions
+
+  typedef connection-status {
+    type enumeration {
+      enum disconnected {
+        value 0;
+        description
+          "The connection to the remote network function is not established.";
+      }
+      enum connecting {
+        value 1;
+        description
+          "The system is about to connect to the remote network function.";
+      }
+      enum connected {
+        value 2;
+        description
+          "The system is connected to the remote network function.";
+      }
+      enum disconnecting {
+        value 3;
+        description
+          "The system is about to disconnect from the remote network
+           function.";
+      }
+      enum unable-to-connect {
+        value 4;
+        description
+          "This value is reported, when the system tried several times
+           to connect and finally gave up.";
+      }
+    }
+    description
+      "A non extensible enumeration representing a connection status.";
+  }
+
+  typedef o-ru-reference {
+    type leafref {
+      path "/network-function/du-to-ru-connection/name";
+    }
+    description
+      "A reference to a remote network function representing an O-RU.";
+  }
+
+  // Abstract object classes - groupings
+
+  grouping connection-grp {
+    description
+      "An abstract object class representing a connection or link to an
+       external component.";
+    leaf name {
+      type string;
+      description
+        "It is proposed to use the network unique identifier of the remote
+         network function.
+         Note: After discussion the string was not restricted by a 'length'
+         statement of a 'pattern' statement. Please avoid leading and ending
+         spaces and consecutive spaces and any character outside of UTF-8-";
+    }
+    leaf operational-state {
+      type enumeration {
+        enum DISABLED {
+          description
+            "The resource is not functional.";
+        }
+        enum ENABLED {
+          description
+            "The resource is functional.";
+        }
+      }
+      config false;
+      description
+        "Operational state of a connection. Indicates
+         whether the resource is functional (ENABLED) or not (DISABLED).";
+      reference
+        "3GPP TS 28.625 and ITU-T X.731";
+    }
+    leaf administrative-state {
+      type enumeration {
+        enum LOCKED {
+          description
+            "LOCKED refers to a situation which is NOT considered as
+             ‘normal operation'. Therefore, the O-DU will shut down the
+             connection to the related O-RU, when the value is set to LOCKED.";
+        }
+        enum UNLOCKED {
+          description
+            "UNLOCKED refers to a situation which is considered as
+             'normal operation'. Therefore, the O-DU will establish the
+             connection to the related O-RU, when the value is set to UNLOCKED.";
+        }
+        enum SHUTTING_DOWN {
+          description
+            "This value should not be used. At least the system
+             behavior is not defined.";
+        }
+      }
+      default "LOCKED";
+      description
+        "Administrative state of a connection.";
+      reference
+        "3GPP TS 28.625 and ITU-T X.731";
+    }
+    leaf cell-state {
+      type enumeration {
+        enum IDLE {
+          description
+            "Indicates whether the O-RU is not in use.";
+        }
+        enum INACTIVE {
+          description
+            "Indicates whether the O-RU is in use but not
+             configured to carry traffic.";
+        }
+        enum ACTIVE {
+          description
+            "Indicates whether the O-RU is in use and
+             configured to carry traffic.";
+        }
+      }
+      config false;
+      description
+        "Cell state of the O-RU instance.";
+      reference
+        "3GPP TS 28.625";
+    }
+    leaf status {
+      type connection-status;
+      default "disconnected";
+      config false;
+      description
+        "The value represents the connection status. ";
+    }
+  }
+
+  grouping network-function-grp {
+    description
+      "An abstract object class grouping the O-RAN-SC-DU parameters with
+       focus on RSAC D-release Closed-Loop use case.";
+    list du-to-ru-connection {
+      key "name";
+      description
+        "A list of connection objects to O-RAN-SC radio units.";
+      uses connection-grp;
+    }
+  }
+
+  grouping rpc-output {
+    description
+      "A generic RPC output syntax.";
+    leaf response-status {
+      type enumeration {
+        enum ok {
+          value 200;
+          description
+            "The system has successfully performed that request.";
+        }
+        enum accepted {
+          value 202;
+          description
+            "The system has received and accepted the request. It continues
+             processing the request. The final status of the processing
+             procedures are reported by a notification service. This response
+             status is typically for long running transactions.";
+        }
+        enum internal-server-error {
+          value 500;
+          description
+            "The request cannot be performed.";
+        }
+      }
+      mandatory true;
+      description
+        "The response status related to the corresponding request.
+         Its values are inspired by HTTP response status codes.";
+      reference
+        "RFC 7231 – Response Status Codes - Section 6.3.4";
+    }
+    leaf message {
+      type string;
+      description
+        "A human readable text complementary to the response status. ";
+    }
+  }
+
+  // Data nodes
+
+  container network-function {
+    description
+      "The root container for the configuration and operational data.
+       The object implements the 'network-function-grp'";
+    uses network-function-grp;
+  }
+
+  // Remote procedure calls - actions on root level
+
+  rpc connect {
+    status deprecated;
+    description
+      "An action to establish the connection to a remote network function.";
+    input {
+      leaf remote-network-function {
+        type o-ru-reference;
+        mandatory true;
+        description
+          "An reference to a remote network function - an O-RU - to which
+           a connection should be established.";
+      }
+    }
+    output {
+      uses rpc-output;
+    }
+  }
+
+  rpc disconnect {
+    status deprecated;
+    description
+      "An action to destroy the connection to a remote network function.";
+    input {
+      leaf remote-network-function {
+        type o-ru-reference;
+        mandatory true;
+        description
+          "An reference to a remote network function - an O-RU - to which
+           the connection should be destroyed.";
+      }
+    }
+    output {
+      uses rpc-output;
+    }
+  }
+}
index d0671ac..31958a7 100644 (file)
@@ -58,6 +58,7 @@ C. Pre-requisite for O1 Interface (Required only if run with O1 interface enable
    $cd l2/build/yang
    $sysrepoctl -i o-ran-sc-odu-alarm-v1.yang
    $sysrepoctl -i o-ran-sc-odu-interface-v1.yang
+   $sysrepoctl -i o-ran-sc-du-hello-world.yang
 
 4. Configure the startup IP and Port configurations for DU, CU and RIC
 
@@ -72,13 +73,22 @@ C. Pre-requisite for O1 Interface (Required only if run with O1 interface enable
 
    $cd l2/build/config
 
-   Open the netconfConfig.xml and edit the desired MAC address, IP, Port, Username and Password for VES PNF Registration.
+   Open the netconfConfig.json and edit the desired MAC address, IP, Port, Username and Password for VES PNF Registration.
 
 6. Configure the VES server details to send VES Events
 
    $cd l2/build/config
 
-   Open the vesConfig.xml and edit the desired IP, Port, Username and Password to send VES Event.
+   Open the vesConfig.json and edit the desired IP, Port, Username and Password to send VES Event.
+
+7. Configure the nacm module to provide access to new user
+
+   $cd l2/build/config
+
+   Open the nacm_config.xml and edit the desired user-name to provide the access to that user.
+
+   $sysrepocfg --import=nacm_config.xml --datastore running --module  ietf-netconf-acm
+
 
 
 D. How to Clean and Build:
index 700180e..2aa8f5b 100644 (file)
@@ -147,22 +147,50 @@ Setting up Netconf server
 
 - Install the YANG modules
 
-   - Ubuntu : 
-    
+   - Ubuntu :
+
       | cd <O-DU High Directory>/l2/build/yang
       | sysrepoctl -i ./yang/o-ran-sc-odu-alarm-v1.yang
       | sysrepoctl -i ./yang/o-ran-sc-odu-interface-v1.yang
+      | sysrepoctl -i ./yang/o-ran-sc-du-hello-world.yang
 
 - Configure the startup IP and Port configurations for DU, CU and RIC
 
-   - Ubuntu : 
-    
+   - Ubuntu :
+
       | cd <O-DU High Directory>/l2/build/config
       |
       | Open the startup_config.xml and edit the desired IP and Port for CU, DU and RIC.
       | Then load the configuration in the sysrepo running datastore using the command below
       |
-      | sysrepocfg --import=startup_config.xml --datastore running --module  o-ran-sc-odu-interface-v1 
+      | sysrepocfg --import=startup_config.xml --datastore running --module  o-ran-sc-odu-interface-v1
+
+- Configure the netconf server details for VES PNF Event
+
+   - Ubuntu :
+
+      | cd <O-DU High Directory>/l2/build/config
+      |
+      | Open the netconfConfig.json and edit the desired MAC address, IP, Port, Username and Password for VES PNF Registration.
+
+-  Configure the VES server details to send VES Events
+
+   - Ubuntu :
+
+      | cd <O-DU High Directory>/l2/build/config
+      |
+      |  Open the vesConfig.json and edit the desired IP, Port, Username and Password to send VES Event.
+
+- Configure the nacm module to provide access to new user
+
+   - Ubuntu :
+
+      | cd <O-DU High Directory>/l2/build/config
+      |
+      | Open the nacm_config.xml and edit the desired user-name to provide the access to that user.
+      |
+      | $sysrepocfg --import=nacm_config.xml --datastore running --module  ietf-netconf-acm
+
 
 Compilation
 ------------
index a06b642..8d600cc 100644 (file)
 #include "du_cell_mgr.h"
 
 #ifdef O1_ENABLE
+
 #include "AlarmInterface.h"
-  
+#include "ConfigInterface.h"
+
 #endif
 
 /*******************************************************************
@@ -203,6 +204,7 @@ uint8_t duHandleCellUpInd(Pst *pst, OduCellId *cellId)
 #ifdef O1_ENABLE
       DU_LOG("\nINFO   -->  DU APP : Raise cell UP alarm for cell id=%d", cellId->cellId);
       raiseCellAlrm(CELL_UP_ALARM_ID, cellId->cellId);
+      setCellOpState(cellId->cellId, ENABLED, ACTIVE);
 #endif
    }
 
index 6bc11c8..76066da 100644 (file)
@@ -33,6 +33,7 @@
 #ifdef O1_ENABLE
 
 #include "O1Interface.h"
+#include "ConfigInterface.h"
 
 #endif
 
@@ -84,6 +85,52 @@ uint8_t duAppInit(SSTskId sysTskId)
    return ROK;
 }
 
+#ifdef O1_ENABLE
+/*******************************************************************
+ *
+ * @brief Bring the cell Up
+ *
+ * @details
+ *
+ *    Function : bringCellUp
+ *
+ *    Functionality:
+ *       - Bring the cell Up when requested from OAM
+ *
+ * @params[in] Cell Id
+ * @return true     - success
+ *         false    - failure
+ *
+ * ****************************************************************/
+
+bool bringCellUp(uint16_t cellId)
+{
+   return true;
+}
+
+/*******************************************************************
+ *
+ * @brief Bring the cell Down
+ *
+ * @details
+ *
+ *    Function : bringCellDown
+ *
+ *    Functionality:
+ *       - Bring the cell Down when requested from OAM
+ *
+ * @params[in] Cell Id
+ * @return true     - success
+ *         false    - failure
+ *
+ * ****************************************************************/
+
+bool bringCellDown(uint16_t cellId)
+{
+   return true;
+}
+#endif
+
 /*******************************************************************
  *
  * @brief Initializes EGTP
@@ -444,7 +491,6 @@ uint8_t tst(void)
    if(start_O1_module() != ROK)
       return RFAILED;
 #endif
-
    //Initialize TAPA layers
    if(duInit() != ROK)
    {
index 5a09fe3..ba1a48a 100644 (file)
@@ -43,6 +43,7 @@
 #ifdef O1_ENABLE
 
 #include "AlarmInterface.h"
+#include "ConfigInterface.h"
 
 #endif 
 
@@ -1616,6 +1617,7 @@ uint8_t duHandleStopInd(Pst *pst, OduCellId *cellId)
 #ifdef O1_ENABLE
       DU_LOG("\nINFO   -->  DU APP : Raise cell down alarm for cell id=%d", cellId->cellId);
       raiseCellAlrm(CELL_DOWN_ALARM_ID, cellId->cellId);
+      setCellOpState(cellId->cellId, DISABLED, INACTIVE);
 #endif
    }
 
index 0a283ae..76c584d 100644 (file)
@@ -25,6 +25,7 @@
 #include "UnixSocketClient.hpp"
 #include "SessionHandler.hpp"
 #include "InitConfig.hpp"
+#include "NrCellList.hpp"
 
 StartupConfig g_cfg;
 
@@ -145,6 +146,30 @@ uint8_t getStartupConfigForStub(StartupConfig *cfg)
    return O1::FAILURE;
 }
 
+/*******************************************************************
+ *
+ * @brief update cell and operational state
+ *
+ * @details
+ *
+ *    Function : setCellOpState
+ *
+ *    Functionality:
+ *      - send update of cell and operational state to it's handler
+ *
+ *
+ * @params[in] cellId, opState, cellState
+ * @return cell operational in string form
+ ******************************************************************/
+
+
+bool setCellOpState(uint16_t cellId, OpState opState, CellState cellState)
+{
+   O1_LOG("\nO1  ConfigInterface: Setting cellId = %d, opState=%d, \
+cellState=%d\n", cellId, opState, cellState);
+   return NrCellList::instance().setCellOpState(cellId, opState, \
+                                                      cellState);
+}
 
 /**********************************************************************
          End of file
index 0f4929e..a8c8d1d 100644 (file)
@@ -44,10 +44,28 @@ typedef struct
    uint16_t RIC_Port;
 }StartupConfig;
 
+typedef enum {
+   INACTIVE,
+   ACTIVE,
+   IDLE
+}CellState;
+
+typedef enum {
+   DISABLED,
+   ENABLED
+}OpState;
+
 
 uint8_t getStartupConfig(StartupConfig *cfg);
 uint8_t getStartupConfigForStub(StartupConfig *cfg);
+bool setCellOpState(uint16_t cellId, OpState opState, \
+                             CellState cellState);
 
+#ifndef ODU_TEST_STUB
+//Defined in odu high
+bool bringCellUp(uint16_t cellId);
+bool bringCellDown(uint16_t cellId);
+#endif //ODU_TEST_STUB
 #ifdef __cplusplus
 }
 #endif
index 759e725..6bf2578 100644 (file)
@@ -35,7 +35,10 @@ using std::string;
 #define ALARM_MODULE_PATH_3GPP "/_3gpp-common-fm:AlarmListGrp"
 #define ALARM_MODULE_NAME_ORAN "o-ran-sc-odu-alarm-v1"
 #define ALARM_MODULE_PATH_ORAN "/o-ran-sc-odu-alarm-v1:odu"
-
+#define CELL_STATE_MODULE_NAME "o-ran-sc-du-hello-world"
+#define CELL_STATE_MODULE_PATH "/o-ran-sc-du-hello-world:network-function"
+#define IETF_NACM_MODULE_NAME "ietf-netconf-acm"
+#define IETF_NACM_MODULE_PATH "/ietf-netconf-acm:nacm"
 #define MAX_ALARM_ID_LEN 10
 
 class O1 
index 1b58f08..5626ba9 100644 (file)
@@ -60,6 +60,7 @@ class InitConfig : public Singleton<InitConfig>
       ~InitConfig();
       bool init(sysrepo::S_Session sess);
       bool getCurrInterfaceConfig(StartupConfig & cfg);
+      bool disableNacm(sysrepo::S_Session sess);
 
    private:
 
diff --git a/src/o1/NrCellCb.cpp b/src/o1/NrCellCb.cpp
new file mode 100644 (file)
index 0000000..e97358b
--- /dev/null
@@ -0,0 +1,290 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2020-2021] [HCL Technologies Ltd.]                          #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/* This file contains Cell state update handler for CLA use case. It handles
+   get and change callback for o-ran-sc-du-hello-world yang module  */
+
+#include <sstream>
+#include "NrCellCb.hpp"
+#define MAX_LEN 100
+
+using namespace std;
+
+/*******************************************************************
+ *
+ * @brief override oper_get_items to handle callback
+ *
+ * @details
+ *
+ *    Function : oper_get_items
+ *
+ *    Functionality:
+ *      - override oper_get_items to handle callback of get of
+ *        o-ran-sc-du-hello-world yang module
+ *
+ *
+ * @params[in] sysrepo::S_Session session, const char *module_name,
+ *             const char *path, const char *request_xpath,
+ *             uint32_t request_id, libyang::S_Data_Node &parent,
+ *             void *private_data
+ * @return SR_ERR_OK  - success
+ *         SR_ERR_OK  - failure
+ ******************************************************************/
+
+int NrCellCb::oper_get_items(sysrepo::S_Session session, \
+                                       const char *module_name, \
+                                       const char *path, \
+                                       const char *request_xpath, \
+                                       uint32_t request_id, \
+                                       libyang::S_Data_Node &parent, \
+                                       void *private_data)
+{
+   O1_LOG("O1 NrCellCb : Callback called for path=%s on get request", path);
+   libyang::S_Context ctx = session->get_context();
+   libyang::S_Module mod = ctx->get_module(module_name);
+
+   //first create root of the tree then add nodes and leaves and fill data
+   parent.reset(new libyang::Data_Node(ctx, CELL_STATE_MODULE_PATH, \
+                nullptr, LYD_ANYDATA_CONSTSTRING, 0));
+   libyang::S_Data_Node connection(new libyang::Data_Node(parent, mod, \
+                                   "du-to-ru-connection"));
+
+   libyang::S_Data_Node name;
+   libyang::S_Data_Node operational_state;
+   libyang::S_Data_Node cell_state;
+   libyang::S_Data_Node administrative_state;
+
+   NrCellList & cellList  = NrCellList::instance();
+   NrCellInfo cellInfo;
+   const NrCellList::CellOpStateMap & cellOpStateMap = cellList.getCellOpStateList();
+   //read the data from CellOpStateMap
+   std::map<uint16_t, NrCellInfo>::const_iterator it;
+   for(it = cellOpStateMap.begin(); it !=cellOpStateMap.end(); it++)
+   {
+      O1_LOG("\nO1 NrCellCb : cellId = %d, opState=%d, cellState=%d\n", \
+              it->first, (int) it->second.getOpState(), (int) it->second.getCellState());
+      name.reset(new libyang::Data_Node(connection, mod, "name", \
+                 to_string(it->first).c_str()));
+      operational_state.reset(new libyang::Data_Node(connection, mod, \
+                        "operational-state", \
+                        cellInfo.enumToOperationalStateString(it->second.getOpState()).c_str()));
+      cell_state.reset(new libyang::Data_Node(connection, mod, "cell-state", \
+                       cellInfo.enumToCellStateString(it->second.getCellState()).c_str()));
+   }
+   return SR_ERR_OK;
+}
+
+/*******************************************************************
+ *
+ * @brief print changes of given operation
+ *
+ * @details
+ *
+ *    Function : oper_get_items
+ *
+ *    Functionality:
+ *      -  print changes of given operation, old and new value
+ *
+ *
+ * @params[in] sysrepo::S_Change change
+ * @return void
+ ******************************************************************/
+
+void NrCellCb::printChange(sysrepo::S_Change change) {
+   switch(change->oper()) {
+      case SR_OP_CREATED:
+         if (nullptr != change->new_val()) {
+            O1_LOG("O1 NrCellCb : CREATED: %s", \
+                    change->new_val()->to_string().c_str());
+         }
+         break;
+      case SR_OP_DELETED:
+         if (nullptr != change->old_val()) {
+             O1_LOG("O1 NrCellCb : DELETED:  %s", \
+                     change->old_val()->to_string().c_str());
+         }
+         break;
+      case SR_OP_MODIFIED:
+         if (nullptr != change->old_val() && nullptr != change->new_val()) {
+            O1_LOG("O1 NrCellCb : MODIFIED: old value %s :new value %s", \
+                    change->old_val()->to_string().c_str(), \
+                    change->new_val()->to_string().c_str());
+        }
+        break;
+     case SR_OP_MOVED:
+        if (nullptr != change->old_val() && nullptr != change->new_val()) {
+           O1_LOG("O1 NrCellCb : MOVED: %s :after %s ", \
+                    change->new_val()->xpath(), \
+                    change->old_val()->xpath());
+        }
+        else if (nullptr != change->new_val()) {
+           O1_LOG("O1 NrCellCb : MOVED: %s : first\n", \
+                   change->new_val()->xpath());
+        }
+        break;
+    }
+}
+
+/*******************************************************************
+ *
+ * @brief convert event type to string
+ *
+ * @details
+ *
+ *    Function : evToStr
+ *
+ *    Functionality:
+ *      - convert event type to string
+ *
+ *
+ * @params[in] sr_event_t event
+ * @return event name in string form
+ ******************************************************************/
+
+/* Helper function for printing events. */
+const char *NrCellCb::evToStr(sr_event_t ev) {
+   switch (ev) {
+      case SR_EV_CHANGE:
+         return "change";
+      case SR_EV_DONE:
+         return "done";
+      case SR_EV_ABORT:
+      default:
+         return "abort";
+   }
+}
+
+/*******************************************************************
+ *
+ * @brief override module_change to handle callback
+ *
+ * @details
+ *
+ *    Function : module_change
+ *
+ *    Functionality:
+ *      - override module_change to handle callback of modification of
+ *        o-ran-sc-du-hello-world yang module
+ *
+ *
+ * @params[in] sysrepo::S_Session session, const char *module_name,
+ *             const char *xpath, sr_event_t event, uint32_t request_id,
+ *             void *private_data
+ * @return SR_ERR_OK  - success
+ *         SR_ERR_OK  - failure
+ ******************************************************************/
+
+int NrCellCb::module_change(sysrepo::S_Session sess, \
+                                    const char *module_name, \
+                                    const char *xpath, \
+                                    sr_event_t event, \
+                                    uint32_t request_id, \
+                                    void *private_data)
+{
+   char change_path[MAX_LEN];
+
+   try {
+      O1_LOG("O1 NrCellCb : Notification %s\n", evToStr(event));
+      if (SR_EV_CHANGE == event)
+      {
+         NrCellList & cellList  = NrCellList::instance();
+         NrCellInfo cellInfo;
+         const NrCellList::CellOpStateMap & cellOpStateMap = cellList.getCellOpStateList();
+         snprintf(change_path, MAX_LEN, "/%s:*//.", module_name);
+         auto it = sess->get_changes_iter(change_path);
+         uint16_t cellId;
+         while (auto change = sess->get_change_next(it)) {
+         //printChange(change); //enable only for debugging
+         if(nullptr != change->new_val())
+         {
+            O1_LOG("O1 NrCellCb : Parameter value has been \
+changed val=%s\n", change->new_val()->val_to_string().c_str());
+            std::map<uint16_t, NrCellInfo>::const_iterator it;
+            for(it = cellOpStateMap.begin(); it !=cellOpStateMap.end(); it++)
+            {
+               stringstream xpath;
+               xpath << CELL_STATE_MODULE_PATH << "/du-to-ru-connection[name='" \
+               << it->first << "']/administrative-state";
+               O1_LOG("O1 NrCellCb : created xpath = %s", \
+                      xpath.str().c_str());
+
+               if((change->new_val()->to_string().find(xpath.str().c_str()) != \
+                   std::string::npos))
+               {
+                  printChange(change);
+                  string val = change->new_val()->val_to_string();
+                  AdminState newVal = cellInfo.adminStateToEnum(val);
+                  O1_LOG("O1 NrCellCb : Update admin state \
+cellId =%d with admin-state value=%s\n", it->first, val.c_str());
+                 if(!setAdminState(it->first, newVal)) {
+                    O1_LOG("O1 NrCellCb : Could not change \
+parameter value =%s\n", change->new_val()->val_to_string().c_str());
+                    return SR_ERR_INTERNAL;
+                 }
+               }
+            }
+         }
+     }
+   }//if evToStr(event) check
+   }
+   catch( const std::exception& e ) {
+      O1_LOG("exception : %s\n", e.what());
+   }
+   return SR_ERR_OK;
+}
+
+/*******************************************************************
+ *
+ * @brief bring cell status according to the admin state
+ *
+ * @details
+ *
+ *    Function : setAdminState
+ *
+ *    Functionality:
+ *      - bring cell status according to the admin state
+ *
+ *
+ * @params[in] cellId, Admin state
+ * @return true   - success
+ *         false  - failure
+ ******************************************************************/
+bool NrCellCb::setAdminState(uint16_t cellId, AdminState newAdminState)
+{
+   if(newAdminState == UNLOCKED)
+   {
+      O1_LOG("\nNrCellList : set Admin State UNLOCKED" );
+#ifndef ODU_TEST_STUB
+      return bringCellUp(cellId);
+#endif
+   }
+   else
+   {
+      O1_LOG("\nNrCellList : set Admin State LOCKED" );
+#ifndef ODU_TEST_STUB
+      return bringCellDown(cellId);
+#endif
+   }
+   return true;
+}
+
+
+/**********************************************************************
+         End of file
+**********************************************************************/
+
diff --git a/src/o1/NrCellCb.hpp b/src/o1/NrCellCb.hpp
new file mode 100644 (file)
index 0000000..00655d2
--- /dev/null
@@ -0,0 +1,65 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2020-2021] [HCL Technologies Ltd.]                          #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/* This file contains Cell state update handler for CLA use case. It handles
+   get and change callback for o-ran-sc-du-hello-world yang module  */
+
+
+#ifndef __NR_CELL_CB_HPP__
+#define __NR_CELL_CB_HPP__
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include "sysrepo-cpp/Session.hpp"
+#include "ConfigInterface.h"
+#include "GlobalDefs.hpp"
+#include "Singleton.hpp"
+#include "NrCellInfo.hpp"
+#include "NrCellList.hpp"
+
+class NrCellCb : public sysrepo::Callback
+{
+
+   public:
+      int oper_get_items(sysrepo::S_Session session,\
+                         const char *module_name,\
+                         const char *path,\
+                         const char *request_xpath,\
+                         uint32_t request_id,\
+                         libyang::S_Data_Node &parent,\
+                         void *private_data); //override
+      int module_change(sysrepo::S_Session sess, \
+                         const char *module_name, \
+                         const char *xpath, \
+                         sr_event_t event, \
+                         uint32_t request_id, \
+                         void *private_data); //override
+
+      bool setAdminState(uint16_t cellId, AdminState newAdminState);
+
+   private:
+      static void printChange(sysrepo::S_Change change);
+      const char *evToStr(sr_event_t ev);
+};
+
+#endif
+
+/**********************************************************************
+         End of file
+**********************************************************************/
diff --git a/src/o1/NrCellInfo.cpp b/src/o1/NrCellInfo.cpp
new file mode 100644 (file)
index 0000000..6fc5516
--- /dev/null
@@ -0,0 +1,132 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2020-2021] [HCL Technologies Ltd.]                          #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/* This file contains parameters list of a cell for CLA use case*/
+
+#include "NrCellInfo.hpp"
+
+using namespace std;
+
+/*******************************************************************
+ *
+ * @brief convert admin state to enum
+ *
+ * @details
+ *
+ *    Function : adminStateToEnum
+ *
+ *    Functionality:
+ *      - convert admin state to enum
+ *
+ *
+ * @params[in] admin state in string form
+ * @return admin state in enum form
+ ******************************************************************/
+
+AdminState NrCellInfo::adminStateToEnum(string val)
+{
+   AdminState ret=LOCKED;
+   if( val == "LOCKED")
+      ret = LOCKED;
+   else if(val == "UNLOCKED")
+      ret = UNLOCKED;
+   else if(val ==  "SHUTTING_DOWN")
+      ret = SHUTTING_DOWN;
+   else
+      O1_LOG("O1 NrCellInfo : %s admin state not handled\n", \
+              val.c_str());
+
+   return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief convert enum of cell state to string
+ *
+ * @details
+ *
+ *    Function : enumToCellStateString
+ *
+ *    Functionality:
+ *      - convert enum of cell state to string
+ *
+ *
+ * @params[in] enum of cell state
+ * @return cell state in string form
+ ******************************************************************/
+
+
+string NrCellInfo::enumToCellStateString(CellState val)
+{
+   string ret = "IDLE";
+   switch(val)
+   {
+      case INACTIVE:
+         ret = "INACTIVE";
+         break;
+      case ACTIVE:
+         ret = "ACTIVE";
+         break;
+      case IDLE:
+         ret = "IDLE";
+         break;
+      default :
+         O1_LOG("O1 NrCellInfo : %d cell state not handled\n", val);
+
+   }
+   return ret;
+}
+
+/*******************************************************************
+ *
+ * @brief convert enum of operational state to string
+ *
+ * @details
+ *
+ *    Function : enumToOperationalStateString
+ *
+ *    Functionality:
+ *      - convert enum of operational state to string
+ *
+ *
+ * @params[in] enum of operational state
+ * @return cell operational in string form
+ ******************************************************************/
+
+string NrCellInfo::enumToOperationalStateString(OpState val)
+{
+   string ret = "DISABLED";
+   switch(val)
+   {
+      case DISABLED:
+         ret = "DISABLED";
+         break;
+      case ENABLED:
+         ret = "ENABLED";
+         break;
+      default :
+         O1_LOG("O1 NrCellInfo : %d operational state not handled\n", val);
+
+   }
+   return ret;
+}
+
+/**********************************************************************
+         End of file
+**********************************************************************/
+
diff --git a/src/o1/NrCellInfo.hpp b/src/o1/NrCellInfo.hpp
new file mode 100644 (file)
index 0000000..2c27b13
--- /dev/null
@@ -0,0 +1,64 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2020-2021] [HCL Technologies Ltd.]                          #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/* This file contains parameters list of a cell for CLA use case*/
+
+#ifndef __NR_CELL_INFO_HPP__
+#define __NR_CELL_INFO_HPP__
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include "sysrepo-cpp/Session.hpp"
+#include "ConfigInterface.h"
+#include "GlobalDefs.hpp"
+#include "Singleton.hpp"
+#include "NrCellInfo.hpp"
+
+
+typedef enum AdminState{
+   LOCKED,
+   UNLOCKED,
+   SHUTTING_DOWN
+}adminState;
+      
+class NrCellInfo
+{
+   public:
+      inline void setCellId(uint16_t id) { mCellId = id;}
+      inline void setOpState(OpState state) { mOpState = state;}
+      inline void setCellState( CellState state) { mCellState = state;} 
+      inline uint16_t getCellId() const {return mCellId;}
+      inline OpState getOpState() const { return mOpState;}
+      inline CellState getCellState() const { return mCellState;}
+      string enumToOperationalStateString(OpState val);
+      string enumToCellStateString(CellState val);
+      AdminState adminStateToEnum(string val);
+
+   private:
+      uint16_t mCellId;
+      OpState mOpState;
+      CellState mCellState;
+};
+
+#endif
+
+/**********************************************************************
+         End of file
+**********************************************************************/
diff --git a/src/o1/NrCellList.cpp b/src/o1/NrCellList.cpp
new file mode 100644 (file)
index 0000000..9ea92e0
--- /dev/null
@@ -0,0 +1,84 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2020-2021] [HCL Technologies Ltd.]                          #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/* This file contains List of the Cell and it's parameters values for CLA 
+   use case*/
+
+#include <sstream>
+#include "NrCellList.hpp"
+#define MAX_LEN 100
+
+using namespace std;
+
+/*******************************************************************
+ *
+ * @brief update cell and operational state in the map
+ *
+ * @details
+ *
+ *    Function : setCellOpState
+ *
+ *    Functionality:
+ *      - update cell and operational state in the map using cellId
+ *        as key
+ *
+ *
+ * @params[in] cellId, opState, cellState
+ * @return true   - success
+ *         false  - failure
+ ******************************************************************/
+
+
+bool NrCellList::setCellOpState(uint16_t cellId, \
+                                OpState opState, \
+                                CellState cellState)
+{
+   O1_LOG("\nO1 NrCellList : Setting cellId = %d, opState=%d, \
+cellState=%d\n", cellId, opState, cellState);
+   NrCellInfo cellInfo ;
+   cellInfo.setCellId( cellId);
+   cellInfo.setOpState(opState);
+   cellInfo.setCellState (cellState);
+   mCellOpStateMap[cellId] = cellInfo;
+   return true;
+}
+
+/*******************************************************************
+ *
+ * @brief provide the cell list 
+ *
+ * @details
+ *
+ *    Function : getCellOpStateList
+ *
+ *    Functionality:
+ *      - provide the cell list
+ *
+ *
+ * @params[in] na
+ * @return map of cell   - success
+ ******************************************************************/
+
+const std::map<uint16_t, NrCellInfo> & NrCellList::getCellOpStateList()
+{
+   return mCellOpStateMap;
+}
+/**********************************************************************
+         End of file
+**********************************************************************/
+
diff --git a/src/o1/NrCellList.hpp b/src/o1/NrCellList.hpp
new file mode 100644 (file)
index 0000000..45dd0f6
--- /dev/null
@@ -0,0 +1,54 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2020-2021] [HCL Technologies Ltd.]                          #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/* This file contains List of the Cell and it's parameters values for CLA 
+   use case*/
+
+#ifndef __NR_CELL_LIST_HPP__
+#define __NR_CELL_LIST_HPP__
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <map>
+#include "sysrepo-cpp/Session.hpp"
+#include "ConfigInterface.h"
+#include "GlobalDefs.hpp"
+#include "Singleton.hpp"
+#include "NrCellInfo.hpp"
+
+class NrCellList : public Singleton<NrCellList>
+{
+   public:
+      friend Singleton<NrCellList>;
+      typedef std::map<uint16_t, NrCellInfo> CellOpStateMap;
+
+      bool setCellOpState(uint16_t cellId, OpState opState, \
+                          CellState cellState);
+      const std::map<uint16_t, NrCellInfo> & getCellOpStateList();
+
+
+   private:
+      std::map<uint16_t, NrCellInfo> mCellOpStateMap;
+};
+
+#endif
+
+/**********************************************************************
+         End of file
+**********************************************************************/
index 1f9c0cf..7c745ac 100644 (file)
@@ -24,7 +24,7 @@
 #include "sysrepo.h"
 #include "SessionHandler.hpp"
 #include "InitConfig.hpp"
-#include <iostream>
+#include "NrCellCb.hpp"
 
 using namespace std;
 /* Default constructor */
@@ -155,6 +155,15 @@ 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);
+
+
    return true;
 }