1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2020] [HCL Technologies Ltd.] #
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 #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
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 *******************************************************************************/
19 /* This file contains Alarm Yang model data filling and sending related methods */
21 #include "Alarm3GPPYangModel.hpp"
26 /**********************************************************************
27 Description : It is a callback function, called on get request of
28 alarm-list (overridden function of sysrepo::Callback )
29 Params[In] : (sysrepo::S_Session, module_name, path,
30 request_xpath, request_id, &parent, private_data)
31 Return : SR_ERR_OK - success
32 **********************************************************************/
34 int Alarm3GPPYangModel::oper_get_items(sysrepo::S_Session session,
35 const char *module_name,
37 const char *request_xpath,
39 libyang::S_Data_Node &parent,
42 O1_LOG("\n\n ========== CALLBACK CALLED TO PROVIDE \" %s DATA ==========\n", path);
44 libyang::S_Context ctx = session->get_context();
45 libyang::S_Module mod = ctx->get_module(module_name);
47 parent.reset(new libyang::Data_Node(ctx, ALARM_MODULE_PATH_3GPP, nullptr, LYD_ANYDATA_CONSTSTRING, 0));
48 //read the data from map
49 //tree of alarmRecord : AlarmList/AlarmListGrp/alarmRecordList/AlarmRecordGrp
51 libyang::S_Data_Node alarms(new libyang::Data_Node(parent, mod, "AlarmList"));
52 libyang::S_Data_Node alarm(new libyang::Data_Node(alarms, mod, "AlarmListGrp"));
53 libyang::S_Data_Node ifc3(new libyang::Data_Node(parent, mod, "alarmRecordList"));
54 libyang::S_Data_Node ifc4(new libyang::Data_Node(ifc3, mod, "AlarmRecordGrp"));
57 libyang::S_Data_Node id;
58 libyang::S_Data_Node text;
59 libyang::S_Data_Node severity;
60 libyang::S_Data_Node status;
61 libyang::S_Data_Node add_info;
63 //read the data from map
64 map<uint16_t,Alarm>::const_iterator it;
66 AlarmManager& alrmMgr = AlarmManager::instance();
67 const map<uint16_t,Alarm>& alrmList = alrmMgr.getAlarmList();
69 for(it = alrmList.begin(); it !=alrmList.end(); it++)
71 O1_LOG("\nAlarm ID %hu", it->second.getAlarmId());
72 alarm.reset(new libyang::Data_Node(alarms, mod, "alarm"));
73 id.reset(new libyang::Data_Node(alarm, mod, "alarm-id", to_string(it->second.getAlarmId()).c_str()));
74 text.reset(new libyang::Data_Node(alarm, mod, "alarm-text", it->second.getAdditionalText().c_str()));
75 severity.reset(new libyang::Data_Node(alarm, mod, "severity", to_string(it->second.getEventType()).c_str()));
76 status.reset(new libyang::Data_Node(alarm, mod, "status", it->second.getSpecificProblem().c_str()));
77 add_info.reset(new libyang::Data_Node(alarm, mod, "additional-info", it->second.getAdditionalInfo().c_str()));
82 /**********************************************************************
84 **********************************************************************/