Merge "Update FM Manager old net-snmp related code"

This commit is contained in:
Zuul 2021-01-25 16:10:31 +00:00 committed by Gerrit Code Review
commit 4a68317f4a
4 changed files with 3 additions and 57 deletions

View File

@ -1,5 +1,5 @@
// //
// Copyright (c) 2018 Wind River Systems, Inc. // Copyright (c) 2018-2020 Wind River Systems, Inc.
// //
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
@ -15,7 +15,6 @@
#include "fmMutex.h" #include "fmMutex.h"
#include "fmConstants.h" #include "fmConstants.h"
#include "fmSnmpConstants.h" #include "fmSnmpConstants.h"
#include "fmSnmpUtils.h"
typedef std::map<std::string, std::string> configParams; typedef std::map<std::string, std::string> configParams;
@ -73,9 +72,6 @@ void fm_get_config_paramters() {
key = trim(line.substr(0, pos)); key = trim(line.substr(0, pos));
value = trim(line.erase(0, pos + delimiter.length())); value = trim(line.erase(0, pos + delimiter.length()));
getConfigMap()[key] = value; getConfigMap()[key] = value;
if (key.compare(FM_SNMP_TRAPDEST) == 0) {
set_trap_dest_list(value);
}
if (key.compare(FM_SQL_CONNECTION) != 0) { if (key.compare(FM_SQL_CONNECTION) != 0) {
// Don't log sql_connection, as it has a password // Don't log sql_connection, as it has a password
if (key.compare(FM_CONF_PASSWORD) == 0 || key.compare(FM_CONF_CONNECTION) == 0) { if (key.compare(FM_CONF_PASSWORD) == 0 || key.compare(FM_CONF_CONNECTION) == 0) {

View File

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017-2018 Wind River Systems, Inc. // Copyright (c) 2017-2020 Wind River Systems, Inc.
// //
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
@ -14,14 +14,6 @@
#define FM_CUSTOMER_LOG 10 #define FM_CUSTOMER_LOG 10
/* Trap Destination definitions */
#define FM_SNMP_TRAPDEST "trap_destinations"
#define FM_TRAPDEST_IP "ip_address"
#define FM_TRAPDEST_COMM "community"
/* MIB Trap definitions */ /* MIB Trap definitions */
const std::string WRS_ALARM_MIB = "WRS-ALARM-MIB"; const std::string WRS_ALARM_MIB = "WRS-ALARM-MIB";
@ -56,11 +48,5 @@ const std::string EVENT_SERVICE_AFFECTING = "wrsEventServiceAffecting";
const std::string SNMPv2_MIB = "SNMPv2-MIB"; const std::string SNMPv2_MIB = "SNMPv2-MIB";
const std::string WARM_START = "warmStart"; const std::string WARM_START = "warmStart";
const std::string TRAP_CMD = "/usr/bin/snmptrap -v 2c";
const std::string CLEAR_REASON_TEXT = "System initiated hierarchical alarm clear"; const std::string CLEAR_REASON_TEXT = "System initiated hierarchical alarm clear";
const std::string SEP = " ";
const std::string SCOPE = "::";
const std::string STR_TYPE = " s ";
const std::string INT_TYPE = " i ";
const std::string OPTION_COMM = " -c ";

View File

@ -38,10 +38,6 @@ static int_to_objtype objtype_map;
static pthread_mutex_t mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; static pthread_mutex_t mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
fm_db_result_t &getTrapDestList(){
static fm_db_result_t trap_dest_list;
return trap_dest_list;
}
static void add_to_table(int t, std::string objtype, int_to_objtype &tbl) { static void add_to_table(int t, std::string objtype, int_to_objtype &tbl) {
tbl[t]=objtype; tbl[t]=objtype;
@ -175,36 +171,6 @@ static std::string get_trap_objtype(int type){
return objtype_map[type]; return objtype_map[type];
} }
static void add_to_list(std::vector<std::string> &trap_strings) {
std::string delimiter = " ";
std::vector<std::string>::iterator it = trap_strings.begin();
std::vector<std::string>::iterator end = trap_strings.end();
getTrapDestList().clear();
for (; it != end; ++it){
size_t pos = 0;
fm_db_single_result_t entry;
pos = (*it).find(delimiter);
entry[FM_TRAPDEST_IP] = (*it).substr(0, pos);
entry[FM_TRAPDEST_COMM] = (*it).erase(0, pos + delimiter.length());
getTrapDestList().push_back(entry);
}
}
void set_trap_dest_list(std::string value){
std::vector<std::string> entries;
std::istringstream f(value);
std::string s;
while (getline(f, s, ',')) {
std::cout << s << std::endl;
FM_INFO_LOG("Add entry: (%s)", s.c_str());
entries.push_back(s);
}
add_to_list(entries);
FM_INFO_LOG("Set trap entries: (%d)", getTrapDestList().size());
}
/** /**

View File

@ -1,5 +1,5 @@
// //
// Copyright (c) 2014 Wind River Systems, Inc. // Copyright (c) 2014-2020 Wind River Systems, Inc.
// //
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
@ -7,13 +7,11 @@
#ifndef __FM_SNMP_UTILS_H #ifndef __FM_SNMP_UTILS_H
#define __FM_SNMP_UTILS_H #define __FM_SNMP_UTILS_H
#include <string>
#include "fmAPI.h" #include "fmAPI.h"
#include "fmDb.h" #include "fmDb.h"
bool fm_snmp_util_gen_trap(int type, SFmAlarmDataT &data); bool fm_snmp_util_gen_trap(int type, SFmAlarmDataT &data);
void set_trap_dest_list(std::string value);
#endif #endif