fault/fm-common/sources/fmDbEventLog.h
Tao Liu c8159ea6cb Decouple Fault Management from stx-config
Create fault management REST API service
Create fault management client and CLI shell
Add a python extension for fault management application APIs
Update fault management python APIs to use the python extension
Update fault manager to retrieve the SNMP configuration from the config file

Story: 2002828
Task: 22747

Depends-On: https://review.openstack.org/#/c/592176/
Change-Id: I888d8d23edf75d05d51594ccca55570ae366c848
Signed-off-by: Tao Liu <tao.liu@windriver.com>
2018-08-16 13:23:33 -04:00

70 lines
1.7 KiB
C++

//
// Copyright (c) 2016-2018 Wind River Systems, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
#ifndef FMDBEVENTLOG_H_
#define FMDBEVENTLOG_H_
#include <string>
#include <vector>
#include <stddef.h>
#include <map>
#include "fmAPI.h"
#include "fmConstants.h"
#include "fmDb.h"
typedef std::map<int,std::string> itos_t;
typedef std::map<std::string,int> stoi_t;
class CFmDbEventLog {
public:
typedef std::map<std::string,std::string> data_type;
bool create_data(SFmAlarmDataT *alarm);
bool import_data(CFmDbEventLog::data_type &m);
bool export_data(SFmAlarmDataT *alarm);
bool export_data(CFmDbEventLog::data_type &m);
void append(std::string &str, const std::string &what);
void add_both_tables(const char *str, int id, itos_t &t1,stoi_t &t2 );
void init_tables();
std::string find_field(const char *field);
void set_field(const std::string &lhs, const std::string &rhs) {
m_event_log_data[lhs] = rhs;
}
std::string to_formatted_db_string(const char ** list=NULL, size_t len=0);
void print();
static inline bool convert_to(CFmDbEventLog::data_type &m, SFmAlarmDataT *alarm ) {
CFmDbEventLog a;
if (!a.import_data(m)) return false;
return a.export_data(alarm);
}
protected:
data_type m_event_log_data;
};
class CFmDbEventLogOperation {
public:
bool create_event_log(CFmDBSession &sess, CFmDbEventLog &a);
bool get_event_log(CFmDBSession &sess, AlarmFilter &af, fm_db_result_t & alarms);
bool get_event_logs(CFmDBSession &sess, fm_db_result_t & alarms) ;
bool get_all_event_logs(CFmDBSession &sess, SFmAlarmDataT **alarms, size_t *len );
bool get_event_logs_by_id(CFmDBSession &sess, const char *id, fm_db_result_t & alarms);
};
#endif /* FMDBEVENTLOG_H_ */