
New API methods have been added to allow getting, setting, and clearing faults by providing both alarm_id and entity_instance_id. Changes in this commit: - For clear_fault operation, the query has been updated to allow the removal of multiple rows with a single query. The entity_instance_id parameter can now be a prefix, enabling the matching of multiple alarms with the same alarm_id. This change does not affect existing use cases. - New method get_faults_by_id_n_eid, This method allows API clients to retrieve a list of alarms that match an alarm_id and a prefix of entity_instance_id, thereby matching multiple alarms. - New method set_faults. This method accepts a list of alarms as a parameter and calls the same core set_fault function for each alarm. [PASS] Build and install packages [PASS] Remove several alarms that matches 'alarm_id', 'entity_instance_id=%' [PASS] Get list of alarms that match 'alarm_id' and 'entity_instance_id=%' [PASS] Verify that the new behavior for removing alarms does not affect previous use cases. [PASS] Test set_faults API function providing a list of alarms. Verify the alarms in the list are being created. [PASS] Enable debug mode to verify that queries are as expected. Story: 2011106 task: 50756 Change-Id: Ib9dcfa97960a5d50865133a61810681e5a09edbe Signed-off-by: fperez <fabrizio.perez@windriver.com>
82 lines
2.1 KiB
C++
82 lines
2.1 KiB
C++
//
|
|
// Copyright (c) 2014-2018 Wind River Systems, Inc.
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
#ifndef FMDBALARM_H_
|
|
#define FMDBALARM_H_
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <stddef.h>
|
|
#include <map>
|
|
|
|
#include "fmAPI.h"
|
|
#include "fmConstants.h"
|
|
#include "fmDb.h"
|
|
|
|
class CFmDbAlarm {
|
|
public:
|
|
typedef std::map<std::string,std::string> data_type;
|
|
|
|
bool import_data(CFmDbAlarm::data_type &m);
|
|
bool create_data(SFmAlarmDataT *alarm);
|
|
bool export_data(SFmAlarmDataT *alarm);
|
|
bool export_data(CFmDbAlarm::data_type &m);
|
|
|
|
|
|
std::string find_field(const char *field);
|
|
|
|
void set_field(const std::string &lhs, const std::string &rhs) {
|
|
m_alarm_data[lhs] = rhs;
|
|
}
|
|
|
|
std::string to_formatted_db_string(const char ** list=NULL, size_t len=0);
|
|
void print();
|
|
|
|
static inline bool convert_to(CFmDbAlarm::data_type &m, SFmAlarmDataT *alarm ) {
|
|
CFmDbAlarm a;
|
|
if (!a.import_data(m)) return false;
|
|
return a.export_data(alarm);
|
|
}
|
|
protected:
|
|
|
|
data_type m_alarm_data;
|
|
};
|
|
|
|
|
|
class CFmDbAlarmOperation {
|
|
|
|
public:
|
|
bool create_alarm(CFmDBSession &sess, CFmDbAlarm &a);
|
|
|
|
int delete_alarms(CFmDBSession &sess, const char *id);
|
|
int delete_alarm(CFmDBSession &sess, AlarmFilter &af);
|
|
|
|
bool delete_row(CFmDBSession &sess, const char* db_table);
|
|
|
|
bool get_alarm(CFmDBSession &sess, AlarmFilter &af, fm_db_result_t & alarms);
|
|
bool get_alarms(CFmDBSession &sess, const char *id, fm_db_result_t & alarms) ;
|
|
bool get_history(CFmDBSession &sess, fm_db_result_t & alarms) ;
|
|
|
|
bool get_all_alarms(CFmDBSession &sess, SFmAlarmDataT **alarms, size_t *len );
|
|
|
|
bool get_all_history_alarms(CFmDBSession &sess, SFmAlarmDataT **alarms, size_t *len );
|
|
|
|
bool get_alarms_by_id(CFmDBSession &sess, const char *id, fm_db_result_t & alarms);
|
|
|
|
bool get_alarms_by_id_n_eid(CFmDBSession &sess, const AlarmFilter &af, fm_db_result_t &alarms);
|
|
|
|
bool get_alarms_eid_not_strict(CFmDBSession &sess, AlarmFilter &af, fm_db_result_t & alarms);
|
|
|
|
bool mask_unmask_alarms(CFmDBSession &sess, SFmAlarmDataT &a, bool mask = true);
|
|
|
|
bool add_alarm_history(CFmDBSession &sess, SFmAlarmDataT &a, bool set);
|
|
|
|
private:
|
|
static std::string build_base_alarm_query(const char *entity_instance_id);
|
|
};
|
|
|
|
#endif /* FMDBALARM_H_ */
|