1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2020-2021] [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 *******************************************************************************/
18 /* This class defines functions to read Netconf Config file */
20 #include "NetconfConfigFile.hpp"
21 #include "JsonHelper.hpp"
22 #include "GlobalDefs.hpp"
26 NetconfConfigFile::NetconfConfigFile(string filepath)
31 NetconfConfigFile::~NetconfConfigFile()
36 string NetconfConfigFile::getNetconfMacAddr() const
38 return mNetconfMacAddr;
40 string NetconfConfigFile::getNetconfIpv4() const
44 string NetconfConfigFile::getNetconfIpv6() const
48 string NetconfConfigFile::getNetconfPort() const
52 string NetconfConfigFile::getNetconfUsername() const
54 return mNetconfUsername;
56 string NetconfConfigFile::getNetconfPassword() const
58 return mNetconfPassword;
61 /*******************************************************************
63 * @brief load Netconf config file
67 * Function : loadConfigFile
70 * - read Netconf Config file and store its contents
72 * @params[in] IN - NULL
73 * @return true - success
76 * ****************************************************************/
78 bool NetconfConfigFile::loadConfigFile()
80 cJSON *json = JsonHelper::read(mFilepath.c_str());
82 O1_LOG("\nO1 PnfRegistrationEvent : Config file reading error is :%s", JsonHelper::getError());
86 cJSON *rootNode = NULL;
87 rootNode = JsonHelper::getNode(json, "NetconfServer");
89 O1_LOG("\nO1 PnfRegistrationEvent : Reading NetconfServer config file");
90 mNetconfMacAddr = JsonHelper::getValue(rootNode, "MacAddress");
91 mNetconfIpv4 = JsonHelper::getValue(rootNode, "NetconfServerIpv4");
92 mNetconfIpv6 = JsonHelper::getValue(rootNode, "NetconfServerIpv6");
93 mNetconfPort = JsonHelper::getValue(rootNode, "NetconfPort");
94 mNetconfUsername = JsonHelper::getValue(rootNode, "NetconfUsername");
95 mNetconfPassword = JsonHelper::getValue(rootNode, "NetconfPassword");
98 O1_LOG("\nO1 PnfRegistrationEvent : smoConfig Object is not available in config file");
102 JsonHelper::deleteNode(json);
106 /**********************************************************************
108 **********************************************************************/