From: HariomGupta Date: Mon, 6 Jun 2022 20:06:37 +0000 (+0530) Subject: Slice PM Counters VES Standard defined X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=b113656b5f48fbe9769e6cb7cea172aa930446ba;hp=e2417efa29f0d317a3ed1044ee20cc14df32e1d3;p=o-du%2Fl2.git Slice PM Counters VES Standard defined Issue-Id: ODUHIGH-431 Signed-off-by: HariomGupta Change-Id: I6b320f72ef1f5fbb4e081a6fb99cc6fa37ea66ca --- diff --git a/src/o1/ves/CellStateChange.cpp b/src/o1/ves/CellStateChange.cpp old mode 100755 new mode 100644 diff --git a/src/o1/ves/CellStateChange.hpp b/src/o1/ves/CellStateChange.hpp old mode 100755 new mode 100644 diff --git a/src/o1/ves/CellStateChangeStdDef.cpp b/src/o1/ves/CellStateChangeStdDef.cpp old mode 100755 new mode 100644 diff --git a/src/o1/ves/CellStateChangeStdDef.hpp b/src/o1/ves/CellStateChangeStdDef.hpp old mode 100755 new mode 100644 index fe83e5051..cfd6ad87e --- a/src/o1/ves/CellStateChangeStdDef.hpp +++ b/src/o1/ves/CellStateChangeStdDef.hpp @@ -28,6 +28,7 @@ #include "AlarmManager.hpp" #include "Message.hpp" #include "Notification.hpp" +#include "VesUtils.hpp" using namespace std; @@ -44,7 +45,6 @@ using namespace std; #define ADD_INFO "new" #define ALARM_ID "1" #define ALRAM_TYPE "COMMUNICATIONS_ALARM" -#define STND_DEFINED_FEILD_VERSION "1.0" #define PERCEIVED_SEVERITY "INDETERMINATE" #define PROPOSED_REPAIR_ACTION "Call the police!" #define ADDITIONAL_TEXT "O-RAN Software Community" diff --git a/src/o1/ves/Notification.cpp b/src/o1/ves/Notification.cpp old mode 100755 new mode 100644 diff --git a/src/o1/ves/Notification.hpp b/src/o1/ves/Notification.hpp old mode 100755 new mode 100644 diff --git a/src/o1/ves/PerfMeasurementEvent.cpp b/src/o1/ves/PerfMeasurementEvent.cpp index 940c6ed96..8a4f84bf4 100644 --- a/src/o1/ves/PerfMeasurementEvent.cpp +++ b/src/o1/ves/PerfMeasurementEvent.cpp @@ -51,10 +51,17 @@ PerfMeasurementEvent::~PerfMeasurementEvent() ******************************************************************/ void PerfMeasurementEvent::getConfig() { + #ifdef StdDef + mVesServerIp = ConfigLoader::instance().getOamConfigFile().getVesServerIp(); + mVesServerPort = ConfigLoader::instance().getOamConfigFile().getVesServerPort(); + mVesServerUsername = ConfigLoader::instance().getOamConfigFile().getVesServerUsername(); + mVesServerPassword = ConfigLoader::instance().getOamConfigFile().getVesServerPassword(); + #else mVesServerIp = ConfigLoader::instance().getSmoConfigFile().getVesServerIp(); mVesServerPort = ConfigLoader::instance().getSmoConfigFile().getVesServerPort(); mVesServerUsername = ConfigLoader::instance().getSmoConfigFile().getVesServerUsername(); mVesServerPassword = ConfigLoader::instance().getSmoConfigFile().getVesServerPassword(); + #endif } /******************************************************************* @@ -74,7 +81,11 @@ void PerfMeasurementEvent::getConfig() ******************************************************************/ void PerfMeasurementEvent::createUrl() { + #ifdef StdDef + mVesUrl = "https://" + mVesServerIp + ":" + mVesServerPort + "/eventListener/v7"; + #else mVesUrl = "https://" + mVesServerIp + ":" + mVesServerPort + "/eventListener/v7/events"; + #endif O1_LOG("\nURL=%s", mVesUrl.c_str()); } diff --git a/src/o1/ves/SliceMeasurementEventStdDef.cpp b/src/o1/ves/SliceMeasurementEventStdDef.cpp new file mode 100644 index 000000000..1fccb6f5d --- /dev/null +++ b/src/o1/ves/SliceMeasurementEventStdDef.cpp @@ -0,0 +1,231 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2022] [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 macros and functions to support the preparation of pnf + Registration VES Event*/ + +#include +#include +#include +#include +#include "JsonHelper.hpp" +#include "SliceMeasurementEventStdDef.hpp" +#include "CmInterface.h" + +extern NRCellDU cellParams; + +/* Default constructor*/ +SliceMeasurementEventStdDef::SliceMeasurementEventStdDef() + : PerfMeasurementEvent(VesEventType::PM_SLICE) +{ + +} + +/* Default Destructor*/ +SliceMeasurementEventStdDef::~SliceMeasurementEventStdDef() +{ + +} + +/******************************************************************* + * + * @brief Returns ISO time String + * + * @details + * + * Function :getISOEventTime + * + * Functionality: + * - Returns ISO time String + * + * @params[in] IN - void + * @return value of string - success + * empty string - failure + * + * ****************************************************************/ + +std::string SliceMeasurementEventStdDef::getISOEventTime() { + auto now = std::chrono::system_clock::now(); + auto itt = std::chrono::system_clock::to_time_t(now); + std::ostringstream os; + os << std::put_time(gmtime(&itt), "%FT%TZ"); + return os.str(); +} + +/******************************************************************* +* +* @brief prepare Stnd Slice Measurement path +* +* @details +* +* Function : getMeaspath +* +* Functionality: +* - prepare Stnd Slice Measurement path +* +* @params[in] IN - void +* @return true - path on success +* false - failure +* +* ****************************************************************/ +std::string SliceMeasurementEventStdDef::getMeasPath(string str, int sd, int sst) +{ + O1_LOG("\n O1 SliceMeasurementEventStdDef cellLocalId :%d",cellParams.cellLocalId); + std::ostringstream os; + os<<"/"< (msg); + + bool ret = true; + + cJSON* stndDefinedFields = this->mVesEventFields; + if(JsonHelper::addNodeToObject(stndDefinedFields, "stndDefinedFieldsVersion",\ + STND_DEFINED_FEILD_VERSION) == 0) + { + ret = false; + } + else if(JsonHelper::addNodeToObject(stndDefinedFields, "schemaReference",\ + SLICE_SCHEMA) == 0) + { + ret = false; + } + + cJSON* data = JsonHelper::createNode(); + if(data == 0) + { + O1_LOG("\nO1 SliceMeasurementEventStdDef : could not create data JSON object"); + return false; + } + else if(JsonHelper::addJsonNodeToObject(stndDefinedFields, "data", \ + data) == 0) { + ret = false; + } + else if(JsonHelper::addNodeToObject(data, "id", SLICE_ID) == 0) + { + ret = false; + } + else if(JsonHelper::addNodeToObject(data, "start-time",\ + getISOEventTime().c_str()) == 0) + { + ret = false; + } + else if(JsonHelper::addNodeToObject(data, "administrative-state",\ + ADMINISTRATIVE_STATE) == 0) + { + ret = false; + } + else if(JsonHelper::addNodeToObject(data, "operational-state",\ + OPERATIONAL_STATE) == 0) + { + ret = false; + } + else if(JsonHelper::addNodeToObject(data, "user-label", USER_LABEL) == 0) + { + ret = false; + } + else if(JsonHelper::addNodeToObject(data, "job-tag", "") == 0) + { + ret = false; + } + else if(JsonHelper::addNodeToObject(data, "granularity-period",\ + GRANULARITY_PERIOD) == 0) + { + ret = false; + } + + cJSON *measure= cJSON_CreateArray(); + if (measure == NULL) + { + ret = false; + } + else if(cJSON_AddItemToObject(data, "measurements", measure) == 0) + { + ret = false; + } + + else if(ret) + { + const vector& sliceList = sliceMetrics->getSliceMetrics(); + for (size_t i{0}; i < sliceList.size(); i++) + { + for(int j=0;j +#include +#include "VesUtils.hpp" +#include "JsonHelper.hpp" +#include "PerfMeasurementEvent.hpp" +#include +#include "SliceMetrics.hpp" +#include "PmInterface.h" + +using namespace std; + +//Macros +#define SLICE_SCHEMA "https://gerrit.o-ran-sc.org/r/gitweb?p=scp/oam/modeling.git;a=blob_plain;f=data-model/oas3/experimental/o-ran-sc-du-hello-world-pm-streaming-oas3.yaml" +#define SLICE_ID "pm1_1638984365" +#define ADMINISTRATIVE_STATE "unlocked" +#define OPERATIONAL_STATE "enabled" +#define USER_LABEL "pm-1" +#define GRANULARITY_PERIOD 5.0 +#define RANDOM_NUM 12345 +#define THROUGHPUT_UNIT "kbit/s" +#define MEAS_REF "measurement-type-instance-reference" +#define YANG_NAME "o-ran-sc-du-hello-world" +#define MAX_THP_TYPE 2 + +class SliceMeasurementEventStdDef : public PerfMeasurementEvent +{ + + public: + /* Default constructor/Destructor */ + SliceMeasurementEventStdDef(); + ~SliceMeasurementEventStdDef(); + + std::string getISOEventTime(); + + protected: + bool prepareEventFields(const Message* msg = NULL); + + private: + string getMeasPath(string str, int sd, int sst); + +}; + +#endif +/********************************************************************** + End of file + **********************************************************************/ diff --git a/src/o1/ves/VesCommonHeader.cpp b/src/o1/ves/VesCommonHeader.cpp index 4cbb8ed44..23e274f20 100644 --- a/src/o1/ves/VesCommonHeader.cpp +++ b/src/o1/ves/VesCommonHeader.cpp @@ -111,7 +111,11 @@ string VesCommonHeader::getEventTypeToStr() str = "pmNotification"; break; case VesEventType::PM_SLICE: + #ifdef StdDef + str = "stndDefined"; + #else str = "measurement"; + #endif break; case VesEventType::HEARTBEAT: str = "heartbeat"; @@ -157,7 +161,11 @@ string VesCommonHeader::getEventId() evntId = getEventTypeToStr() + "_" + formatTime(getCurrentTime()); break; case VesEventType::PM_SLICE: + #ifdef StdDef + evntId = SLICE_EVENTID; + #else evntId = "_" + stringEpochTime + "_" + "PM1min"; + #endif break; case VesEventType::FAULT_NOTIFICATION: #ifdef StdDef @@ -206,7 +214,11 @@ string VesCommonHeader::getEventType() evntType = EVENT_TYPE_ORAN_COMPONENT; break; case VesEventType::PM_SLICE: + #ifdef StdDef + evntType = PM_SLICE_EVENT_TYPE; + #else evntType = EVENT_TYPE_ORAN_COMPONENT_PM; + #endif break; case VesEventType::FAULT_NOTIFICATION: evntType = FAULT_TYPE; @@ -297,7 +309,11 @@ string VesCommonHeader::getEventName() evntName = getEventTypeToStr() + "_" + EVENT_TYPE_ORAN_COMPONENT; break; case VesEventType::PM_SLICE: + #ifdef StdDef + evntName = PM_SLICE_EVENT_NAME; + #else evntName = getEventTypeToStr() + "_" + EVENT_TYPE_ORAN_COMPONENT_PM; + #endif break; case VesEventType::FAULT_NOTIFICATION: #ifdef StdDef @@ -341,7 +357,9 @@ string VesCommonHeader::getReportingEntityId() case VesEventType::PNF_REGISTRATION: evntName = ODU_HIGH; break; - + case VesEventType::PM_SLICE: + evntName = ODU_HIGH; + break; case VesEventType::FAULT_NOTIFICATION: evntName = ODU_HIGH; break; @@ -414,6 +432,9 @@ string VesCommonHeader::getSourceName() case VesEventType::PNF_REGISTRATION: sourceName = ODU_HIGH; break; + case VesEventType::PM_SLICE: + sourceName = ODU_HIGH; + break; case VesEventType::FAULT_NOTIFICATION: sourceName = ODU_HIGH; break; @@ -472,6 +493,9 @@ string VesCommonHeader::getnfcNamingCode() string name = ""; switch(mEventType) { + case VesEventType::PM_SLICE: + name = NFC_NAMING_CODE; + break; case VesEventType::FAULT_NOTIFICATION: name = NFC_NAMING_CODE; break; @@ -508,6 +532,7 @@ string VesCommonHeader::getNamingCode() nammingcdoe = NAMING_CODE_ODU; break; case VesEventType::PM_SLICE: + nammingcdoe = NAMING_CODE_ODU; break; case VesEventType::FAULT_NOTIFICATION: nammingcdoe = NAMING_CODE_ODU; @@ -615,8 +640,11 @@ string VesCommonHeader::getstndDefinedNamespace() string stndDefinedNamespace=""; switch(mEventType) { + case VesEventType::PM_SLICE: + stndDefinedNamespace = PM_SLICE_STND_DEFINED_NAMESPACE; + break; case VesEventType::FAULT_NOTIFICATION: - stndDefinedNamespace = STND_DEFINED_NAMESPACE; + stndDefinedNamespace = FAULT_STND_DEFINED_NAMESPACE; break; default: break; @@ -679,6 +707,8 @@ bool VesCommonHeader::prepare(cJSON *commonHeader, \ ret = false; } + #ifdef StdDef + #else if (mEventType == VesEventType::PM_SLICE) { cJSON *internalHeaderFields = JsonHelper::createNode(); @@ -702,11 +732,7 @@ bool VesCommonHeader::prepare(cJSON *commonHeader, \ ret = false; } } - - if (mEventType == VesEventType::PNF_REGISTRATION) - { - - } + #endif if(JsonHelper::addNodeToObject(commonHeader, "sequence", \ getSequenceNo()) == 0) @@ -769,28 +795,17 @@ bool VesCommonHeader::prepare(cJSON *commonHeader, \ ret = false; } - if (mEventType == VesEventType::PM_SLICE) - { - if(JsonHelper::addNodeToObject(commonHeader, "version", \ - VERSION_4_1) == 0) - { - ret = false; - } - } - else - { - if(JsonHelper::addNodeToObject(commonHeader, "version", \ + else if(JsonHelper::addNodeToObject(commonHeader, "version", \ COMMON_HEADER_VERSION) == 0) - { - ret = false; - } + { + ret = false; } - if(JsonHelper::addNodeToObject(commonHeader, "stndDefinedNamespace", \ + else if(JsonHelper::addNodeToObject(commonHeader, "stndDefinedNamespace", \ getstndDefinedNamespace().c_str())== 0) { ret = false; } - if(JsonHelper::addNodeToObject(commonHeader, "vesEventListenerVersion", \ + else if(JsonHelper::addNodeToObject(commonHeader, "vesEventListenerVersion", \ VES_EVENT_LISNERT_VERSION) == 0) { ret = false; diff --git a/src/o1/ves/VesEvent.cpp b/src/o1/ves/VesEvent.cpp index f06cb2a59..9415df670 100644 --- a/src/o1/ves/VesEvent.cpp +++ b/src/o1/ves/VesEvent.cpp @@ -211,7 +211,11 @@ string VesEvent::getEventFieldName() } case VesEventType::PM_SLICE: { + #ifdef StdDef + return "stndDefinedFields"; + #else return "measurementFields"; + #endif } case VesEventType::HEARTBEAT: { diff --git a/src/o1/ves/VesEventHandler.cpp b/src/o1/ves/VesEventHandler.cpp index 18e45a75d..bf52f1d50 100644 --- a/src/o1/ves/VesEventHandler.cpp +++ b/src/o1/ves/VesEventHandler.cpp @@ -26,6 +26,7 @@ #include "Message.hpp" #include "CellStateChange.hpp" #include "CellStateChangeStdDef.hpp" +#include "SliceMeasurementEventStdDef.hpp" /******************************************************************* * @@ -97,8 +98,13 @@ bool VesEventHandler::prepare(VesEventType evtType, const Message* msg) } case VesEventType::PM_SLICE: { + #ifdef StdDef + mVesEvent = new SliceMeasurementEventStdDef; + O1_LOG("\nO1 VesEventHandler : Preparing Standard VES PM Slice"); + #else mVesEvent = new SliceMeasurementEvent; O1_LOG("\nO1 VesEventHandler : Preparing VES PM Slice"); + #endif break; } case VesEventType::FAULT_NOTIFICATION: diff --git a/src/o1/ves/VesUtils.hpp b/src/o1/ves/VesUtils.hpp index 84df3bda8..d48b2c8db 100644 --- a/src/o1/ves/VesUtils.hpp +++ b/src/o1/ves/VesUtils.hpp @@ -24,14 +24,14 @@ #include #include "GlobalDefs.hpp" -#define StdDef 1 +//#define StdDef 1 //config file path #define NETCONF_CONFIG "config/netconfConfig.json" #define OAM_VES_CONFIG "config/oamVesConfig.json" #define SMO_VES_CONFIG "config/smoVesConfig.json" //Common Header Macros -#define STND_DEFINED_NAMESPACE "3GPP-FaultSupervision" +#define FAULT_STND_DEFINED_NAMESPACE "3GPP-FaultSupervision" #define COMMON_HEADER_VERSION "4.0.1" #define VES_EVENT_LISNERT_VERSION "7.2.1" @@ -55,10 +55,6 @@ //Timezone Offset #define TIME_ZONE_00_00 "+00:00" -//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" @@ -84,14 +80,21 @@ // PM_SLICE Macros #define PM_EVENT_ID "_1634181300_PM1min" +#define SLICE_EVENTID "pm1_1638984365" #define PM_REPORTING_ENTITY "ORAN-DEV" #define EVENT_TYPE_ORAN_COMPONENT_PM "O_RAN_COMPONENT_PM1min" +#define PM_SLICE_EVENT_TYPE "performanceMeasurementStreaming" +#define PM_SLICE_EVENT_NAME "stndDefined_performanceMeasurementStreaming" +#define PM_SLICE_STND_DEFINED_NAMESPACE "o-ran-sc-du-hello-world-pm-streaming-oas3" //NOTIFICATION Macros #define FAULT_EVENTID "Alarm000000001" #define FAULT_TYPE "alarm" #define FAULT_EVENT_NAME "COMMUNICATIONS_ALARM" +//STND DEFINED Macros +#define STND_DEFINED_FEILD_VERSION "1.0" + enum class VesEventType { PNF_REGISTRATION,