VES PM data for slicing use case. [Issue-Id: ODUHIGH-384] 11/7111/8
authorVidhu <vidhu.pandey@hcl.com>
Tue, 23 Nov 2021 19:55:27 +0000 (01:25 +0530)
committerVidhu <vidhu.pandey@hcl.com>
Sun, 5 Dec 2021 08:06:21 +0000 (13:36 +0530)
Added function to send the slice performance counters to SMO

Signed-off-by: Vidhu <vidhu.pandey@hcl.com>
Change-Id: Idc758936a1c7c4c13592017cdfdc5340efc29278

40 files changed:
build/config/oamVesConfig.json [moved from build/config/vesConfig.json with 100% similarity]
build/config/smoVesConfig.json [new file with mode: 0644]
src/o1/Alarm.hpp
src/o1/AlarmManager.cpp
src/o1/AlarmManager.hpp
src/o1/ConfigFile.hpp [new file with mode: 0644]
src/o1/ConfigLoader.cpp [new file with mode: 0644]
src/o1/ConfigLoader.hpp [new file with mode: 0644]
src/o1/Message.hpp [new file with mode: 0644]
src/o1/NetconfConfigFile.cpp [new file with mode: 0644]
src/o1/NetconfConfigFile.hpp [new file with mode: 0644]
src/o1/O1Interface.cpp
src/o1/PmInterface.cpp [new file with mode: 0644]
src/o1/PmInterface.h [new file with mode: 0644]
src/o1/SliceMetrics.cpp [new file with mode: 0644]
src/o1/SliceMetrics.hpp [new file with mode: 0644]
src/o1/Thread.cpp
src/o1/Thread.hpp
src/o1/UnixSocketServer.cpp
src/o1/VesConfigFile.cpp [new file with mode: 0644]
src/o1/VesConfigFile.hpp [new file with mode: 0644]
src/o1/ves/HttpClient.cpp
src/o1/ves/HttpClient.hpp
src/o1/ves/JsonHelper.cpp
src/o1/ves/JsonHelper.hpp
src/o1/ves/PerfMeasurementEvent.cpp [new file with mode: 0644]
src/o1/ves/PerfMeasurementEvent.hpp [new file with mode: 0644]
src/o1/ves/PnfRegistrationEvent.cpp [moved from src/o1/ves/PnfRegistration.cpp with 81% similarity]
src/o1/ves/PnfRegistrationEvent.hpp [moved from src/o1/ves/PnfRegistration.hpp with 89% similarity]
src/o1/ves/PnfRegistrationThread.cpp
src/o1/ves/PnfRegistrationThread.hpp
src/o1/ves/SliceMeasurementEvent.cpp [new file with mode: 0644]
src/o1/ves/SliceMeasurementEvent.hpp [new file with mode: 0644]
src/o1/ves/VesCommonHeader.cpp
src/o1/ves/VesCommonHeader.hpp
src/o1/ves/VesEvent.cpp
src/o1/ves/VesEvent.hpp
src/o1/ves/VesEventHandler.cpp
src/o1/ves/VesEventHandler.hpp
src/o1/ves/VesUtils.hpp

diff --git a/build/config/smoVesConfig.json b/build/config/smoVesConfig.json
new file mode 100644 (file)
index 0000000..f1299b5
--- /dev/null
@@ -0,0 +1,8 @@
+{
+    "vesConfig": {
+        "vesV4IpAddress" : "10.0.2.135",
+        "vesPort" : "9999",
+        "username" : "user",
+        "password" : "password"
+    }
+}
index c4d8413..2249445 100644 (file)
 #include <string>
 #include <string.h>
 #include "AlarmMessages.h"
+#include "Message.hpp"
 
 using std::string; 
 
 
-class Alarm
+class Alarm : public Message
 {
-
    private:
    EventType mEventType;
    string mObjectClassObjectInstance;
@@ -46,8 +46,8 @@ class Alarm
    string mSpecificProblem;
 
    public:
-   Alarm(){};
-   ~Alarm(){};
+   Alarm() {}
+   ~Alarm(){}
    /* Getter functions */
    inline const EventType& getEventType()const 
    { 
index 3ed8aca..b396188 100644 (file)
@@ -47,9 +47,12 @@ AlarmManager::~AlarmManager()
 **********************************************************************/
 bool AlarmManager::raiseAlarm(const Alarm& alarm)
 {
+
    pair<map<uint16_t,Alarm>::iterator,bool> ret;
    ret = mAlarmList.insert(pair<uint16_t,Alarm>(alarm.getAlarmId(),alarm));
    return ret.second;
+
+   
 }
 
 
index a30fa9a..0562f63 100644 (file)
 #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 (file)
index 0000000..cee4cc6
--- /dev/null
@@ -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 <string>
+
+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 (file)
index 0000000..041a05a
--- /dev/null
@@ -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 (file)
index 0000000..a4a7290
--- /dev/null
@@ -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 <string>
+#include "VesConfigFile.hpp"
+#include "NetconfConfigFile.hpp"
+#include "VesUtils.hpp"
+#include "Singleton.hpp"
+
+using std::string;
+
+class ConfigLoader : public Singleton<ConfigLoader> {
+private: 
+    ConfigLoader();
+    ~ConfigLoader();
+
+    VesConfigFile mOamConfig;
+    VesConfigFile mSmoConfig;
+    NetconfConfigFile mNetconfConfig;
+
+public:
+    friend Singleton<ConfigLoader>;
+
+    const VesConfigFile& getOamConfigFile()const;
+    const VesConfigFile& getSmoConfigFile()const;
+    const NetconfConfigFile& getNetconfConfigFile()const;
+
+    bool loadConfigurations();
+};
+
+#endif
+
+/**********************************************************************
+  End of file
+ **********************************************************************/
diff --git a/src/o1/Message.hpp b/src/o1/Message.hpp
new file mode 100644 (file)
index 0000000..dc0b883
--- /dev/null
@@ -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 (file)
index 0000000..79e1cde
--- /dev/null
@@ -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 (file)
index 0000000..58cef42
--- /dev/null
@@ -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 <string>
+
+
+using std::string;
+
+class NetconfConfigFile : public ConfigFile {
+public:  
+    //constructor & Destructor
+    NetconfConfigFile(string filepath);
+    ~NetconfConfigFile();
+
+    //member functions
+    bool loadConfigFile() override;
+
+
+    //Getters
+    string getNetconfMacAddr() const;
+    string getNetconfIpv4() const;
+    string getNetconfIpv6() const;
+    string getNetconfPort() const;
+    string getNetconfUsername() const;
+    string getNetconfPassword() const;
+    
+private: 
+    //member variables
+    string mNetconfMacAddr;
+    string mNetconfIpv4;
+    string mNetconfIpv6;
+    string mNetconfPort;
+    string mNetconfUsername;
+    string mNetconfPassword;
+};
+#endif
+
+/**********************************************************************
+  End of file
+ **********************************************************************/
index c0c552a..b1fdeff 100644 (file)
@@ -22,6 +22,7 @@
 #include "O1App.hpp"
 #include "GlobalDefs.hpp"
 #include "PnfRegistrationThread.hpp"
+#include "ConfigLoader.hpp"
 
 #include <signal.h>
 #include <unistd.h>
@@ -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 (file)
index 0000000..b36bce2
--- /dev/null
@@ -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 <unistd.h>
+#include "GlobalDefs.hpp"
+
+
+/*******************************************************************
+ *
+ * @brief Send the Slice metrics to SMO as a VES message
+ *
+ * @details
+ *
+ *    Function : sendSliceMetric
+ *
+ *    Functionality:
+ *      - Takes the Slice metrics list and sends it to SMO
+ *
+ *
+ * @params[in] pointer to SliceMetricList
+ * @return O1::SUCCESS - success
+ *         O1::FAILURE - failure
+ ******************************************************************/
+int sendSliceMetric(SliceMetricList* sliceMetricList) {
+
+   O1_LOG("\n PmInterfce : Call received from the the du_app code !!");
+
+   SliceMetrics metrics;
+   for(int i = 0; i < sliceMetricList->nRecords; i++)
+      metrics.addMetric(sliceMetricList->sliceRecord[i]); 
+
+   VesEventHandler vesEventHandler;
+   if (!vesEventHandler.prepare(VesEventType::PM_SLICE, &metrics))
+      return O1::FAILURE;
+   
+   O1_LOG("\n PmInterface : Sending slice PM Data");
+   if ( !vesEventHandler.send() )
+      return O1::FAILURE;
+
+   return O1::SUCCESS;
+}
+
+/**********************************************************************
+         End of file
+**********************************************************************/
diff --git a/src/o1/PmInterface.h b/src/o1/PmInterface.h
new file mode 100644 (file)
index 0000000..5208779
--- /dev/null
@@ -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 <stdint.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+typedef struct {
+   uint32_t networkSliceIdentifier;
+   double DRB_UEThpDl_SNSSAI;
+   double DRB_UEThpUl_SNSSAI;
+}SliceMetricRecord;
+
+typedef struct {
+   SliceMetricRecord *sliceRecord;
+   uint8_t nRecords;
+}SliceMetricList;
+
+
+int sendSliceMetric(SliceMetricList* sliceMetricList);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/**********************************************************************
+         End of file
+**********************************************************************/
diff --git a/src/o1/SliceMetrics.cpp b/src/o1/SliceMetrics.cpp
new file mode 100644 (file)
index 0000000..df843ef
--- /dev/null
@@ -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<SliceMetricRecord>
+ ******************************************************************/
+const vector<SliceMetricRecord>& SliceMetrics::getSliceMetrics() const {
+   return mSliceList;
+}
+
+/**********************************************************************
+         End of file
+**********************************************************************/
diff --git a/src/o1/SliceMetrics.hpp b/src/o1/SliceMetrics.hpp
new file mode 100644 (file)
index 0000000..b72d716
--- /dev/null
@@ -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 <string>
+#include <vector>
+#include "Message.hpp"
+#include "PmInterface.h"
+
+using namespace std;
+
+class SliceMetrics : public Message {
+   
+public:
+    SliceMetrics();
+    ~SliceMetrics();
+
+    const vector<SliceMetricRecord>& getSliceMetrics() const;
+    void addMetric(SliceMetricRecord& sliceMetricRecord);
+
+private: 
+    vector<SliceMetricRecord> mSliceList;
+
+};
+
+#endif
+
+/**********************************************************************
+End of file
+**********************************************************************/
index 266c21b..70b71d5 100644 (file)
@@ -220,3 +220,7 @@ bool Thread::printAffinity()
            O1_LOG("CPU %d ", i);
    return true;
 }
+
+/**********************************************************************
+End of file
+**********************************************************************/
\ No newline at end of file
index 9f9ee51..68c5ef8 100644 (file)
@@ -43,6 +43,8 @@ class Thread
    bool join();
 };
 
-
-
 #endif
+
+/**********************************************************************
+End of file
+**********************************************************************/
\ No newline at end of file
index 528e039..412d288 100644 (file)
@@ -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 (file)
index 0000000..d2f6c69
--- /dev/null
@@ -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 (file)
index 0000000..0a13941
--- /dev/null
@@ -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 <string>
+#include "ConfigFile.hpp"
+
+
+using std::string;
+
+class VesConfigFile : public ConfigFile {
+public:
+    //Constructor and Destructor
+    VesConfigFile(string filepath);
+    ~VesConfigFile();
+
+    //Getters
+    string getVesServerIp()const;
+    string getVesServerPort()const;
+    string getVesServerUsername()const;
+    string getVesServerPassword()const;
+
+    //member functions
+    bool loadConfigFile()override;
+    
+private: 
+    //member variables
+    string mVesServerIp;
+    string mVesServerPort;
+    string mVesServerUsername;
+    string mVesServerPassword;
+};
+#endif
+
+/**********************************************************************
+  End of file
+ **********************************************************************/
index 261f5ae..7aed15f 100644 (file)
@@ -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://"<<mServerIp<<":"<<mServerPort<<"/eventListener/v7";
-      string url = oss.str();
-      O1_LOG("\nO1 HttpClient : URL=%s", url.c_str());
-      curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
-      return true;
-   }
-   else
-   {
-      return false;
-   }
-}
 
 /*******************************************************************
  *
index fba7242..9e3b8da 100644 (file)
@@ -47,7 +47,7 @@ class HttpClient
       HttpClient(){}
       ~HttpClient(){}
 
-      HttpClient(string ip, string port, string username, string password);
+      HttpClient(string url, string username=0, string password=0);
       bool send(const char *send_data);
 
    private:
@@ -57,13 +57,11 @@ class HttpClient
       bool sendHttpRequest(struct curl_slist *header, CURL *curl);
       bool setCurlOptions(CURL *curl);
       bool setUserPassword(CURL *curl);
-      bool createUrl(CURL *curl);
 
       //member variable
-      string mServerIp;
-      string mServerPort;
       string mServerUsername;
       string mServerPassword;
+      string mUrl;
 };
 
 #endif
index db86275..340f869 100644 (file)
@@ -295,6 +295,18 @@ cJSON* JsonHelper::read(const char * fileName)
    return json;
 }
 
+cJSON* JsonHelper::createArray() 
+{
+   return cJSON_CreateArray();
+}
+
+cJSON_bool JsonHelper::addJsonNodeToArray(cJSON * array, cJSON* node)
+{
+   return cJSON_AddItemToArray(array, node);
+}
+
+
+
 /**********************************************************************
   End of file
  **********************************************************************/
index 6509dda..7d5f0d5 100644 (file)
@@ -49,6 +49,9 @@ class JsonHelper
       static char *printUnformatted(cJSON * node);
       static char *print(cJSON * node);
       static const char *getError();
+      static cJSON* createArray();
+      static cJSON_bool addJsonNodeToArray(cJSON * array, cJSON* node);
+
 
 };
 
diff --git a/src/o1/ves/PerfMeasurementEvent.cpp b/src/o1/ves/PerfMeasurementEvent.cpp
new file mode 100644 (file)
index 0000000..c8bff7e
--- /dev/null
@@ -0,0 +1,82 @@
+/*******************************************************************************
+################################################################################
+#   Copyright (c) [2020-2021] [HCL Technologies Ltd.]                          #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+*******************************************************************************/
+
+/* This file contains base class for Performance Measurement VES Event*/
+
+
+#include "PerfMeasurementEvent.hpp"
+
+/* Constructor */
+PerfMeasurementEvent::PerfMeasurementEvent(VesEventType eventType)
+                :VesEvent(eventType)
+{
+
+}
+/* Default Destructor*/
+PerfMeasurementEvent::~PerfMeasurementEvent()
+{
+    
+}
+
+/* overriding */
+/*******************************************************************
+ *
+ * @brief Get SMO Ves Collector configuration 
+ *
+ * @details
+ *
+ *    Function : getConfig
+ *
+ *    Functionality:
+ *      - Gets Ves Collector configuration
+ *
+ *
+ * @params[in] void
+ * @return void
+ ******************************************************************/
+void PerfMeasurementEvent::getConfig()
+{
+    mVesServerIp = ConfigLoader::instance().getSmoConfigFile().getVesServerIp();
+    mVesServerPort = ConfigLoader::instance().getSmoConfigFile().getVesServerPort();
+    mVesServerUsername = ConfigLoader::instance().getSmoConfigFile().getVesServerUsername();
+    mVesServerPassword = ConfigLoader::instance().getSmoConfigFile().getVesServerPassword();
+}
+
+/*******************************************************************
+ *
+ * @brief Create the URL for sending VES messages
+ *
+ * @details
+ *
+ *    Function : createUrl (overridden)
+ *
+ *    Functionality:
+ *      - Creates the VES URL
+ *
+ *
+ * @params[in] void
+ * @return void
+ ******************************************************************/
+void PerfMeasurementEvent::createUrl()
+{
+   mVesUrl = "http://" + mVesServerIp + ":" + mVesServerPort + "/eventListener/v7/events";
+}
+
+/**********************************************************************
+         End of file
+**********************************************************************/
diff --git a/src/o1/ves/PerfMeasurementEvent.hpp b/src/o1/ves/PerfMeasurementEvent.hpp
new file mode 100644 (file)
index 0000000..9d86ae3
--- /dev/null
@@ -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 base class for Performance Measurement VES Event*/
+
+#ifndef __PERF_MEASUREMENT_EVENT_HPP__
+#define __PERF_MEASUREMENT_EVENT_HPP__
+
+#include "VesEvent.hpp"
+
+class PerfMeasurementEvent : public VesEvent
+{
+
+public:
+
+    PerfMeasurementEvent(VesEventType eventType);
+    virtual ~PerfMeasurementEvent();
+
+protected:
+
+    virtual void getConfig();
+    virtual void createUrl();
+
+};
+#endif
+
+/**********************************************************************
+         End of file
+**********************************************************************/
similarity index 81%
rename from src/o1/ves/PnfRegistration.cpp
rename to src/o1/ves/PnfRegistrationEvent.cpp
index 27f692a..48cd488 100644 (file)
 #include <string.h>
 #include <stdlib.h>
 #include <sstream>
-#include "PnfRegistration.hpp"
+#include "PnfRegistrationEvent.hpp"
 #include "JsonHelper.hpp"
 #include "VesUtils.hpp"
 
 /* Default constructor*/
-PnfRegistration::PnfRegistration()
+PnfRegistrationEvent::PnfRegistrationEvent()
+               : VesEvent(VesEventType::PNF_REGISTRATION)
 {
-   this->mVesEventType = VesEventType::PNF_REGISTRATION;
 }
 
 /* Default Destructor*/
-PnfRegistration::~PnfRegistration()
+PnfRegistrationEvent::~PnfRegistrationEvent()
 {
 }
 
@@ -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
  **********************************************************************/
similarity index 89%
rename from src/o1/ves/PnfRegistration.hpp
rename to src/o1/ves/PnfRegistrationEvent.hpp
index 72f0d22..041b1e2 100644 (file)
@@ -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 <iostream>
 #include <string>
 #include <stdio.h>
 #include "VesUtils.hpp"
 #include "VesEvent.hpp"
+#include "Message.hpp"
 
 #define MAX_TIME_STR 11
 
 using namespace std;
 
-class PnfRegistration : public VesEvent
+class PnfRegistrationEvent : public VesEvent
 {
 
    public:
       /* Default constructor/Destructor */
-      PnfRegistration();
-      ~PnfRegistration();
+      PnfRegistrationEvent();
+      ~PnfRegistrationEvent();
 
    protected:
-      bool prepareEventFields();
+      bool prepareEventFields(const Message* msg = NULL);
 
    private:
       bool prepareAdditionalFields(cJSON *addFields);
@@ -57,7 +58,7 @@ class PnfRegistration : public VesEvent
       string getPassword();
       string getSerialNumber();
       string getUnitFamily();
-      bool readConfigFile();
+      void getNetconfConfig();
 
       //member variables
       string mNetconfMacAddr;
index 6158327..b50140a 100644 (file)
@@ -45,4 +45,10 @@ bool PnfRegistrationThread::run()
          vesEvtHdr.send();
       }
    }
+   return true;
+
 }
+
+/**********************************************************************
+  End of file
+ **********************************************************************/
\ No newline at end of file
index 607bd5f..bfdc6ab 100644 (file)
@@ -42,3 +42,7 @@ class PnfRegistrationThread : public Singleton<PnfRegistrationThread>, 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 (file)
index 0000000..ab219bb
--- /dev/null
@@ -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<const SliceMetrics*> (msg);
+    
+    bool ret = true;
+    cJSON *measurementFields = this->mVesEventFields;
+
+    if(JsonHelper::addNodeToObject(measurementFields, \
+                                    "measurementFieldsVersion", \
+                                    MEASUREMENT_FIELDS_VERSION) == 0)
+    {
+        ret = false;
+    }
+
+    cJSON *networkSliceArray = JsonHelper::createArray();
+
+    if(networkSliceArray == 0)
+    {
+        ret = false;
+    }
+
+    else if (JsonHelper::addJsonNodeToObject(measurementFields, \
+                                            "networkSliceArray", \
+                                            networkSliceArray) == 0)
+    {
+        ret = false;
+    }
+    else if(ret)
+    {
+        const vector<SliceMetricRecord>& sliceList = sliceMetrics->getSliceMetrics();
+        for (size_t i{0}; i < sliceList.size(); i++)            
+        {
+            cJSON *Slice = JsonHelper::createNode();
+            if(Slice == 0)
+            {
+                ret = false;
+            }
+            else if (JsonHelper::addJsonNodeToArray(networkSliceArray, Slice) == 0)
+            {
+                ret = false;
+            }
+
+            else if (JsonHelper::addNodeToObject(Slice, \
+                                                "DRB.UEThpDl.SNSSAI", \
+                                                 sliceList[i].DRB_UEThpDl_SNSSAI) == 0)
+            {
+                ret = false;
+            }
+
+            else if (JsonHelper::addNodeToObject(Slice, \
+                                                "DRB.UEThpUl.SNSSAI", \
+                                                sliceList[i].DRB_UEThpUl_SNSSAI) == 0)
+            {
+                ret = false;
+            }
+            else if (JsonHelper::addNodeToObject(Slice, \
+                                                "networkSliceIdentifier", \
+                                                sliceList[i].networkSliceIdentifier) == 0)
+            {
+                ret = false;
+            }
+        }
+    }
+
+    if(JsonHelper::addNodeToObject(measurementFields, \
+                                   "measurementInterval", \
+                                    MEASUREMENT_INTERVAL) == 0)
+    {
+        ret = false;
+    }
+
+    return ret;
+}
+
+/**********************************************************************
+         End of file
+**********************************************************************/
diff --git a/src/o1/ves/SliceMeasurementEvent.hpp b/src/o1/ves/SliceMeasurementEvent.hpp
new file mode 100644 (file)
index 0000000..7233e8f
--- /dev/null
@@ -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 <iostream>
+#include <string>
+#include "VesUtils.hpp"
+#include "PerfMeasurementEvent.hpp"
+#include <cjson/cJSON.h>
+#include "SliceMetrics.hpp"
+
+using namespace std;
+
+
+class SliceMeasurementEvent : public PerfMeasurementEvent
+{
+public:
+    SliceMeasurementEvent();
+    ~SliceMeasurementEvent();
+
+private:
+    bool prepareEventFields(const Message* msg = NULL);
+};
+#endif
+
+/**********************************************************************
+         End of file
+**********************************************************************/
index 864ea84..ce7214d 100644 (file)
@@ -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;
-
 }
 
 /**********************************************************************
index 21e0d6e..96f850b 100644 (file)
@@ -32,7 +32,6 @@
 #include <stdio.h>
 #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;
 };
index 23a4d88..a12d1c7 100644 (file)
    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
+ **********************************************************************/
+
index c1254da..2f15131 100644 (file)
@@ -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
index 48e0ff6..60f8513 100644 (file)
@@ -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;
    }
index c304190..9925f02 100644 (file)
@@ -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:
index a86d72b..c9da3ff 100644 (file)
 
 //config file path
 #define NETCONF_CONFIG "config/netconfConfig.json"
-#define VES_CONFIG "config/vesConfig.json"
+#define OAM_VES_CONFIG "config/oamVesConfig.json"
+#define SMO_VES_CONFIG "config/smoVesConfig.json"
 
 //Common Header Macros
 
 //Event Type
 #define EVENT_TYPE_5G "EventType5G"
-#define EVENT_TYPE_ORAN_COMPONENET "O_RAN_COMPONENT"
+#define EVENT_TYPE_ORAN_COMPONENT "O_RAN_COMPONENT"
 #define EVENT_TYPE_CONTROLLER "Controller"
 
 //Priority
 
 //version
 #define VERSION_4_0_1 "4.0.1"
+#define VERSION_4_1 "4.1"
 
 //Ves Event Listener Version
 #define VES_EVENT_LISTENER_7_2_1 "7.2.1"
 
-
-
 //PNF Registration Macros
 #define PNF_REGISTRATION_VERSION_2_1 "2.1"
 #define SOFTWARE_VERSION_2_3_5 "2.3.5"
 #define BETWEEN_ATTEMPTS_TIMEOUT_2000 "2000"
 #define KEEPALIVE_DELAY_120 "120"
 
+// PM_SLICE Macros
+#define PM_EVENT_ID "_1634181300_PM1min"
+#define PM_REPORTING_ENTITY "ORAN-DEV"
+#define EVENT_TYPE_ORAN_COMPONENT_PM "O_RAN_COMPONENT_PM1min"
+
 enum class VesEventType
 { 
    PNF_REGISTRATION,
    FAULT_NOTIFICATION,
    PM_NOTIFICATION,
-   HEARTBEAT
+   HEARTBEAT,
+   PM_SLICE
+};
+
+enum class MessageType
+{
+   ALARM,
+   PERF_DATA,
 };
 
 
 #endif
+
 /**********************************************************************
   End of file
  **********************************************************************/