fault/fm-common/sources/fmDbUtils.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

94 lines
2.7 KiB
C++

//
// Copyright (c) 2014-2018 Wind River Systems, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
#ifndef FMDBUTILS_H_
#define FMDBUTILS_H_
#include "fmAPI.h"
#include "fmDbAlarm.h"
#include "fmDbEventLog.h"
#include "fmDb.h"
#include <string>
#include <memory>
#include <vector>
static inline const char *FM_DB_AND() { return "AND"; }
static inline const char *FM_DB_WHERE() { return "WHERE"; }
static inline const char *FM_DB_SELECT_FROM() { return "SELECT * FROM"; }
static inline const char *FM_DB_SELECT_COUNTS() {
return "SELECT COUNT(*) FROM";
}
static inline const char *FM_DB_ORDERBY_TIME() { return "order by timestamp desc"; }
static inline std::string FM_DB_SELECT_FROM_TABLE(const std::string &table){
return std::string(FM_DB_SELECT_FROM()) + " " +table;
}
static inline std::string FM_DB_SELECT_ROW_COUNTS_FROM_TABLE(
const std::string &table){
return std::string(FM_DB_SELECT_COUNTS()) + " " +table;
}
void FM_DB_UT_NAME_VAL( std::string &result,
const std::string &lhs, const std::string &rhs);
void FM_DB_UT_NAME_PARAM( std::string &result,
const std::string &lhs, const std::string &rhs);
std::string fm_db_util_replace_single_quote(std::string const& original);
void fm_db_util_make_timestamp_string(std::string &tstr,
FMTimeT tm=0, bool snmp=false);
bool fm_db_util_get_timestamp(const char *str, FMTimeT &ft);
bool fm_db_util_build_sql_query(const char* db_table,
const char* db_query, std::string &db_cmd);
bool fm_db_util_build_sql_insert(const char* db_table,
std::map<std::string,std::string> &map,
fm_db_util_sql_params &parms);
bool fm_db_util_event_log_build_sql_insert(std::map<std::string,std::string> &map,
fm_db_util_sql_params &params);
bool fm_db_util_build_sql_update(const char* db_table,
const std::string & id, std::map<std::string,std::string> &map,
fm_db_util_sql_params &parms, FMBoolTypeT masked=0);
bool fm_db_util_build_sql_delete(const char* db_table,
AlarmFilter *db_data, std::string &db_cmd);
bool fm_db_util_build_sql_delete_row(const char* db_table, int id,
std::string &db_cmd);
bool fm_db_util_build_sql_delete_all(const char* db_table,
const char *id, std::string &db_cmd);
bool fm_db_util_get_row_counts(CFmDBSession &sess, const char* db_table,
int &counts);
bool fm_db_util_create_session(CFmDBSession **sess,
std::string key=FM_SQL_CONNECTION);
std::string fm_db_util_get_system_name();
std::string fm_db_util_get_region_name();
void fm_db_util_set_conf_file(const char *fn);
bool fm_db_util_get_next_log_id(CFmDBSession &sess, int &id);
std::string fm_db_util_int_to_string(int val);
int fm_db_util_string_to_int(std::string val);
bool fm_db_util_sync_event_suppression(void);
#endif /* FMDBUTILS_H_ */