VES PM data for slicing use case. [Issue-Id: ODUHIGH-384]
[o-du/l2.git] / src / o1 / PmInterface.cpp
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2020-2021] [HCL Technologies Ltd.]                          #
4 #                                                                              #
5 #   Licensed under the Apache License, Version 2.0 (the "License");            #
6 #   you may not use this file except in compliance with the License.           #
7 #   You may obtain a copy of the License at                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
11 #   Unless required by applicable law or agreed to in writing, software        #
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17 *******************************************************************************/
18
19 /* This file contains the C interface for ODU to access the Performance 
20    Management functions */
21
22 #include "PmInterface.h"
23 #include "VesEventHandler.hpp"
24 #include "SliceMetrics.hpp"
25 #include <unistd.h>
26 #include "GlobalDefs.hpp"
27
28
29 /*******************************************************************
30  *
31  * @brief Send the Slice metrics to SMO as a VES message
32  *
33  * @details
34  *
35  *    Function : sendSliceMetric
36  *
37  *    Functionality:
38  *      - Takes the Slice metrics list and sends it to SMO
39  *
40  *
41  * @params[in] pointer to SliceMetricList
42  * @return O1::SUCCESS - success
43  *         O1::FAILURE - failure
44  ******************************************************************/
45 int sendSliceMetric(SliceMetricList* sliceMetricList) {
46
47    O1_LOG("\n PmInterfce : Call received from the the du_app code !!");
48
49    SliceMetrics metrics;
50  
51    for(int i = 0; i < sliceMetricList->nRecords; i++)
52       metrics.addMetric(sliceMetricList->sliceRecord[i]); 
53
54    VesEventHandler vesEventHandler;
55    if (!vesEventHandler.prepare(VesEventType::PM_SLICE, &metrics))
56       return O1::FAILURE;
57    
58    O1_LOG("\n PmInterface : Sending slice PM Data");
59    if ( !vesEventHandler.send() )
60       return O1::FAILURE;
61
62    return O1::SUCCESS;
63 }
64
65 /**********************************************************************
66          End of file
67 **********************************************************************/