From e850787b10d1f3882e2501e0eef12737b12d078f Mon Sep 17 00:00:00 2001 From: Vidhu Date: Wed, 24 Nov 2021 01:25:27 +0530 Subject: [PATCH] VES PM data for slicing use case. [Issue-Id: ODUHIGH-384] Added function to send the slice performance counters to SMO Signed-off-by: Vidhu Change-Id: Idc758936a1c7c4c13592017cdfdc5340efc29278 --- build/config/{vesConfig.json => oamVesConfig.json} | 0 build/config/smoVesConfig.json | 8 + src/o1/Alarm.hpp | 8 +- src/o1/AlarmManager.cpp | 3 + src/o1/AlarmManager.hpp | 4 + src/o1/ConfigFile.hpp | 39 +++++ src/o1/ConfigLoader.cpp | 120 ++++++++++++++ src/o1/ConfigLoader.hpp | 54 ++++++ src/o1/Message.hpp | 44 +++++ src/o1/NetconfConfigFile.cpp | 108 ++++++++++++ src/o1/NetconfConfigFile.hpp | 60 +++++++ src/o1/O1Interface.cpp | 4 + src/o1/PmInterface.cpp | 67 ++++++++ src/o1/PmInterface.h | 56 +++++++ src/o1/SliceMetrics.cpp | 75 +++++++++ src/o1/SliceMetrics.hpp | 49 ++++++ src/o1/Thread.cpp | 4 + src/o1/Thread.hpp | 6 +- src/o1/UnixSocketServer.cpp | 17 ++ src/o1/VesConfigFile.cpp | 102 ++++++++++++ src/o1/VesConfigFile.hpp | 55 +++++++ src/o1/ves/HttpClient.cpp | 69 ++------ src/o1/ves/HttpClient.hpp | 6 +- src/o1/ves/JsonHelper.cpp | 12 ++ src/o1/ves/JsonHelper.hpp | 3 + src/o1/ves/PerfMeasurementEvent.cpp | 82 ++++++++++ src/o1/ves/PerfMeasurementEvent.hpp | 44 +++++ ...nfRegistration.cpp => PnfRegistrationEvent.cpp} | 96 +++++------ ...nfRegistration.hpp => PnfRegistrationEvent.hpp} | 15 +- src/o1/ves/PnfRegistrationThread.cpp | 6 + src/o1/ves/PnfRegistrationThread.hpp | 4 + src/o1/ves/SliceMeasurementEvent.cpp | 133 +++++++++++++++ src/o1/ves/SliceMeasurementEvent.hpp | 49 ++++++ src/o1/ves/VesCommonHeader.cpp | 182 +++++++++++++++++---- src/o1/ves/VesCommonHeader.hpp | 5 +- src/o1/ves/VesEvent.cpp | 161 +++++++++++------- src/o1/ves/VesEvent.hpp | 25 ++- src/o1/ves/VesEventHandler.cpp | 32 ++-- src/o1/ves/VesEventHandler.hpp | 2 +- src/o1/ves/VesUtils.hpp | 23 ++- 40 files changed, 1576 insertions(+), 256 deletions(-) rename build/config/{vesConfig.json => oamVesConfig.json} (100%) create mode 100644 build/config/smoVesConfig.json create mode 100644 src/o1/ConfigFile.hpp create mode 100644 src/o1/ConfigLoader.cpp create mode 100644 src/o1/ConfigLoader.hpp create mode 100644 src/o1/Message.hpp create mode 100644 src/o1/NetconfConfigFile.cpp create mode 100644 src/o1/NetconfConfigFile.hpp create mode 100644 src/o1/PmInterface.cpp create mode 100644 src/o1/PmInterface.h create mode 100644 src/o1/SliceMetrics.cpp create mode 100644 src/o1/SliceMetrics.hpp create mode 100644 src/o1/VesConfigFile.cpp create mode 100644 src/o1/VesConfigFile.hpp create mode 100644 src/o1/ves/PerfMeasurementEvent.cpp create mode 100644 src/o1/ves/PerfMeasurementEvent.hpp rename src/o1/ves/{PnfRegistration.cpp => PnfRegistrationEvent.cpp} (81%) rename src/o1/ves/{PnfRegistration.hpp => PnfRegistrationEvent.hpp} (89%) create mode 100644 src/o1/ves/SliceMeasurementEvent.cpp create mode 100644 src/o1/ves/SliceMeasurementEvent.hpp diff --git a/build/config/vesConfig.json b/build/config/oamVesConfig.json similarity index 100% rename from build/config/vesConfig.json rename to build/config/oamVesConfig.json diff --git a/build/config/smoVesConfig.json b/build/config/smoVesConfig.json new file mode 100644 index 000000000..f1299b5f8 --- /dev/null +++ b/build/config/smoVesConfig.json @@ -0,0 +1,8 @@ +{ + "vesConfig": { + "vesV4IpAddress" : "10.0.2.135", + "vesPort" : "9999", + "username" : "user", + "password" : "password" + } +} diff --git a/src/o1/Alarm.hpp b/src/o1/Alarm.hpp index c4d84132c..2249445b4 100644 --- a/src/o1/Alarm.hpp +++ b/src/o1/Alarm.hpp @@ -24,13 +24,13 @@ #include #include #include "AlarmMessages.h" +#include "Message.hpp" using std::string; -class Alarm +class Alarm : public Message { - private: EventType mEventType; string mObjectClassObjectInstance; @@ -46,8 +46,8 @@ class Alarm string mSpecificProblem; public: - Alarm(){}; - ~Alarm(){}; + Alarm() {} + ~Alarm(){} /* Getter functions */ inline const EventType& getEventType()const { diff --git a/src/o1/AlarmManager.cpp b/src/o1/AlarmManager.cpp index 3ed8aca7b..b396188d4 100644 --- a/src/o1/AlarmManager.cpp +++ b/src/o1/AlarmManager.cpp @@ -47,9 +47,12 @@ AlarmManager::~AlarmManager() **********************************************************************/ bool AlarmManager::raiseAlarm(const Alarm& alarm) { + pair::iterator,bool> ret; ret = mAlarmList.insert(pair(alarm.getAlarmId(),alarm)); return ret.second; + + } diff --git a/src/o1/AlarmManager.hpp b/src/o1/AlarmManager.hpp index a30fa9a36..0562f63bf 100644 --- a/src/o1/AlarmManager.hpp +++ b/src/o1/AlarmManager.hpp @@ -27,6 +27,10 @@ #include "Alarm.hpp" #include "Singleton.hpp" +#include "PnfRegistrationThread.hpp" +#include "VesUtils.hpp" +#include "VesEventHandler.hpp" + using std::map; diff --git a/src/o1/ConfigFile.hpp b/src/o1/ConfigFile.hpp new file mode 100644 index 000000000..cee4cc62c --- /dev/null +++ b/src/o1/ConfigFile.hpp @@ -0,0 +1,39 @@ +/******************************************************************************* +################################################################################ +# 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 + +using std::string; + +class ConfigFile { +public: + ConfigFile(string filepath) : mFilepath(filepath) {} + ~ConfigFile() {} + virtual bool loadConfigFile() = 0; +protected: + string mFilepath; +}; +#endif + +/********************************************************************** + End of file + **********************************************************************/ diff --git a/src/o1/ConfigLoader.cpp b/src/o1/ConfigLoader.cpp new file mode 100644 index 000000000..041a05a97 --- /dev/null +++ b/src/o1/ConfigLoader.cpp @@ -0,0 +1,120 @@ +/******************************************************************************* +################################################################################ +# 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 + **********************************************************************/ diff --git a/src/o1/ConfigLoader.hpp b/src/o1/ConfigLoader.hpp new file mode 100644 index 000000000..a4a7290bf --- /dev/null +++ b/src/o1/ConfigLoader.hpp @@ -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 is a singleton class to load and store all configuration parameters */ + +#ifndef __CONFIG_LOADER_HPP__ +#define __CONFIG_LOADER_HPP__ + +#include +#include "VesConfigFile.hpp" +#include "NetconfConfigFile.hpp" +#include "VesUtils.hpp" +#include "Singleton.hpp" + +using std::string; + +class ConfigLoader : public Singleton { +private: + ConfigLoader(); + ~ConfigLoader(); + + VesConfigFile mOamConfig; + VesConfigFile mSmoConfig; + NetconfConfigFile mNetconfConfig; + +public: + friend Singleton; + + const VesConfigFile& getOamConfigFile()const; + const VesConfigFile& getSmoConfigFile()const; + const NetconfConfigFile& getNetconfConfigFile()const; + + bool loadConfigurations(); +}; + +#endif + +/********************************************************************** + End of file + **********************************************************************/ diff --git a/src/o1/Message.hpp b/src/o1/Message.hpp new file mode 100644 index 000000000..dc0b883f1 --- /dev/null +++ b/src/o1/Message.hpp @@ -0,0 +1,44 @@ +/******************************************************************************* +################################################################################ +# 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 +**********************************************************************/ diff --git a/src/o1/NetconfConfigFile.cpp b/src/o1/NetconfConfigFile.cpp new file mode 100644 index 000000000..79e1cdea5 --- /dev/null +++ b/src/o1/NetconfConfigFile.cpp @@ -0,0 +1,108 @@ +/******************************************************************************* +################################################################################ +# 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 + **********************************************************************/ diff --git a/src/o1/NetconfConfigFile.hpp b/src/o1/NetconfConfigFile.hpp new file mode 100644 index 000000000..58cef4284 --- /dev/null +++ b/src/o1/NetconfConfigFile.hpp @@ -0,0 +1,60 @@ +/******************************************************************************* +################################################################################ +# 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 + + +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 + **********************************************************************/ diff --git a/src/o1/O1Interface.cpp b/src/o1/O1Interface.cpp index c0c552a38..b1fdeff12 100644 --- a/src/o1/O1Interface.cpp +++ b/src/o1/O1Interface.cpp @@ -22,6 +22,7 @@ #include "O1App.hpp" #include "GlobalDefs.hpp" #include "PnfRegistrationThread.hpp" +#include "ConfigLoader.hpp" #include #include @@ -85,6 +86,9 @@ int static check_O1_module_status(void){ 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; diff --git a/src/o1/PmInterface.cpp b/src/o1/PmInterface.cpp new file mode 100644 index 000000000..b36bce2ce --- /dev/null +++ b/src/o1/PmInterface.cpp @@ -0,0 +1,67 @@ +/******************************************************************************* +################################################################################ +# 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 +#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 +**********************************************************************/ diff --git a/src/o1/PmInterface.h b/src/o1/PmInterface.h new file mode 100644 index 000000000..5208779a6 --- /dev/null +++ b/src/o1/PmInterface.h @@ -0,0 +1,56 @@ +/******************************************************************************* +################################################################################ +# 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 + +#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 +**********************************************************************/ diff --git a/src/o1/SliceMetrics.cpp b/src/o1/SliceMetrics.cpp new file mode 100644 index 000000000..df843efc2 --- /dev/null +++ b/src/o1/SliceMetrics.cpp @@ -0,0 +1,75 @@ +/******************************************************************************* +################################################################################ +# 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 + ******************************************************************/ +const vector& SliceMetrics::getSliceMetrics() const { + return mSliceList; +} + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/o1/SliceMetrics.hpp b/src/o1/SliceMetrics.hpp new file mode 100644 index 000000000..b72d71624 --- /dev/null +++ b/src/o1/SliceMetrics.hpp @@ -0,0 +1,49 @@ +/******************************************************************************* +################################################################################ +# 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 +#include +#include "Message.hpp" +#include "PmInterface.h" + +using namespace std; + +class SliceMetrics : public Message { + +public: + SliceMetrics(); + ~SliceMetrics(); + + const vector& getSliceMetrics() const; + void addMetric(SliceMetricRecord& sliceMetricRecord); + +private: + vector mSliceList; + +}; + +#endif + +/********************************************************************** +End of file +**********************************************************************/ diff --git a/src/o1/Thread.cpp b/src/o1/Thread.cpp index 266c21b5f..70b71d513 100644 --- a/src/o1/Thread.cpp +++ b/src/o1/Thread.cpp @@ -220,3 +220,7 @@ bool Thread::printAffinity() O1_LOG("CPU %d ", i); return true; } + +/********************************************************************** +End of file +**********************************************************************/ \ No newline at end of file diff --git a/src/o1/Thread.hpp b/src/o1/Thread.hpp index 9f9ee514e..68c5ef8ac 100644 --- a/src/o1/Thread.hpp +++ b/src/o1/Thread.hpp @@ -43,6 +43,8 @@ class Thread bool join(); }; - - #endif + +/********************************************************************** +End of file +**********************************************************************/ \ No newline at end of file diff --git a/src/o1/UnixSocketServer.cpp b/src/o1/UnixSocketServer.cpp index 528e0398a..412d28820 100644 --- a/src/o1/UnixSocketServer.cpp +++ b/src/o1/UnixSocketServer.cpp @@ -147,12 +147,22 @@ int UnixSocketServer::readMessage(int fd) 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 : " @@ -160,12 +170,19 @@ int UnixSocketServer::readMessage(int fd) 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 { diff --git a/src/o1/VesConfigFile.cpp b/src/o1/VesConfigFile.cpp new file mode 100644 index 000000000..d2f6c6923 --- /dev/null +++ b/src/o1/VesConfigFile.cpp @@ -0,0 +1,102 @@ +/******************************************************************************* +################################################################################ +# 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 + **********************************************************************/ diff --git a/src/o1/VesConfigFile.hpp b/src/o1/VesConfigFile.hpp new file mode 100644 index 000000000..0a139411e --- /dev/null +++ b/src/o1/VesConfigFile.hpp @@ -0,0 +1,55 @@ +/******************************************************************************* +################################################################################ +# 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 +#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 + **********************************************************************/ diff --git a/src/o1/ves/HttpClient.cpp b/src/o1/ves/HttpClient.cpp index 261f5aed8..7aed15f80 100644 --- a/src/o1/ves/HttpClient.cpp +++ b/src/o1/ves/HttpClient.cpp @@ -24,9 +24,9 @@ #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) { } @@ -96,23 +96,21 @@ bool HttpClient::prepareHttpHeader(struct curl_slist *header, CURL *curl) 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; } @@ -155,41 +153,6 @@ bool HttpClient::setUserPassword(CURL *curl) 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://"< #include #include -#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() { } @@ -56,7 +56,7 @@ PnfRegistration::~PnfRegistration() * * ****************************************************************/ -string PnfRegistration::getCurrentDate() +string PnfRegistrationEvent::getCurrentDate() { time_t t = time(0); char dateStr[MAX_TIME_STR]; @@ -82,13 +82,13 @@ string PnfRegistration::getCurrentDate() * * ****************************************************************/ -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 ""; } } @@ -110,13 +110,13 @@ string PnfRegistration::getNetconfMacAddr() * * ****************************************************************/ -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 ""; } } @@ -138,13 +138,13 @@ string PnfRegistration::getNetconfV4ServerIP() * * ****************************************************************/ -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; } } @@ -167,13 +167,13 @@ string PnfRegistration::getNetconfPort() * ****************************************************************/ -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 ""; } } @@ -195,13 +195,13 @@ string PnfRegistration::getUsername() * * ****************************************************************/ -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 ""; } } @@ -222,13 +222,13 @@ string PnfRegistration::getPassword() * * ****************************************************************/ -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 ""; } } @@ -250,7 +250,7 @@ string PnfRegistration::getNetconfV6ServerIP() * * ****************************************************************/ -string PnfRegistration::getSerialNumber() +string PnfRegistrationEvent::getSerialNumber() { string serialNum; serialNum.append(VENDER_NAME_VENDORB).append("-").append(UNIT_TYPE_7DEV); @@ -278,7 +278,7 @@ string PnfRegistration::getSerialNumber() * * ****************************************************************/ -string PnfRegistration::getUnitFamily() +string PnfRegistrationEvent::getUnitFamily() { string unitFamily; unitFamily.append(VENDER_NAME_VENDORB).append("-").append(UNIT_TYPE_7DEV); @@ -292,7 +292,7 @@ string PnfRegistration::getUnitFamily() * * @details * - * Function : preparePnfRegistrationFields + * Function : preparePnfRegistrationEventFields * * Functionality: * - prepare PNF registration Fields in json format @@ -303,15 +303,13 @@ string PnfRegistration::getUnitFamily() * * ****************************************************************/ -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; @@ -365,26 +363,26 @@ bool PnfRegistration::prepareEventFields() { 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; } @@ -406,7 +404,7 @@ bool PnfRegistration::prepareEventFields() * * ****************************************************************/ -bool PnfRegistration::prepareAdditionalFields(cJSON *addFields) +bool PnfRegistrationEvent::prepareAdditionalFields(cJSON *addFields) { bool ret = true; if(JsonHelper::addNodeToObject(addFields, "oamPort", getNetconfPort().c_str()) == 0) { @@ -453,10 +451,9 @@ bool PnfRegistration::prepareAdditionalFields(cJSON *addFields) 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 @@ -474,34 +471,17 @@ bool PnfRegistration::prepareAdditionalFields(cJSON *addFields) * 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 **********************************************************************/ diff --git a/src/o1/ves/PnfRegistration.hpp b/src/o1/ves/PnfRegistrationEvent.hpp similarity index 89% rename from src/o1/ves/PnfRegistration.hpp rename to src/o1/ves/PnfRegistrationEvent.hpp index 72f0d22f4..041b1e2a4 100644 --- a/src/o1/ves/PnfRegistration.hpp +++ b/src/o1/ves/PnfRegistrationEvent.hpp @@ -20,8 +20,8 @@ Registration VES Event*/ -#ifndef __PNF_REGISTRATION_HPP__ -#define __PNF_REGISTRATION_HPP__ +#ifndef __PNF_REGISTRATION_EVENT_HPP__ +#define __PNF_REGISTRATION_EVENT_HPP__ #include #include @@ -30,21 +30,22 @@ #include #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); @@ -57,7 +58,7 @@ class PnfRegistration : public VesEvent string getPassword(); string getSerialNumber(); string getUnitFamily(); - bool readConfigFile(); + void getNetconfConfig(); //member variables string mNetconfMacAddr; diff --git a/src/o1/ves/PnfRegistrationThread.cpp b/src/o1/ves/PnfRegistrationThread.cpp index 61583273f..b50140aef 100644 --- a/src/o1/ves/PnfRegistrationThread.cpp +++ b/src/o1/ves/PnfRegistrationThread.cpp @@ -45,4 +45,10 @@ bool PnfRegistrationThread::run() vesEvtHdr.send(); } } + return true; + } + +/********************************************************************** + End of file + **********************************************************************/ \ No newline at end of file diff --git a/src/o1/ves/PnfRegistrationThread.hpp b/src/o1/ves/PnfRegistrationThread.hpp index 607bd5f11..bfdc6ab85 100644 --- a/src/o1/ves/PnfRegistrationThread.hpp +++ b/src/o1/ves/PnfRegistrationThread.hpp @@ -42,3 +42,7 @@ class PnfRegistrationThread : public Singleton, public Th #endif + +/********************************************************************** + End of file + **********************************************************************/ \ No newline at end of file diff --git a/src/o1/ves/SliceMeasurementEvent.cpp b/src/o1/ves/SliceMeasurementEvent.cpp new file mode 100644 index 000000000..ab219bb51 --- /dev/null +++ b/src/o1/ves/SliceMeasurementEvent.cpp @@ -0,0 +1,133 @@ +/******************************************************************************* +################################################################################ +# 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 (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& 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 +**********************************************************************/ diff --git a/src/o1/ves/SliceMeasurementEvent.hpp b/src/o1/ves/SliceMeasurementEvent.hpp new file mode 100644 index 000000000..7233e8fe9 --- /dev/null +++ b/src/o1/ves/SliceMeasurementEvent.hpp @@ -0,0 +1,49 @@ +/******************************************************************************* +################################################################################ +# 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 +#include +#include "VesUtils.hpp" +#include "PerfMeasurementEvent.hpp" +#include +#include "SliceMetrics.hpp" + +using namespace std; + + +class SliceMeasurementEvent : public PerfMeasurementEvent +{ +public: + SliceMeasurementEvent(); + ~SliceMeasurementEvent(); + +private: + bool prepareEventFields(const Message* msg = NULL); +}; +#endif + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/o1/ves/VesCommonHeader.cpp b/src/o1/ves/VesCommonHeader.cpp index 864ea84ca..ce7214ddd 100644 --- a/src/o1/ves/VesCommonHeader.cpp +++ b/src/o1/ves/VesCommonHeader.cpp @@ -30,6 +30,8 @@ static uint16_t seqNo = 0; +#define MAX_TIME_STR 35 + /******************************************************************* * * @brief provide next sequence number of VES event @@ -103,6 +105,9 @@ string VesCommonHeader::getEventTypeToStr() case VesEventType::PM_NOTIFICATION: str = "pmNotification"; break; + case VesEventType::PM_SLICE: + str = "measurement"; + break; case VesEventType::HEARTBEAT: str = "heartbeat"; break; @@ -134,6 +139,9 @@ string VesCommonHeader::getEventId() { /*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) { @@ -141,15 +149,20 @@ string VesCommonHeader::getEventId() 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; - } /******************************************************************* @@ -181,8 +194,14 @@ string VesCommonHeader::getEventType() 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"); @@ -222,6 +241,12 @@ string VesCommonHeader::getPriority() 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"); @@ -260,11 +285,17 @@ string VesCommonHeader::getEventName() 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; @@ -288,8 +319,8 @@ not available"); 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) @@ -297,9 +328,15 @@ string VesCommonHeader::getReportingEntityName() 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; @@ -323,8 +360,6 @@ getReportingEntityName is not available"); string VesCommonHeader::getSourceName() { - /*Currently PNF_REGISTRATION only supported. This function need to be updated - in later releases*/ return ODU_HIGH; } @@ -347,8 +382,6 @@ string VesCommonHeader::getSourceName() string VesCommonHeader::getNamingCode() { - /*Currently PNF_REGISTRATION only supported. This function need to be updated - in later releases*/ return NAMING_CODE_ODU; } @@ -380,28 +413,50 @@ uint64_t VesCommonHeader::getEpochTime() /******************************************************************* * - * @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(); } /******************************************************************* @@ -431,8 +486,14 @@ bool VesCommonHeader::prepare(cJSON *commonHeader, \ 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", \ @@ -450,7 +511,47 @@ bool VesCommonHeader::prepare(cJSON *commonHeader, \ { 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; @@ -470,7 +571,7 @@ bool VesCommonHeader::prepare(cJSON *commonHeader, \ { ret = false; } - else if(JsonHelper::addNodeToObject(commonHeader, "sourceId", \ + else if(JsonHelper::addNodeToObject(commonHeader, "sourceId", \ "") == 0) { ret = false; @@ -480,18 +581,19 @@ bool VesCommonHeader::prepare(cJSON *commonHeader, \ { 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; } @@ -500,17 +602,30 @@ bool VesCommonHeader::prepare(cJSON *commonHeader, \ { 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; @@ -520,7 +635,6 @@ bool VesCommonHeader::prepare(cJSON *commonHeader, \ O1_LOG("\nO1 VesCommonHeader : VES common Header prepared"); } return ret; - } /********************************************************************** diff --git a/src/o1/ves/VesCommonHeader.hpp b/src/o1/ves/VesCommonHeader.hpp index 21e0d6e69..96f850b92 100644 --- a/src/o1/ves/VesCommonHeader.hpp +++ b/src/o1/ves/VesCommonHeader.hpp @@ -32,7 +32,6 @@ #include #include "VesUtils.hpp" -#define MAX_TIME_STR 11 using namespace std; class VesCommonHeader{ @@ -56,7 +55,9 @@ class VesCommonHeader{ string getSourceName(); string getNamingCode(); uint64_t getEpochTime(); - string getCurrentTime(); + time_t getCurrentTime(); + string formatTime(time_t); + uint64_t mLastEpochTime; VesEventType mEventType; }; diff --git a/src/o1/ves/VesEvent.cpp b/src/o1/ves/VesEvent.cpp index 23a4d88ea..a12d1c75e 100644 --- a/src/o1/ves/VesEvent.cpp +++ b/src/o1/ves/VesEvent.cpp @@ -22,22 +22,27 @@ 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); } /******************************************************************* @@ -57,75 +62,63 @@ VesEvent::~VesEvent() * * ****************************************************************/ -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 @@ -144,43 +137,89 @@ bool VesEvent::send() /******************************************************************* * - * @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 + **********************************************************************/ + diff --git a/src/o1/ves/VesEvent.hpp b/src/o1/ves/VesEvent.hpp index c1254da9e..2f151311b 100644 --- a/src/o1/ves/VesEvent.hpp +++ b/src/o1/ves/VesEvent.hpp @@ -30,6 +30,8 @@ #include "VesUtils.hpp" #include "VesCommonHeader.hpp" #include "HttpClient.hpp" +#include "Message.hpp" +#include "ConfigLoader.hpp" using namespace std; @@ -37,23 +39,28 @@ class VesEvent{ 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 diff --git a/src/o1/ves/VesEventHandler.cpp b/src/o1/ves/VesEventHandler.cpp index 48e0ff62d..60f85137c 100644 --- a/src/o1/ves/VesEventHandler.cpp +++ b/src/o1/ves/VesEventHandler.cpp @@ -21,7 +21,9 @@ #include "VesEventHandler.hpp" -#include "PnfRegistration.hpp" +#include "PnfRegistrationEvent.hpp" +#include "SliceMeasurementEvent.hpp" +#include "Message.hpp" /******************************************************************* * @@ -79,33 +81,31 @@ VesEventHandler::~VesEventHandler() * * ****************************************************************/ -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; } diff --git a/src/o1/ves/VesEventHandler.hpp b/src/o1/ves/VesEventHandler.hpp index c3041909d..9925f02f7 100644 --- a/src/o1/ves/VesEventHandler.hpp +++ b/src/o1/ves/VesEventHandler.hpp @@ -34,7 +34,7 @@ class VesEventHandler /* Default constructor/Destructor*/ VesEventHandler(); ~VesEventHandler(); - bool prepare(VesEventType evtType); + bool prepare(VesEventType evtType, const Message* msg = NULL); bool send(); private: diff --git a/src/o1/ves/VesUtils.hpp b/src/o1/ves/VesUtils.hpp index a86d72bb3..c9da3fff0 100644 --- a/src/o1/ves/VesUtils.hpp +++ b/src/o1/ves/VesUtils.hpp @@ -26,13 +26,14 @@ //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 @@ -50,12 +51,11 @@ //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" @@ -76,16 +76,29 @@ #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 **********************************************************************/ -- 2.16.6