Edit-conf changes for CLA use case.
[o-du/l2.git] / src / o1 / InitConfig.hpp
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2020] [HCL Technologies Ltd.]                               #
4 #                                                                              #
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                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
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 *******************************************************************************/
18
19 /* This file contains InitConfig class header*/
20
21 #ifndef __INIT_CONFIG_HPP__
22 #define __INIT_CONFIG_HPP__
23
24 #include <utility>
25 #include <string>
26 #include <iostream>
27 #include <string.h>
28 #include <map>
29 #include "sysrepo-cpp/Session.hpp"
30 #include "Singleton.hpp"
31 #include "ConfigInterface.h"
32 #include "GlobalDefs.hpp"
33
34 #define IP_ADDRESS "interface-address" 
35 #define PORT "port"
36 #define INTERFACE_MODULE_NAME_ORAN "/o-ran-sc-odu-interface-v1:odu"
37 #define MAX_XPATH 100
38 #define NETCONF_STARTUP_CFG "/etc/netconf_startup.cfg"
39
40 using namespace std;
41 enum class Interface 
42 { ODU,
43   OCU,
44   RIC
45 };
46
47
48 class InitConfig : public Singleton<InitConfig>
49 {
50
51    friend Singleton<InitConfig>;
52
53    public:
54       
55      //member variable
56       typedef std::pair<std::string, uint16_t> Address;
57       typedef std::map<Interface, Address> InterfaceMap;
58      
59       InitConfig();
60       ~InitConfig();
61       bool init(sysrepo::S_Session sess);
62       bool getCurrInterfaceConfig(StartupConfig & cfg);
63       bool disableNacm(sysrepo::S_Session sess);
64
65    private:
66
67       InterfaceMap mInterfaceList;
68       char xpath[MAX_XPATH];
69       sysrepo::S_Session mSess;
70       //string mVal;
71       /* function to get the data of Interfaces param*/
72       bool getInterfaceData(sysrepo::S_Session sess, \
73                             Interface inf, InitConfig::Address & addr);
74       bool getInterfaceConfig(sysrepo::S_Session sess , InitConfig::InterfaceMap &map);
75       char * getInterfaceXpath( std::string sInf, std::string param);
76       bool getData(sysrepo::S_Session sess,char* xpath, string &val);
77       std::string interfaceToString(Interface inf);
78       bool printInterfaceConfig();
79       bool writeInterfaceConfig();
80
81 };
82
83 #endif
84
85 /**********************************************************************
86          End of file
87 **********************************************************************/