#include "AlarmManager.hpp"
#include "Message.hpp"
#include "Notification.hpp"
+#include "VesUtils.hpp"
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"
******************************************************************/
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
}
/*******************************************************************
******************************************************************/
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());
}
--- /dev/null
+/*******************************************************************************
+################################################################################
+# 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 <iostream>
+#include <chrono>
+#include <iomanip>
+#include <sstream>
+#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<<"/"<<YANG_NAME<<":network-function/distributed-unit-functions[id='"\
+ << ODU_HIGH <<"']/cell[id='"<<cellParams.cellLocalId <<\
+ "']/supported-measurements[performance-measurement-type='user-equipment-average-throughput-"\
+ <<str<<"']/supported-snssai-subcounter-instances[slice-differentiator='"\
+ <<sd<<"'][slice-service-type='"<<sst<<"']" ;
+ return os.str();
+
+}
+
+/*******************************************************************
+*
+* @brief prepare Stnd Slice Measurement Fields
+*
+* @details
+*
+* Function : prepareEventFields
+*
+* Functionality:
+* - prepare Stnd Slice Measurement Fields in json format
+*
+* @params[in] IN - const pointer of Message type
+* @return true - success
+* false - failure
+*
+* ****************************************************************/
+
+bool SliceMeasurementEventStdDef::prepareEventFields(const Message* msg)
+{
+
+ const SliceMetrics* sliceMetrics = dynamic_cast<const SliceMetrics*> (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<SliceMetricRecord>& sliceList = sliceMetrics->getSliceMetrics();
+ for (size_t i{0}; i < sliceList.size(); i++)
+ {
+ for(int j=0;j<MAX_THP_TYPE;j++)
+ {
+ cJSON* arr = JsonHelper::createNode();
+ cJSON_AddItemToArray(measure,arr);
+
+ string str;
+ cJSON *value;
+ if(j==0)
+ {
+ str = "downlink";
+ value = cJSON_CreateNumber(sliceList[i].DRB_UEThpDl_SNSSAI);
+ }
+ else
+ {
+ str = "uplink";
+ value = cJSON_CreateNumber(sliceList[i].DRB_UEThpUl_SNSSAI);
+ }
+
+ if(JsonHelper::addNodeToObject(arr, MEAS_REF, getMeasPath(str,\
+ sliceList[i].networkSliceIdentifier.sd,\
+ sliceList[i].networkSliceIdentifier.sst).c_str()) == 0)
+ {
+ ret = false;
+ }
+
+ cJSON_AddItemToObject(arr,"value", value);
+
+ cJSON *unit = cJSON_CreateString(THROUGHPUT_UNIT);
+ cJSON_AddItemToObject(arr,"unit", unit);
+ }
+ }
+ }
+
+ return ret;
+}
+
+/**********************************************************************
+ End of file
+**********************************************************************/
--- /dev/null
+/*******************************************************************************
+################################################################################
+# 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*/
+
+
+#ifndef __SLICE_MEASUREMENT_EVENT_STD_DEF_HPP__
+#define __SLICE_MEASUREMENT_EVENT_STD_DEF_HPP__
+
+#include <iostream>
+#include <string>
+#include "VesUtils.hpp"
+#include "JsonHelper.hpp"
+#include "PerfMeasurementEvent.hpp"
+#include <cjson/cJSON.h>
+#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
+ **********************************************************************/
str = "pmNotification";
break;
case VesEventType::PM_SLICE:
+ #ifdef StdDef
+ str = "stndDefined";
+ #else
str = "measurement";
+ #endif
break;
case VesEventType::HEARTBEAT:
str = "heartbeat";
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
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;
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
case VesEventType::PNF_REGISTRATION:
evntName = ODU_HIGH;
break;
-
+ case VesEventType::PM_SLICE:
+ evntName = ODU_HIGH;
+ break;
case VesEventType::FAULT_NOTIFICATION:
evntName = ODU_HIGH;
break;
case VesEventType::PNF_REGISTRATION:
sourceName = ODU_HIGH;
break;
+ case VesEventType::PM_SLICE:
+ sourceName = ODU_HIGH;
+ break;
case VesEventType::FAULT_NOTIFICATION:
sourceName = ODU_HIGH;
break;
string name = "";
switch(mEventType)
{
+ case VesEventType::PM_SLICE:
+ name = NFC_NAMING_CODE;
+ break;
case VesEventType::FAULT_NOTIFICATION:
name = NFC_NAMING_CODE;
break;
nammingcdoe = NAMING_CODE_ODU;
break;
case VesEventType::PM_SLICE:
+ nammingcdoe = NAMING_CODE_ODU;
break;
case VesEventType::FAULT_NOTIFICATION:
nammingcdoe = NAMING_CODE_ODU;
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;
ret = false;
}
+ #ifdef StdDef
+ #else
if (mEventType == VesEventType::PM_SLICE)
{
cJSON *internalHeaderFields = JsonHelper::createNode();
ret = false;
}
}
-
- if (mEventType == VesEventType::PNF_REGISTRATION)
- {
-
- }
+ #endif
if(JsonHelper::addNodeToObject(commonHeader, "sequence", \
getSequenceNo()) == 0)
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;
}
case VesEventType::PM_SLICE:
{
+ #ifdef StdDef
+ return "stndDefinedFields";
+ #else
return "measurementFields";
+ #endif
}
case VesEventType::HEARTBEAT:
{
#include "Message.hpp"
#include "CellStateChange.hpp"
#include "CellStateChangeStdDef.hpp"
+#include "SliceMeasurementEventStdDef.hpp"
/*******************************************************************
*
}
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:
#include <iostream>
#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"
//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"
// 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,