--- /dev/null
+{
+ "vesConfig": {
+ "vesV4IpAddress" : "10.0.2.135",
+ "vesPort" : "9999",
+ "username" : "user",
+ "password" : "password"
+ }
+}
#include <string>
#include <string.h>
#include "AlarmMessages.h"
+#include "Message.hpp"
using std::string;
-class Alarm
+class Alarm : public Message
{
-
private:
EventType mEventType;
string mObjectClassObjectInstance;
string mSpecificProblem;
public:
- Alarm(){};
- ~Alarm(){};
+ Alarm() {}
+ ~Alarm(){}
/* Getter functions */
inline const EventType& getEventType()const
{
**********************************************************************/
bool AlarmManager::raiseAlarm(const Alarm& alarm)
{
+
pair<map<uint16_t,Alarm>::iterator,bool> ret;
ret = mAlarmList.insert(pair<uint16_t,Alarm>(alarm.getAlarmId(),alarm));
return ret.second;
+
+
}
#include "Alarm.hpp"
#include "Singleton.hpp"
+#include "PnfRegistrationThread.hpp"
+#include "VesUtils.hpp"
+#include "VesEventHandler.hpp"
+
using std::map;
--- /dev/null
+/*******************************************************************************
+################################################################################
+# 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 is a super class for all config files */
+
+#ifndef __CONFIG_FILE_HPP__
+#define __CONFIG_FILE_HPP__
+
+#include <string>
+
+using std::string;
+
+class ConfigFile {
+public:
+ ConfigFile(string filepath) : mFilepath(filepath) {}
+ ~ConfigFile() {}
+ virtual bool loadConfigFile() = 0;
+protected:
+ string mFilepath;
+};
+#endif
+
+/**********************************************************************
+ End of file
+ **********************************************************************/
--- /dev/null
+/*******************************************************************************
+################################################################################
+# 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 is a singleton class to load and store all configuration parameters */
+
+#include "ConfigLoader.hpp"
+
+/* Constructor */
+ConfigLoader::ConfigLoader()
+ : mNetconfConfig(NETCONF_CONFIG),
+ mOamConfig(OAM_VES_CONFIG),
+ mSmoConfig(SMO_VES_CONFIG)
+{
+};
+/* Default Destructor */
+ConfigLoader::~ConfigLoader()
+{
+}
+
+/*******************************************************************
+ *
+ * @brief Load all configuration files
+ *
+ * @details
+ *
+ * Function : loadConfigurations
+ *
+ * Functionality:
+ * - Loads all the configuration files
+ *
+ *
+ * @params[in] void
+ * @return true - success
+ * false - failure
+ ******************************************************************/
+bool ConfigLoader::loadConfigurations() {
+ return mOamConfig.loadConfigFile()
+ &&
+ mSmoConfig.loadConfigFile()
+ &&
+ mNetconfConfig.loadConfigFile();
+}
+
+/*******************************************************************
+ *
+ * @brief Get OAM Ves collector configuration
+ *
+ * @details
+ *
+ * Function : getOamConfigFile
+ *
+ * Functionality:
+ * - Returns the OAM config object
+ *
+ *
+ * @params[in] void
+ * @return const reference to VesConfigFile
+ *
+ ******************************************************************/
+const VesConfigFile& ConfigLoader::getOamConfigFile() const{
+ return mOamConfig;
+}
+
+/*******************************************************************
+ *
+ * @brief Get SMO Ves collector configuration
+ *
+ * @details
+ *
+ * Function : getsmoConfigFile
+ *
+ * Functionality:
+ * - Returns the Smo config object
+ *
+ *
+ * @params[in] void
+ * @return const reference to VesConfigFile
+ *
+ ******************************************************************/
+const VesConfigFile& ConfigLoader::getSmoConfigFile() const{
+ return mSmoConfig;
+}
+
+/*******************************************************************
+ *
+ * @brief Get Netconf server configuration
+ *
+ * @details
+ *
+ * Function : getNetconfConfigFile
+ *
+ * Functionality:
+ * - Returns the Netconf config object
+ *
+ *
+ * @params[in] void
+ * @return const reference to NetconfConfigFile
+ *
+ ******************************************************************/
+const NetconfConfigFile& ConfigLoader::getNetconfConfigFile() const{
+ return mNetconfConfig;
+}
+
+/**********************************************************************
+ End of file
+ **********************************************************************/
--- /dev/null
+/*******************************************************************************
+################################################################################
+# 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 is a singleton class to load and store all configuration parameters */
+
+#ifndef __CONFIG_LOADER_HPP__
+#define __CONFIG_LOADER_HPP__
+
+#include <string>
+#include "VesConfigFile.hpp"
+#include "NetconfConfigFile.hpp"
+#include "VesUtils.hpp"
+#include "Singleton.hpp"
+
+using std::string;
+
+class ConfigLoader : public Singleton<ConfigLoader> {
+private:
+ ConfigLoader();
+ ~ConfigLoader();
+
+ VesConfigFile mOamConfig;
+ VesConfigFile mSmoConfig;
+ NetconfConfigFile mNetconfConfig;
+
+public:
+ friend Singleton<ConfigLoader>;
+
+ const VesConfigFile& getOamConfigFile()const;
+ const VesConfigFile& getSmoConfigFile()const;
+ const NetconfConfigFile& getNetconfConfigFile()const;
+
+ bool loadConfigurations();
+};
+
+#endif
+
+/**********************************************************************
+ End of file
+ **********************************************************************/
--- /dev/null
+/*******************************************************************************
+################################################################################
+# 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 Message base class for generic messages */
+
+#ifndef __MESSAGE_HPP__
+#define __MESSAGE_HPP__
+
+#include "VesUtils.hpp"
+
+
+class Message {
+
+public:
+
+ Message() {};
+ virtual ~Message() {};
+
+protected:
+ MessageType mMsgType;
+ virtual MessageType getMessageType() { return mMsgType; }
+
+};
+
+#endif
+
+/**********************************************************************
+ End of file
+**********************************************************************/
--- /dev/null
+/*******************************************************************************
+################################################################################
+# 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 class defines functions to read Netconf Config file */
+
+#include "NetconfConfigFile.hpp"
+#include "JsonHelper.hpp"
+#include "GlobalDefs.hpp"
+
+
+// Constructor
+NetconfConfigFile::NetconfConfigFile(string filepath)
+ :ConfigFile(filepath)
+{
+}
+// Default Destructor
+NetconfConfigFile::~NetconfConfigFile()
+{
+}
+
+//Getters
+string NetconfConfigFile::getNetconfMacAddr() const
+{
+ return mNetconfMacAddr;
+}
+string NetconfConfigFile::getNetconfIpv4() const
+{
+ return mNetconfIpv4;
+}
+string NetconfConfigFile::getNetconfIpv6() const
+{
+ return mNetconfIpv6;
+}
+string NetconfConfigFile::getNetconfPort() const
+{
+ return mNetconfPort;
+}
+string NetconfConfigFile::getNetconfUsername() const
+{
+ return mNetconfUsername;
+}
+string NetconfConfigFile::getNetconfPassword() const
+{
+ return mNetconfPassword;
+}
+
+/*******************************************************************
+*
+* @brief load Netconf config file
+*
+* @details
+*
+* Function : loadConfigFile
+*
+* Functionality:
+* - read Netconf Config file and store its contents
+*
+* @params[in] IN - NULL
+* @return true - success
+* false - failure
+*
+* ****************************************************************/
+
+bool NetconfConfigFile::loadConfigFile()
+{
+ cJSON *json = JsonHelper::read(mFilepath.c_str());
+ if(json == NULL) {
+ O1_LOG("\nO1 PnfRegistrationEvent : Config file reading error is :%s", JsonHelper::getError());
+ return false;
+ }
+ else {
+ cJSON *rootNode = NULL;
+ rootNode = JsonHelper::getNode(json, "NetconfServer");
+ if(rootNode) {
+ O1_LOG("\nO1 PnfRegistrationEvent : Reading NetconfServer config file");
+ mNetconfMacAddr = JsonHelper::getValue(rootNode, "MacAddress");
+ mNetconfIpv4 = JsonHelper::getValue(rootNode, "NetconfServerIpv4");
+ mNetconfIpv6 = JsonHelper::getValue(rootNode, "NetconfServerIpv6");
+ mNetconfPort = JsonHelper::getValue(rootNode, "NetconfPort");
+ mNetconfUsername = JsonHelper::getValue(rootNode, "NetconfUsername");
+ mNetconfPassword = JsonHelper::getValue(rootNode, "NetconfPassword");
+ }
+ else {
+ O1_LOG("\nO1 PnfRegistrationEvent : smoConfig Object is not available in config file");
+ return false;
+ }
+ }
+ JsonHelper::deleteNode(json);
+ return true;
+}
+
+/**********************************************************************
+ End of file
+ **********************************************************************/
--- /dev/null
+/*******************************************************************************
+################################################################################
+# 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 class defines functions to read Netconf Config file */
+
+#ifndef __NETCONF_CONFIG_FILE_HPP__
+#define __NETCONF_CONFIG_FILE_HPP__
+
+#include "ConfigFile.hpp"
+#include <string>
+
+
+using std::string;
+
+class NetconfConfigFile : public ConfigFile {
+public:
+ //constructor & Destructor
+ NetconfConfigFile(string filepath);
+ ~NetconfConfigFile();
+
+ //member functions
+ bool loadConfigFile() override;
+
+
+ //Getters
+ string getNetconfMacAddr() const;
+ string getNetconfIpv4() const;
+ string getNetconfIpv6() const;
+ string getNetconfPort() const;
+ string getNetconfUsername() const;
+ string getNetconfPassword() const;
+
+private:
+ //member variables
+ string mNetconfMacAddr;
+ string mNetconfIpv4;
+ string mNetconfIpv6;
+ string mNetconfPort;
+ string mNetconfUsername;
+ string mNetconfPassword;
+};
+#endif
+
+/**********************************************************************
+ End of file
+ **********************************************************************/
#include "O1App.hpp"
#include "GlobalDefs.hpp"
#include "PnfRegistrationThread.hpp"
+#include "ConfigLoader.hpp"
#include <signal.h>
#include <unistd.h>
int start_O1_module(void)
{
+ if( !ConfigLoader::instance().loadConfigurations() )
+ return O1::FAILURE;
+
if(O1App::instance().start() == false){
O1_LOG("\nO1 O1Interface : Failed to start");
return O1::FAILURE;
--- /dev/null
+/*******************************************************************************
+################################################################################
+# 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 the C interface for ODU to access the Performance
+ Management functions */
+
+#include "PmInterface.h"
+#include "VesEventHandler.hpp"
+#include "SliceMetrics.hpp"
+#include <unistd.h>
+#include "GlobalDefs.hpp"
+
+
+/*******************************************************************
+ *
+ * @brief Send the Slice metrics to SMO as a VES message
+ *
+ * @details
+ *
+ * Function : sendSliceMetric
+ *
+ * Functionality:
+ * - Takes the Slice metrics list and sends it to SMO
+ *
+ *
+ * @params[in] pointer to SliceMetricList
+ * @return O1::SUCCESS - success
+ * O1::FAILURE - failure
+ ******************************************************************/
+int sendSliceMetric(SliceMetricList* sliceMetricList) {
+
+ O1_LOG("\n PmInterfce : Call received from the the du_app code !!");
+
+ SliceMetrics metrics;
+
+ for(int i = 0; i < sliceMetricList->nRecords; i++)
+ metrics.addMetric(sliceMetricList->sliceRecord[i]);
+
+ VesEventHandler vesEventHandler;
+ if (!vesEventHandler.prepare(VesEventType::PM_SLICE, &metrics))
+ return O1::FAILURE;
+
+ O1_LOG("\n PmInterface : Sending slice PM Data");
+ if ( !vesEventHandler.send() )
+ return O1::FAILURE;
+
+ return O1::SUCCESS;
+}
+
+/**********************************************************************
+ End of file
+**********************************************************************/
--- /dev/null
+/*******************************************************************************
+################################################################################
+# 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 the C interface for ODU to access the Performance
+ Management functions */
+
+#ifndef __PM_INTERFACE_H__
+#define __PM_INTERFACE_H__
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+typedef struct {
+ uint32_t networkSliceIdentifier;
+ double DRB_UEThpDl_SNSSAI;
+ double DRB_UEThpUl_SNSSAI;
+}SliceMetricRecord;
+
+typedef struct {
+ SliceMetricRecord *sliceRecord;
+ uint8_t nRecords;
+}SliceMetricList;
+
+
+int sendSliceMetric(SliceMetricList* sliceMetricList);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/**********************************************************************
+ End of file
+**********************************************************************/
--- /dev/null
+/*******************************************************************************
+################################################################################
+# 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 defines the SliceMetrics which holds the Network Slice Metrics */
+
+#include "SliceMetrics.hpp"
+
+/* Default Constructor */
+SliceMetrics::SliceMetrics() {
+
+}
+
+/* Default Destructor */
+SliceMetrics::~SliceMetrics() {
+
+}
+
+/*******************************************************************
+ *
+ * @brief Add the slice metric record to the list
+ *
+ * @details
+ *
+ * Function : addMetric
+ *
+ * Functionality:
+ * - Adds slice metric record to the list
+ *
+ *
+ * @params[in] SliceMetricRecord
+ * @return void
+ ******************************************************************/
+void SliceMetrics::addMetric(SliceMetricRecord& sliceMetricRecord) {
+
+ mSliceList.push_back(sliceMetricRecord);
+
+}
+
+/*******************************************************************
+ *
+ * @brief Returns the slice metric list
+ *
+ * @details
+ *
+ * Function : getSliceMetrics
+ *
+ * Functionality:
+ * - Returns the slice metric vector list
+ *
+ *
+ * @params[in] void
+ * @return const reference to vector<SliceMetricRecord>
+ ******************************************************************/
+const vector<SliceMetricRecord>& SliceMetrics::getSliceMetrics() const {
+ return mSliceList;
+}
+
+/**********************************************************************
+ End of file
+**********************************************************************/
--- /dev/null
+/*******************************************************************************
+################################################################################
+# 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 defines the SliceMetrics which holds the Network Slice Metrics */
+
+#ifndef __SLICE_METRICS_HPP__
+#define __SLICE_METRICS_HPP__
+
+#include <string>
+#include <vector>
+#include "Message.hpp"
+#include "PmInterface.h"
+
+using namespace std;
+
+class SliceMetrics : public Message {
+
+public:
+ SliceMetrics();
+ ~SliceMetrics();
+
+ const vector<SliceMetricRecord>& getSliceMetrics() const;
+ void addMetric(SliceMetricRecord& sliceMetricRecord);
+
+private:
+ vector<SliceMetricRecord> mSliceList;
+
+};
+
+#endif
+
+/**********************************************************************
+End of file
+**********************************************************************/
O1_LOG("CPU %d ", i);
return true;
}
+
+/**********************************************************************
+End of file
+**********************************************************************/
\ No newline at end of file
bool join();
};
-
-
#endif
+
+/**********************************************************************
+End of file
+**********************************************************************/
\ No newline at end of file
switch(msgHdr->action)
{
case RAISE_ALARM:
+
if(AlarmManager::instance().raiseAlarm(alrm))
{
O1_LOG("\nO1 UnixSocketServer : "
"Alarm raised for alarm Id %s",
alrmRec->alarmId);
+
+ // triggering VES notification for the risen Alarm
+
+ VesEventHandler vesEvtHdr;
+ if(vesEvtHdr.prepare(VesEventType::FAULT_NOTIFICATION, &alrm)) {
+ vesEvtHdr.send();
+ }
+
}
+
else
{
O1_LOG("\nO1 UnixSocketServer : "
alrmRec->alarmId);
}
break;
+
case CLEAR_ALARM:
if(AlarmManager::instance().clearAlarm(alrm))
{
O1_LOG("\nO1 UnixSocketServer : "
"Alarm cleared for alarm Id %s",
alrmRec->alarmId);
+
+ // triggering VES notification for the cleared Alarm
+ VesEventHandler vesEvtHdr;
+ if(vesEvtHdr.prepare(VesEventType::FAULT_NOTIFICATION, &alrm)) {
+ vesEvtHdr.send();
+ }
}
else
{
--- /dev/null
+/*******************************************************************************
+################################################################################
+# 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 class defines functions to read Ves Config files */
+
+#include "VesConfigFile.hpp"
+#include "JsonHelper.hpp"
+#include "GlobalDefs.hpp"
+
+
+/* Constructor */
+VesConfigFile::VesConfigFile(string filepath)
+ :ConfigFile(filepath)
+{
+}
+/* Default Destructor */
+VesConfigFile::~VesConfigFile()
+{
+}
+
+//Getters
+string VesConfigFile::getVesServerIp() const
+{
+ return mVesServerIp;
+}
+string VesConfigFile::getVesServerPort() const
+{
+ return mVesServerPort;
+}
+string VesConfigFile::getVesServerUsername() const
+{
+ return mVesServerUsername;
+}
+string VesConfigFile::getVesServerPassword() const
+{
+ return mVesServerPassword;
+}
+
+/*******************************************************************
+*
+* @brief load Ves config file
+*
+* @details
+*
+* Function : loadConfigFile
+*
+* Functionality:
+* - read Ves Config file and store its contents
+*
+* @params[in] IN - NULL
+* @return true - success
+* false - failure
+*
+* ****************************************************************/
+
+bool VesConfigFile::loadConfigFile()
+{
+ cJSON *json = JsonHelper::read(mFilepath.c_str());
+ if (json == NULL)
+ {
+ O1_LOG("\nO1 VesEvent : Error reading config file :%s", JsonHelper::getError());
+ return false;
+ }
+ else
+ {
+ cJSON *rootNode = NULL;
+ rootNode = JsonHelper::getNode(json, "vesConfig");
+ if (rootNode)
+ {
+ O1_LOG("\nO1 VesEvent : Reading Config.json file\n");
+ mVesServerIp = JsonHelper::getValue(rootNode, "vesV4IpAddress");
+ mVesServerPort = JsonHelper::getValue(rootNode, "vesPort");
+ mVesServerUsername = JsonHelper::getValue(rootNode, "username");
+ mVesServerPassword = JsonHelper::getValue(rootNode, "password");
+ }
+ else
+ {
+ O1_LOG("\nO1 VesEvent : Config Object is not available in config file");
+ return false;
+ }
+ }
+ JsonHelper::deleteNode(json);
+ return true;
+}
+
+/**********************************************************************
+ End of file
+ **********************************************************************/
--- /dev/null
+/*******************************************************************************
+################################################################################
+# 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 class defines functions to read Ves Config files */
+
+#ifndef __VES_CONFIG_FILE_HPP__
+#define __VES_CONFIG_FILE_HPP__
+
+#include <string>
+#include "ConfigFile.hpp"
+
+
+using std::string;
+
+class VesConfigFile : public ConfigFile {
+public:
+ //Constructor and Destructor
+ VesConfigFile(string filepath);
+ ~VesConfigFile();
+
+ //Getters
+ string getVesServerIp()const;
+ string getVesServerPort()const;
+ string getVesServerUsername()const;
+ string getVesServerPassword()const;
+
+ //member functions
+ bool loadConfigFile()override;
+
+private:
+ //member variables
+ string mVesServerIp;
+ string mVesServerPort;
+ string mVesServerUsername;
+ string mVesServerPassword;
+};
+#endif
+
+/**********************************************************************
+ End of file
+ **********************************************************************/
#include "HttpClient.hpp"
/* Overloaded constructor */
-HttpClient::HttpClient(string ip, string port, string username, \
- string password): mServerIp(ip), mServerPort(port), \
- mServerUsername(username), mServerPassword(password)
+HttpClient::HttpClient(string url, string username, string password):
+ mUrl(url), mServerUsername(username),
+ mServerPassword(password)
{
}
header = curl_slist_append(header, "Content-Type: application/json");
if(!header) {
- O1_LOG("\nO1 HttpClient : curl_slist_append failed");
- curl_easy_cleanup(curl);
- return false;
+ O1_LOG("\nO1 HttpClient : curl_slist_append failed");
+ curl_easy_cleanup(curl);
+ return false;
}
- header = curl_slist_append(header, "Accept: application/json");
- if(!header) {
- O1_LOG("\nO1 HttpClient : curl_slist_append failed");
- curl_easy_cleanup(curl);
- return false;
- }
- curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header);
- if(!createUrl(curl))
- {
- O1_LOG("\nO1 HttpClient : could not create URL");
- return false;
- }
+ header = curl_slist_append(header, "Accept: application/json");
+ if(!header) {
+ O1_LOG("\nO1 HttpClient : curl_slist_append failed");
+ curl_easy_cleanup(curl);
+ return false;
+ }
+ curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header);
+
+ curl_easy_setopt(curl, CURLOPT_URL, mUrl.c_str());
+
return true;
}
return true;
}
-/*******************************************************************
- *
- * @brief creates and set URL into the curl header
- *
- * @details
- *
- * Function : createUrl
- *
- * Functionality:
- * - creates URL string and set into the curl
- *
- *
- * @params[in] pointer to curl
- * @return true : success
- * false : failure
- ******************************************************************/
-
-
-bool HttpClient::createUrl(CURL *curl)
-{
- //make the url format -- https://10.0.2.132:8443/eventListener/v7
-
- std::ostringstream oss;
- if((mServerIp.c_str()) && (mServerPort.c_str())) {
- oss <<"https://"<<mServerIp<<":"<<mServerPort<<"/eventListener/v7";
- string url = oss.str();
- O1_LOG("\nO1 HttpClient : URL=%s", url.c_str());
- curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
- return true;
- }
- else
- {
- return false;
- }
-}
/*******************************************************************
*
HttpClient(){}
~HttpClient(){}
- HttpClient(string ip, string port, string username, string password);
+ HttpClient(string url, string username=0, string password=0);
bool send(const char *send_data);
private:
bool sendHttpRequest(struct curl_slist *header, CURL *curl);
bool setCurlOptions(CURL *curl);
bool setUserPassword(CURL *curl);
- bool createUrl(CURL *curl);
//member variable
- string mServerIp;
- string mServerPort;
string mServerUsername;
string mServerPassword;
+ string mUrl;
};
#endif
return json;
}
+cJSON* JsonHelper::createArray()
+{
+ return cJSON_CreateArray();
+}
+
+cJSON_bool JsonHelper::addJsonNodeToArray(cJSON * array, cJSON* node)
+{
+ return cJSON_AddItemToArray(array, node);
+}
+
+
+
/**********************************************************************
End of file
**********************************************************************/
static char *printUnformatted(cJSON * node);
static char *print(cJSON * node);
static const char *getError();
+ static cJSON* createArray();
+ static cJSON_bool addJsonNodeToArray(cJSON * array, cJSON* node);
+
};
--- /dev/null
+/*******************************************************************************
+################################################################################
+# 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 base class for Performance Measurement VES Event*/
+
+
+#include "PerfMeasurementEvent.hpp"
+
+/* Constructor */
+PerfMeasurementEvent::PerfMeasurementEvent(VesEventType eventType)
+ :VesEvent(eventType)
+{
+
+}
+/* Default Destructor*/
+PerfMeasurementEvent::~PerfMeasurementEvent()
+{
+
+}
+
+/* overriding */
+/*******************************************************************
+ *
+ * @brief Get SMO Ves Collector configuration
+ *
+ * @details
+ *
+ * Function : getConfig
+ *
+ * Functionality:
+ * - Gets Ves Collector configuration
+ *
+ *
+ * @params[in] void
+ * @return void
+ ******************************************************************/
+void PerfMeasurementEvent::getConfig()
+{
+ mVesServerIp = ConfigLoader::instance().getSmoConfigFile().getVesServerIp();
+ mVesServerPort = ConfigLoader::instance().getSmoConfigFile().getVesServerPort();
+ mVesServerUsername = ConfigLoader::instance().getSmoConfigFile().getVesServerUsername();
+ mVesServerPassword = ConfigLoader::instance().getSmoConfigFile().getVesServerPassword();
+}
+
+/*******************************************************************
+ *
+ * @brief Create the URL for sending VES messages
+ *
+ * @details
+ *
+ * Function : createUrl (overridden)
+ *
+ * Functionality:
+ * - Creates the VES URL
+ *
+ *
+ * @params[in] void
+ * @return void
+ ******************************************************************/
+void PerfMeasurementEvent::createUrl()
+{
+ mVesUrl = "http://" + mVesServerIp + ":" + mVesServerPort + "/eventListener/v7/events";
+}
+
+/**********************************************************************
+ End of file
+**********************************************************************/
--- /dev/null
+/*******************************************************************************
+################################################################################
+# 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 base class for Performance Measurement VES Event*/
+
+#ifndef __PERF_MEASUREMENT_EVENT_HPP__
+#define __PERF_MEASUREMENT_EVENT_HPP__
+
+#include "VesEvent.hpp"
+
+class PerfMeasurementEvent : public VesEvent
+{
+
+public:
+
+ PerfMeasurementEvent(VesEventType eventType);
+ virtual ~PerfMeasurementEvent();
+
+protected:
+
+ virtual void getConfig();
+ virtual void createUrl();
+
+};
+#endif
+
+/**********************************************************************
+ End of file
+**********************************************************************/
#include <string.h>
#include <stdlib.h>
#include <sstream>
-#include "PnfRegistration.hpp"
+#include "PnfRegistrationEvent.hpp"
#include "JsonHelper.hpp"
#include "VesUtils.hpp"
/* Default constructor*/
-PnfRegistration::PnfRegistration()
+PnfRegistrationEvent::PnfRegistrationEvent()
+ : VesEvent(VesEventType::PNF_REGISTRATION)
{
- this->mVesEventType = VesEventType::PNF_REGISTRATION;
}
/* Default Destructor*/
-PnfRegistration::~PnfRegistration()
+PnfRegistrationEvent::~PnfRegistrationEvent()
{
}
*
* ****************************************************************/
-string PnfRegistration::getCurrentDate()
+string PnfRegistrationEvent::getCurrentDate()
{
time_t t = time(0);
char dateStr[MAX_TIME_STR];
*
* ****************************************************************/
-string PnfRegistration::getNetconfMacAddr()
+string PnfRegistrationEvent::getNetconfMacAddr()
{
if(mNetconfMacAddr != "") {
return mNetconfMacAddr;
}
else {
- O1_LOG("\nO1 PnfRegistration : could not get Netconf Mac Address");
+ O1_LOG("\nO1 PnfRegistrationEvent : could not get Netconf Mac Address");
return "";
}
}
*
* ****************************************************************/
-string PnfRegistration::getNetconfV4ServerIP()
+string PnfRegistrationEvent::getNetconfV4ServerIP()
{
if(mNetconfIpv4 != "") {
return mNetconfIpv4;
}
else {
- O1_LOG("\nO1 PnfRegistration : could not get Netconf IPv4 ip");
+ O1_LOG("\nO1 PnfRegistrationEvent : could not get Netconf IPv4 ip");
return "";
}
}
*
* ****************************************************************/
-string PnfRegistration::getNetconfPort()
+string PnfRegistrationEvent::getNetconfPort()
{
if(mNetconfPort != "") {
return mNetconfPort;
}
else {
- O1_LOG("\nO1 PnfRegistration : Could not get Netconf Port number");
+ O1_LOG("\nO1 PnfRegistrationEvent : Could not get Netconf Port number");
return NETCONF_DEFAULT_PORT;
}
}
* ****************************************************************/
-string PnfRegistration::getUsername()
+string PnfRegistrationEvent::getUsername()
{
if(mNetconfUsername != "") {
return mNetconfUsername;
}
else {
- O1_LOG("\nO1 PnfRegistration : could not get Netconf username");
+ O1_LOG("\nO1 PnfRegistrationEvent : could not get Netconf username");
return "";
}
}
*
* ****************************************************************/
-string PnfRegistration::getPassword()
+string PnfRegistrationEvent::getPassword()
{
if(mNetconfPassword != "") {
return mNetconfPassword;
}
else {
- O1_LOG("\nO1 PnfRegistration : could not get Netconf password");
+ O1_LOG("\nO1 PnfRegistrationEvent : could not get Netconf password");
return "";
}
}
*
* ****************************************************************/
-string PnfRegistration::getNetconfV6ServerIP()
+string PnfRegistrationEvent::getNetconfV6ServerIP()
{
if(mNetconfIpv6 != "") {
return mNetconfIpv6;
}
else {
- O1_LOG("\nO1 PnfRegistration : could not get Netconf IPv6 ip");
+ O1_LOG("\nO1 PnfRegistrationEvent : could not get Netconf IPv6 ip");
return "";
}
}
*
* ****************************************************************/
-string PnfRegistration::getSerialNumber()
+string PnfRegistrationEvent::getSerialNumber()
{
string serialNum;
serialNum.append(VENDER_NAME_VENDORB).append("-").append(UNIT_TYPE_7DEV);
*
* ****************************************************************/
-string PnfRegistration::getUnitFamily()
+string PnfRegistrationEvent::getUnitFamily()
{
string unitFamily;
unitFamily.append(VENDER_NAME_VENDORB).append("-").append(UNIT_TYPE_7DEV);
*
* @details
*
- * Function : preparePnfRegistrationFields
+ * Function : preparePnfRegistrationEventFields
*
* Functionality:
* - prepare PNF registration Fields in json format
*
* ****************************************************************/
-bool PnfRegistration::prepareEventFields()
+bool PnfRegistrationEvent::prepareEventFields(const Message* msg)
{
bool ret = true;
cJSON* pnfFields = this->mVesEventFields;
- if(!readConfigFile())
- {
- O1_LOG("\nO1 PnfRegistration : Failed to read config file");
- return false;
- }
+
+ getNetconfConfig();
+
if(JsonHelper::addNodeToObject(pnfFields, "pnfRegistrationFieldsVersion", \
PNF_REGISTRATION_VERSION_2_1) == 0) {
ret = false;
{
cJSON *addFields = JsonHelper::createNode();
if(addFields == 0) {
- O1_LOG("\nO1 PnfRegistration : could not create additional fields JSON object");
+ O1_LOG("\nO1 PnfRegistrationEvent : could not create additional fields JSON object");
return false;
}
if(prepareAdditionalFields(addFields))
{
if(addFields == 0) {
- O1_LOG("\nO1 PnfRegistration : could not prepare additional fields cJSON object");
+ O1_LOG("\nO1 PnfRegistrationEvent : could not prepare additional fields cJSON object");
JsonHelper::deleteNode(pnfFields);
return false;
}
if(JsonHelper::addJsonNodeToObject(pnfFields, "additionalFields", \
addFields) == 0) {
- O1_LOG("\nO1 PnfRegistration : could not add additional fields");
+ O1_LOG("\nO1 PnfRegistrationEvent : could not add additional fields");
JsonHelper::deleteNode(pnfFields);
return false;
}
}
- O1_LOG("\nO1 PnfRegistration : Event fields prepared for PNF registration");
+ O1_LOG("\nO1 PnfRegistrationEvent : Event fields prepared for PNF registration");
}
return ret;
}
*
* ****************************************************************/
-bool PnfRegistration::prepareAdditionalFields(cJSON *addFields)
+bool PnfRegistrationEvent::prepareAdditionalFields(cJSON *addFields)
{
bool ret = true;
if(JsonHelper::addNodeToObject(addFields, "oamPort", getNetconfPort().c_str()) == 0) {
KEEPALIVE_DELAY_120) == 0) {
ret = false;
}
- O1_LOG("\nO1 PnfRegistration : Additional fields prepared for PNF registration");
+ O1_LOG("\nO1 PnfRegistrationEvent : Additional fields prepared for PNF registration");
return ret;
}
-
/*******************************************************************
*
* @brief Read json file
* false : failure
******************************************************************/
-bool PnfRegistration::readConfigFile()
+void PnfRegistrationEvent::getNetconfConfig()
{
- cJSON *json = JsonHelper::read(NETCONF_CONFIG);
- if(json == NULL) {
- O1_LOG("\nO1 PnfRegistration : Config file reading error is :%s", JsonHelper::getError());
- return false;
- }
- else {
- cJSON *rootNode = NULL;
- rootNode = JsonHelper::getNode(json, "NetconfServer");
- if(rootNode) {
- O1_LOG("\nO1 PnfRegistration : Reading NetconfServer config file");
- mNetconfMacAddr = JsonHelper::getValue(rootNode, "MacAddress");
- mNetconfIpv4 = JsonHelper::getValue(rootNode, "NetconfServerIpv4");
- mNetconfIpv6 = JsonHelper::getValue(rootNode, "NetconfServerIpv6");
- mNetconfPort = JsonHelper::getValue(rootNode, "NetconfPort");
- mNetconfUsername = JsonHelper::getValue(rootNode, "NetconfUsername");
- mNetconfPassword = JsonHelper::getValue(rootNode, "NetconfPassword");
- }
- else {
- O1_LOG("\nO1 PnfRegistration : smoConfig Object is not available in config file");
- return false;
- }
- }
- JsonHelper::deleteNode(json);
- return true;
+ mNetconfMacAddr = ConfigLoader::instance().getNetconfConfigFile().getNetconfMacAddr();
+ mNetconfIpv4 = ConfigLoader::instance().getNetconfConfigFile().getNetconfIpv4();
+ mNetconfIpv6 = ConfigLoader::instance().getNetconfConfigFile().getNetconfIpv6();
+ mNetconfPort = ConfigLoader::instance().getNetconfConfigFile().getNetconfPort();
+ mNetconfUsername =ConfigLoader::instance().getNetconfConfigFile().getNetconfUsername();
+ mNetconfPassword = ConfigLoader::instance().getNetconfConfigFile().getNetconfPassword();
}
+
/**********************************************************************
End of file
**********************************************************************/
Registration VES Event*/
-#ifndef __PNF_REGISTRATION_HPP__
-#define __PNF_REGISTRATION_HPP__
+#ifndef __PNF_REGISTRATION_EVENT_HPP__
+#define __PNF_REGISTRATION_EVENT_HPP__
#include <iostream>
#include <string>
#include <stdio.h>
#include "VesUtils.hpp"
#include "VesEvent.hpp"
+#include "Message.hpp"
#define MAX_TIME_STR 11
using namespace std;
-class PnfRegistration : public VesEvent
+class PnfRegistrationEvent : public VesEvent
{
public:
/* Default constructor/Destructor */
- PnfRegistration();
- ~PnfRegistration();
+ PnfRegistrationEvent();
+ ~PnfRegistrationEvent();
protected:
- bool prepareEventFields();
+ bool prepareEventFields(const Message* msg = NULL);
private:
bool prepareAdditionalFields(cJSON *addFields);
string getPassword();
string getSerialNumber();
string getUnitFamily();
- bool readConfigFile();
+ void getNetconfConfig();
//member variables
string mNetconfMacAddr;
vesEvtHdr.send();
}
}
+ return true;
+
}
+
+/**********************************************************************
+ End of file
+ **********************************************************************/
\ No newline at end of file
#endif
+
+/**********************************************************************
+ End of file
+ **********************************************************************/
\ No newline at end of file
--- /dev/null
+/*******************************************************************************
+################################################################################
+# 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 SliceMeasurementEvent class for preparing the
+ Slice Measurement VES Event*/
+
+#include "SliceMeasurementEvent.hpp"
+#include "JsonHelper.hpp"
+#include "PmInterface.h"
+
+#define MEASUREMENT_INTERVAL 60
+#define MEASUREMENT_FIELDS_VERSION 4.0
+
+/* Constructor*/
+SliceMeasurementEvent::SliceMeasurementEvent()
+ : PerfMeasurementEvent(VesEventType::PM_SLICE)
+{
+}
+/* Default destructor*/
+SliceMeasurementEvent::~SliceMeasurementEvent()
+{
+}
+
+/*******************************************************************
+*
+* @brief prepare Slice Measurement Fields
+*
+* @details
+*
+* Function : prepareEventFields
+*
+* Functionality:
+* - prepare Slice Measurement Fields in json format
+*
+* @params[in] IN - const pointer of Message type
+* @return true - success
+* false - failure
+*
+* ****************************************************************/
+
+bool SliceMeasurementEvent::prepareEventFields(const Message* msg)
+{
+
+ const SliceMetrics* sliceMetrics = dynamic_cast<const SliceMetrics*> (msg);
+
+ bool ret = true;
+ cJSON *measurementFields = this->mVesEventFields;
+
+ if(JsonHelper::addNodeToObject(measurementFields, \
+ "measurementFieldsVersion", \
+ MEASUREMENT_FIELDS_VERSION) == 0)
+ {
+ ret = false;
+ }
+
+ cJSON *networkSliceArray = JsonHelper::createArray();
+
+ if(networkSliceArray == 0)
+ {
+ ret = false;
+ }
+
+ else if (JsonHelper::addJsonNodeToObject(measurementFields, \
+ "networkSliceArray", \
+ networkSliceArray) == 0)
+ {
+ ret = false;
+ }
+ else if(ret)
+ {
+ const vector<SliceMetricRecord>& sliceList = sliceMetrics->getSliceMetrics();
+ for (size_t i{0}; i < sliceList.size(); i++)
+ {
+ cJSON *Slice = JsonHelper::createNode();
+ if(Slice == 0)
+ {
+ ret = false;
+ }
+ else if (JsonHelper::addJsonNodeToArray(networkSliceArray, Slice) == 0)
+ {
+ ret = false;
+ }
+
+ else if (JsonHelper::addNodeToObject(Slice, \
+ "DRB.UEThpDl.SNSSAI", \
+ sliceList[i].DRB_UEThpDl_SNSSAI) == 0)
+ {
+ ret = false;
+ }
+
+ else if (JsonHelper::addNodeToObject(Slice, \
+ "DRB.UEThpUl.SNSSAI", \
+ sliceList[i].DRB_UEThpUl_SNSSAI) == 0)
+ {
+ ret = false;
+ }
+ else if (JsonHelper::addNodeToObject(Slice, \
+ "networkSliceIdentifier", \
+ sliceList[i].networkSliceIdentifier) == 0)
+ {
+ ret = false;
+ }
+ }
+ }
+
+ if(JsonHelper::addNodeToObject(measurementFields, \
+ "measurementInterval", \
+ MEASUREMENT_INTERVAL) == 0)
+ {
+ ret = false;
+ }
+
+ return ret;
+}
+
+/**********************************************************************
+ End of file
+**********************************************************************/
--- /dev/null
+/*******************************************************************************
+################################################################################
+# 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 SliceMeasurementEvent class for preparing the
+ Slice Measurement VES Event*/
+
+#ifndef __SLICE_MEASUREMENT_EVENT_HPP__
+#define __SLICE_MEASUREMENT_EVENT_HPP__
+
+#include <iostream>
+#include <string>
+#include "VesUtils.hpp"
+#include "PerfMeasurementEvent.hpp"
+#include <cjson/cJSON.h>
+#include "SliceMetrics.hpp"
+
+using namespace std;
+
+
+class SliceMeasurementEvent : public PerfMeasurementEvent
+{
+public:
+ SliceMeasurementEvent();
+ ~SliceMeasurementEvent();
+
+private:
+ bool prepareEventFields(const Message* msg = NULL);
+};
+#endif
+
+/**********************************************************************
+ End of file
+**********************************************************************/
static uint16_t seqNo = 0;
+#define MAX_TIME_STR 35
+
/*******************************************************************
*
* @brief provide next sequence number of VES event
case VesEventType::PM_NOTIFICATION:
str = "pmNotification";
break;
+ case VesEventType::PM_SLICE:
+ str = "measurement";
+ break;
case VesEventType::HEARTBEAT:
str = "heartbeat";
break;
{
/*Currently PNF_REGISTRATION only supported. This function must be updated
in later releases*/
+ std::ostringstream oss;
+ oss << mLastEpochTime;
+ string stringEpochTime = oss.str().substr(0, 10);
string evntId = "";
switch(mEventType)
{
evntId = getSourceName() + "_" + MODEL_NUMBER_007_DEV;
break;
case VesEventType::HEARTBEAT:
- evntId = getEventTypeToStr() + "_" + getCurrentTime();
+ evntId = getEventTypeToStr() + "_" + formatTime(getCurrentTime());
break;
+ case VesEventType::PM_SLICE:
+ evntId = "_" + stringEpochTime + "_" + "PM1min";
+ break;
+ case VesEventType::FAULT_NOTIFICATION:
+ evntId = getSourceName() + "_" + MODEL_NUMBER_007_DEV;
+ break;
default:
O1_LOG("\nO1 VesCommonHeader : this VES msg Type support in getEventId is \
not available");
break;
}
return evntId;
-
}
/*******************************************************************
evntType = EVENT_TYPE_5G;
break;
case VesEventType::HEARTBEAT:
- evntType = EVENT_TYPE_ORAN_COMPONENET;
+ evntType = EVENT_TYPE_ORAN_COMPONENT;
+ break;
+ case VesEventType::PM_SLICE:
+ evntType = EVENT_TYPE_ORAN_COMPONENT_PM;
break;
+ case VesEventType::FAULT_NOTIFICATION:
+ evntType = EVENT_TYPE_5G;
+ break;
default:
O1_LOG("\nO1 VesCommonHeader : this VES msg Type support in getEvenType is \
not available");
case VesEventType::HEARTBEAT:
evntId = PRIORITY_LOW;
break;
+ case VesEventType::PM_SLICE:
+ evntId = PRIORITY_LOW ;
+ break;
+ case VesEventType::FAULT_NOTIFICATION:
+ evntId = PRIORITY_LOW ;
+ break;
default:
O1_LOG("\nO1 VesCommonHeader : This VES msg Type support in getPriority is \
not available");
evntName = getEventTypeToStr() + "_" + EVENT_TYPE_5G;
break;
case VesEventType::HEARTBEAT:
- evntName = getEventTypeToStr() + "_" + EVENT_TYPE_ORAN_COMPONENET;
+ evntName = getEventTypeToStr() + "_" + EVENT_TYPE_ORAN_COMPONENT;
+ break;
+ case VesEventType::PM_SLICE:
+ evntName = getEventTypeToStr() + "_" + EVENT_TYPE_ORAN_COMPONENT_PM;
break;
+ case VesEventType::FAULT_NOTIFICATION:
+ evntName = getEventTypeToStr() + "_" + EVENT_TYPE_5G;
+ break;
default:
O1_LOG("\nO1 VesCommonHeader : This VES msg Type support in getEventName is \
-not available");
+ not available");
break;
}
return evntName;
string VesCommonHeader::getReportingEntityName()
{
- /*Currently PNF_REGISTRATION only supported. This function must be updated
- in later releases*/
+ /*Currently PNF_REGISTRATION and PM_SLICE are only supported.
+ This function must be updated in later releases*/
string evntName = "";
switch(mEventType)
case VesEventType::PNF_REGISTRATION:
evntName = getSourceName();
break;
+ case VesEventType::PM_SLICE:
+ evntName = PM_REPORTING_ENTITY;
+ break;
+ case VesEventType::FAULT_NOTIFICATION:
+ evntName = getSourceName();
+ break;
default:
O1_LOG("\nO1 VesCommonHeader : This VES msg Type support in \
-getReportingEntityName is not available");
+ getReportingEntityName is not available");
break;
}
return evntName;
string VesCommonHeader::getSourceName()
{
- /*Currently PNF_REGISTRATION only supported. This function need to be updated
- in later releases*/
return ODU_HIGH;
}
string VesCommonHeader::getNamingCode()
{
- /*Currently PNF_REGISTRATION only supported. This function need to be updated
- in later releases*/
return NAMING_CODE_ODU;
}
/*******************************************************************
*
- * @brief get current date-time
+ * @brief get current time
*
* @details
*
* Function : getCurrentTime
*
* Functionality:
- * - get current date-time
+ * - get current time
*
* @params[in] void
- * @return time-date - success
+ * @return time - success
*
* ****************************************************************/
-string VesCommonHeader::getCurrentTime()
+time_t VesCommonHeader::getCurrentTime()
{
- time_t t = time(0);
+ time_t t;
+ time(&t);
+ return t;
+}
+
+/*******************************************************************
+ *
+ * @brief formats the current time like:
+ * "Thu, 14 Oct 2021 03:15:00 +0000"
+ *
+ * @details
+ *
+ * Function : formatTime
+ *
+ * Functionality:
+ * - formats current time
+ *
+ * @params[in] void
+ * @return formatted time - success
+ *
+ * ****************************************************************/
+
+std::string VesCommonHeader::formatTime(time_t t) {
std::ostringstream oss;
- char *dateStr;
- strftime(dateStr, MAX_TIME_STR, "%F", localtime(&t));
- oss << dateStr;
- return oss.str();
+ char dateStr[MAX_TIME_STR];
+ strftime(dateStr, sizeof(dateStr), "%a, %d %b %Y %T %z", gmtime(&t));
+ oss << dateStr;
+ return oss.str();
}
/*******************************************************************
mEventType = type;
seqNo=0;
nextSequenceNo(); //update the sequence number for next message
+ //local utility variables:
+ time_t intervalStartTime = getCurrentTime();
+ time_t intervalEndTime = intervalStartTime+60; /*adding 1 min to system time*/
+ uint64_t startEpochTime = getEpochTime();
+ mLastEpochTime = startEpochTime+60*100000; /*adding 1 min to epoch time*/
+
if(JsonHelper::addNodeToObject(commonHeader, "domain", \
- getEventTypeToStr().c_str()) == 0) {
+ getEventTypeToStr().c_str()) == 0) {
ret=false;
}
else if ( JsonHelper::addNodeToObject(commonHeader, "eventId", \
{
ret = false;
}
- else if(JsonHelper::addNodeToObject(commonHeader, "sequence", \
+
+ if (mEventType == VesEventType::PM_SLICE)
+ {
+ cJSON *internalHeaderFields = JsonHelper::createNode();
+ if(internalHeaderFields == 0)
+ {
+ ret = false;
+ }
+ else if(JsonHelper::addJsonNodeToObject(commonHeader, "internalHeaderFields", \
+ internalHeaderFields) == 0)
+ {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(internalHeaderFields, "intervalEndTime", \
+ formatTime(intervalEndTime).c_str()) == 0)
+ {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(internalHeaderFields, "intervalStartTime", \
+ formatTime(intervalStartTime).c_str()) == 0)
+ {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(commonHeader, "nfcNamingCode", \
+ "") == 0)
+ {
+ ret = false;
+ }
+ else if(JsonHelper::addNodeToObject(commonHeader, "stndDefinedNamespace", \
+ "") == 0)
+ {
+ ret = false;
+ }
+ }
+
+ if (mEventType == VesEventType::PNF_REGISTRATION)
+ {
+
+ }
+
+ if(JsonHelper::addNodeToObject(commonHeader, "sequence", \
getSequenceNo()) == 0)
{
ret = false;
{
ret = false;
}
- else if(JsonHelper::addNodeToObject(commonHeader, "sourceId", \
+ else if(JsonHelper::addNodeToObject(commonHeader, "sourceId", \
"") == 0)
{
ret = false;
{
ret = false;
}
- else if(JsonHelper::addNodeToObject(commonHeader, "startEpochMicrosec", \
- (double) getEpochTime()) == 0)
+ else if(JsonHelper::addNodeToObject(commonHeader, "startEpochMicrosec", \
+ (double)startEpochTime) == 0)
{
ret = false;
}
else if(JsonHelper::addNodeToObject(commonHeader, "lastEpochMicrosec", \
- (double) getEpochTime()) == 0)
+ (double)mLastEpochTime) == 0)
{
ret = false;
}
else if(JsonHelper::addNodeToObject(commonHeader, "nfNamingCode", \
- getNamingCode().c_str()) == 0)
+ (type==VesEventType::PNF_REGISTRATION) ? \
+ getNamingCode().c_str() : "") == 0)
{
ret = false;
}
{
ret = false;
}
- else if(JsonHelper::addNodeToObject(commonHeader, "timeZoneOffset", \
+ else if(JsonHelper::addNodeToObject(commonHeader, "timeZoneOffset", \
TIME_ZONE_00_00) == 0)
{
ret = false;
}
- else if(JsonHelper::addNodeToObject(commonHeader, "version", \
- VERSION_4_0_1) == 0)
+
+ if (mEventType == VesEventType::PM_SLICE)
{
- ret = false;
+ if(JsonHelper::addNodeToObject(commonHeader, "version", \
+ VERSION_4_1) == 0)
+ {
+ ret = false;
+ }
+ }
+ else
+ {
+ if(JsonHelper::addNodeToObject(commonHeader, "version", \
+ VERSION_4_0_1) == 0)
+ {
+ ret = false;
+ }
}
- else if(JsonHelper::addNodeToObject(commonHeader, "vesEventListenerVersion", \
+
+ if(JsonHelper::addNodeToObject(commonHeader, "vesEventListenerVersion", \
VES_EVENT_LISTENER_7_2_1) == 0)
{
ret = false;
O1_LOG("\nO1 VesCommonHeader : VES common Header prepared");
}
return ret;
-
}
/**********************************************************************
#include <stdio.h>
#include "VesUtils.hpp"
-#define MAX_TIME_STR 11
using namespace std;
class VesCommonHeader{
string getSourceName();
string getNamingCode();
uint64_t getEpochTime();
- string getCurrentTime();
+ time_t getCurrentTime();
+ string formatTime(time_t);
+ uint64_t mLastEpochTime;
VesEventType mEventType;
};
fields */
#include "VesEvent.hpp"
+#include "Message.hpp"
+/* Constructor */
+VesEvent::VesEvent(VesEventType eventType)
+ : mVesEventType(eventType) {
-/* Default constructor*/
-VesEvent::VesEvent()
-{
- mHttpClient = NULL;
-}
+ getConfig();
+ createUrl();
+ mHttpClient = new HttpClient(mVesUrl, mVesServerUsername, mVesServerPassword);
+
+};
/* Default Destructor*/
VesEvent::~VesEvent()
{
- if(mHttpClient != NULL)
+ if ( mHttpClient != NULL )
{
delete mHttpClient;
}
+ free(mSendData);
}
/*******************************************************************
*
* ****************************************************************/
-bool VesEvent::prepare()
+bool VesEvent::prepare(const Message* msg)
{
- if(!readConfigFile()) {
- O1_LOG("\nO1 VesEvent : Could not get SMO details");
- return false;
- }
-
- mHttpClient = new HttpClient(mVesServerIp, mVesServerPort, mVesServerUsername, \
- mVesServerPassword);
-
cJSON *rootNode = JsonHelper::createNode();
if(rootNode == 0) {
O1_LOG("\nO1 VesEvent : could not create cJSON root Node object");
return false;
}
-
cJSON *event = JsonHelper::createNode();
if(event == 0) {
O1_LOG("\nO1 VesEvent : could not create event cJSON object");
JsonHelper::deleteNode(rootNode);
return false;
}
-
if(JsonHelper::addJsonNodeToObject(rootNode, "event", event) == 0) {
O1_LOG("\nO1 VesEvent : could not add event Object");
JsonHelper::deleteNode(rootNode);
return false;
}
-
cJSON *commHdrNode = JsonHelper::createNode();
if(commHdrNode == 0) {
O1_LOG("\nO1 VesEvent : could not create common header Node JSON object");
+ JsonHelper::deleteNode(rootNode);
return false;
}
-
VesCommonHeader vesCommHdr;
-
if(vesCommHdr.prepare(commHdrNode, mVesEventType))
{
- if(JsonHelper::addJsonNodeToObject(event, "commonEventHeader", \
- commHdrNode) == 0) {
- O1_LOG("\nO1 VesEvent : could not add commonEventHeader object");
- JsonHelper::deleteNode(rootNode);
- return false;
+ if(JsonHelper::addJsonNodeToObject(event, "commonEventHeader", commHdrNode) == 0)
+ {
+ O1_LOG("\nO1 VesEvent : could not add commonEventHeader object");
+ JsonHelper::deleteNode(rootNode);
+ return false;
}
else {
-
//add header into the message and create pnfFields
mVesEventFields = JsonHelper::createNode();
if(mVesEventFields == 0) {
O1_LOG("\nO1 VesEvent : could not create Ves Event Fields JSON object");
+ JsonHelper::deleteNode(rootNode);
return false;
}
-
- if(!prepareEventFields()) {
- O1_LOG("\nO1 VesEvent : could not prepare Ves Event Fields Node");
- JsonHelper::deleteNode(rootNode);
- return false;
+ if(!prepareEventFields(msg)) {
+ O1_LOG("\nO1 VesEvent : could not prepare Ves Event Fields Node");
+ JsonHelper::deleteNode(rootNode);
+ return false;
}
-
- if(JsonHelper::addJsonNodeToObject(event, "pnfRegistrationFields", mVesEventFields) == 0) {
+ if(JsonHelper::addJsonNodeToObject(event, getEventFieldName().c_str(), mVesEventFields) == 0) {
O1_LOG("\nO1 VesEvent : could not add mVesEventFields object");
JsonHelper::deleteNode(rootNode);
return false;
}
-
- mSendData = JsonHelper::printUnformatted(rootNode);
- O1_LOG("\nO1 VesEvent : VES request : -- \n%s\n", JsonHelper::print(rootNode));
+ mSendData = JsonHelper::printUnformatted(rootNode);
+ char* rootNode_string = JsonHelper::print(rootNode);
+ O1_LOG("\nO1 VesEvent : VES request : -- \n%s\n", rootNode_string);
+ free(rootNode_string);
+ JsonHelper::deleteNode(rootNode); //deleting the rootNode here; (after getting the string version of the json created)
}
}
else
/*******************************************************************
*
- * @brief Read Ves Collector config json file
+ * @brief gets Event Type name from VesEventType Enum
*
* @details
*
- * Function : readConfigFile
+ * Function : getEventFieldName
*
* Functionality:
- * - Reads json file.
+ * - returns VesEvent name
*
*
* @params[in] void
- * @return true : success
- * false : failure
+ * @return string : Ves Event Name
******************************************************************/
-bool VesEvent::readConfigFile()
+string VesEvent::getEventFieldName()
{
- cJSON *json = JsonHelper::read(VES_CONFIG);
- if(json == NULL) {
- O1_LOG("\nO1 VesEvent : Error reading config file :%s", JsonHelper::getError());
- return false;
- }
- else {
- cJSON *rootNode = NULL;
- rootNode = JsonHelper::getNode(json, "vesConfig");
- if(rootNode) {
- O1_LOG("\nO1 VesEvent : Reading smoConfig.json file\n");
- mVesServerIp = JsonHelper::getValue(rootNode, "vesV4IpAddress");
- mVesServerPort = JsonHelper::getValue(rootNode, "vesPort");
- mVesServerUsername = JsonHelper::getValue(rootNode, "username");
- mVesServerPassword = JsonHelper::getValue(rootNode, "password");
+
+ switch(mVesEventType)
+ {
+ case VesEventType::PNF_REGISTRATION:
+ {
+ return "pnfRegistrationFields";
}
- else {
- O1_LOG("\nO1 VesEvent : smoConfig Object is not available in config file");
- return false;
+ case VesEventType::FAULT_NOTIFICATION:
+ {
+ return "faultFields";
+ }
+ case VesEventType::PM_SLICE:
+ {
+ return "measurementFields";
}
+ case VesEventType::HEARTBEAT:
+ {
+ return "heartbeatFields";
+ }
+ default:
+ return "eventFields";
}
- JsonHelper::deleteNode(json);
- return true;
}
+
+/*******************************************************************
+ *
+ * @brief Get Ves Collector configuration
+ *
+ * @details
+ *
+ * Function : getConfig
+ *
+ * Functionality:
+ * - Gets Ves Collector configuration
+ *
+ *
+ * @params[in] void
+ * @return void
+ ******************************************************************/
+void VesEvent::getConfig()
+{
+ mVesServerIp = ConfigLoader::instance().getOamConfigFile().getVesServerIp();
+ mVesServerPort = ConfigLoader::instance().getOamConfigFile().getVesServerPort();
+ mVesServerUsername = ConfigLoader::instance().getOamConfigFile().getVesServerUsername();
+ mVesServerPassword = ConfigLoader::instance().getOamConfigFile().getVesServerPassword();
+}
+
+/*******************************************************************
+ *
+ * @brief Create the URL for sending VES messages
+ *
+ * @details
+ *
+ * Function : createUrl
+ *
+ * Functionality:
+ * - Creates the VES URL
+ *
+ *
+ * @params[in] void
+ * @return void
+ ******************************************************************/
+void VesEvent::createUrl()
+{
+ mVesUrl = "https://" + mVesServerIp + ":" + mVesServerPort + "/eventListener/v7";
+}
+/**********************************************************************
+ End of file
+ **********************************************************************/
+
#include "VesUtils.hpp"
#include "VesCommonHeader.hpp"
#include "HttpClient.hpp"
+#include "Message.hpp"
+#include "ConfigLoader.hpp"
using namespace std;
public:
VesEvent();
- ~VesEvent();
- bool prepare();
+ VesEvent(VesEventType);
+ virtual ~VesEvent();
+ bool prepare(const Message* msg = NULL);
bool send();
protected:
- virtual bool prepareEventFields() = 0;
+ virtual bool prepareEventFields(const Message* msg = NULL) = 0;
+ virtual void getConfig();
+ virtual void createUrl();
VesEventType mVesEventType;
cJSON* mVesEventFields;
-
- private:
- bool readConfigFile();
- char * mSendData;
- HttpClient *mHttpClient;
- string mVesServerIp;
+ string mVesServerIp;
string mVesServerPort;
string mVesServerUsername;
string mVesServerPassword;
+ string mVesUrl;
+
+ private:
+ string getEventFieldName();
+ char * mSendData;
+ HttpClient *mHttpClient;
+
};
#endif
#include "VesEventHandler.hpp"
-#include "PnfRegistration.hpp"
+#include "PnfRegistrationEvent.hpp"
+#include "SliceMeasurementEvent.hpp"
+#include "Message.hpp"
/*******************************************************************
*
*
* ****************************************************************/
-bool VesEventHandler::prepare(VesEventType evtType)
+bool VesEventHandler::prepare(VesEventType evtType, const Message* msg)
{
//check event type and call funtions accordingly
bool ret = true;
switch(evtType)
{
case VesEventType::PNF_REGISTRATION:
- {
- O1_LOG("\nO1 VesEventHandler : Preparing PNF registration");
- mVesEvent = new PnfRegistration;
- break;
- }
- case VesEventType::FAULT_NOTIFICATION:
- O1_LOG("\nO1 VesEventHandler : Preparing VES fault notification");
+ {
+ O1_LOG("\nO1 VesEventHandler : Preparing PNF registration");
+ mVesEvent = new PnfRegistrationEvent();
break;
- case VesEventType::PM_NOTIFICATION:
- O1_LOG("\nO1 VesEventHandler : Preparing VES pm notification");
- break;
- case VesEventType::HEARTBEAT:
- O1_LOG("\nO1 VesEventHandler : Preparing VES heartbeat");
+ }
+ case VesEventType::PM_SLICE:
+ {
+ mVesEvent = new SliceMeasurementEvent;
+ O1_LOG("\nO1 VesEventHandler : Preparing VES PM Slice");
break;
+ }
+
default:
- O1_LOG("\nO1 VesEventHandler : VES msg Type is not available");
+ O1_LOG("\nO1 VesEventHandler : VES message type does not exist ");
ret = false;
break;
}
- if(!mVesEvent->prepare()) {
+ if(!mVesEvent->prepare(msg)) {
O1_LOG("\nO1 VesEventHandler : Failed to prepare VES message");
ret = false;
}
/* Default constructor/Destructor*/
VesEventHandler();
~VesEventHandler();
- bool prepare(VesEventType evtType);
+ bool prepare(VesEventType evtType, const Message* msg = NULL);
bool send();
private:
//config file path
#define NETCONF_CONFIG "config/netconfConfig.json"
-#define VES_CONFIG "config/vesConfig.json"
+#define OAM_VES_CONFIG "config/oamVesConfig.json"
+#define SMO_VES_CONFIG "config/smoVesConfig.json"
//Common Header Macros
//Event Type
#define EVENT_TYPE_5G "EventType5G"
-#define EVENT_TYPE_ORAN_COMPONENET "O_RAN_COMPONENT"
+#define EVENT_TYPE_ORAN_COMPONENT "O_RAN_COMPONENT"
#define EVENT_TYPE_CONTROLLER "Controller"
//Priority
//version
#define VERSION_4_0_1 "4.0.1"
+#define VERSION_4_1 "4.1"
//Ves Event Listener Version
#define VES_EVENT_LISTENER_7_2_1 "7.2.1"
-
-
//PNF Registration Macros
#define PNF_REGISTRATION_VERSION_2_1 "2.1"
#define SOFTWARE_VERSION_2_3_5 "2.3.5"
#define BETWEEN_ATTEMPTS_TIMEOUT_2000 "2000"
#define KEEPALIVE_DELAY_120 "120"
+// PM_SLICE Macros
+#define PM_EVENT_ID "_1634181300_PM1min"
+#define PM_REPORTING_ENTITY "ORAN-DEV"
+#define EVENT_TYPE_ORAN_COMPONENT_PM "O_RAN_COMPONENT_PM1min"
+
enum class VesEventType
{
PNF_REGISTRATION,
FAULT_NOTIFICATION,
PM_NOTIFICATION,
- HEARTBEAT
+ HEARTBEAT,
+ PM_SLICE
+};
+
+enum class MessageType
+{
+ ALARM,
+ PERF_DATA,
};
#endif
+
/**********************************************************************
End of file
**********************************************************************/