mirror of
https://github.com/Telecominfraproject/OpenNetworkLinux.git
synced 2025-12-25 17:27:01 +00:00
[from @kenchiang]
Rework snmp oid registration so that the temperature, fan, and PSU oids are registered as netsnmp tables. When a sensor is added or deleted, the corresponding table is updated accordingly.
This commit is contained in:
@@ -38,9 +38,6 @@ cdefs: &cdefs
|
||||
- ONLP_SNMP_CONFIG_DEV_BASE_INDEX:
|
||||
doc: "Base index."
|
||||
default: 1
|
||||
- ONLP_SNMP_CONFIG_DEV_MAX_INDEX:
|
||||
doc: "Maximum index."
|
||||
default: 100
|
||||
- ONLP_SNMP_CONFIG_INCLUDE_THERMALS:
|
||||
doc: "Include Thermals."
|
||||
default: 1
|
||||
|
||||
@@ -131,16 +131,6 @@
|
||||
#define ONLP_SNMP_CONFIG_DEV_BASE_INDEX 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* ONLP_SNMP_CONFIG_DEV_MAX_INDEX
|
||||
*
|
||||
* Maximum index. */
|
||||
|
||||
|
||||
#ifndef ONLP_SNMP_CONFIG_DEV_MAX_INDEX
|
||||
#define ONLP_SNMP_CONFIG_DEV_MAX_INDEX 100
|
||||
#endif
|
||||
|
||||
/**
|
||||
* ONLP_SNMP_CONFIG_INCLUDE_THERMALS
|
||||
*
|
||||
|
||||
@@ -79,14 +79,6 @@ typedef enum onlp_snmp_fan_flow_type_e {
|
||||
ONLP_SNMP_FAN_FLOW_TYPE_F2B = 2,
|
||||
} onlp_snmp_fan_flow_type_t;
|
||||
|
||||
/** onlp_snmp_sensor_status */
|
||||
typedef enum onlp_snmp_sensor_status_e {
|
||||
ONLP_SNMP_SENSOR_STATUS_MISSING = 0,
|
||||
ONLP_SNMP_SENSOR_STATUS_GOOD = 1,
|
||||
ONLP_SNMP_SENSOR_STATUS_FAILED = 2,
|
||||
ONLP_SNMP_SENSOR_STATUS_UNPLUGGED = 3,
|
||||
} onlp_snmp_sensor_status_t;
|
||||
|
||||
/** onlp_snmp_psu_type */
|
||||
typedef enum onlp_snmp_psu_type_e {
|
||||
ONLP_SNMP_PSU_TYPE_UNKNOWN = 0,
|
||||
@@ -95,6 +87,14 @@ typedef enum onlp_snmp_psu_type_e {
|
||||
ONLP_SNMP_PSU_TYPE_DC48 = 3,
|
||||
} onlp_snmp_psu_type_t;
|
||||
|
||||
/** onlp_snmp_sensor_status */
|
||||
typedef enum onlp_snmp_sensor_status_e {
|
||||
ONLP_SNMP_SENSOR_STATUS_MISSING = 0,
|
||||
ONLP_SNMP_SENSOR_STATUS_GOOD = 1,
|
||||
ONLP_SNMP_SENSOR_STATUS_FAILED = 2,
|
||||
ONLP_SNMP_SENSOR_STATUS_UNPLUGGED = 3,
|
||||
} onlp_snmp_sensor_status_t;
|
||||
|
||||
/** onlp_snmp_sensor_type */
|
||||
typedef enum onlp_snmp_sensor_type_e {
|
||||
ONLP_SNMP_SENSOR_TYPE_TEMP = 1,
|
||||
@@ -136,27 +136,6 @@ extern aim_map_si_t onlp_snmp_fan_flow_type_map[];
|
||||
/** onlp_snmp_fan_flow_type_desc_map table. */
|
||||
extern aim_map_si_t onlp_snmp_fan_flow_type_desc_map[];
|
||||
|
||||
/** Enum names. */
|
||||
const char* onlp_snmp_sensor_status_name(onlp_snmp_sensor_status_t e);
|
||||
|
||||
/** Enum values. */
|
||||
int onlp_snmp_sensor_status_value(const char* str, onlp_snmp_sensor_status_t* e, int substr);
|
||||
|
||||
/** Enum descriptions. */
|
||||
const char* onlp_snmp_sensor_status_desc(onlp_snmp_sensor_status_t e);
|
||||
|
||||
/** Enum validator. */
|
||||
int onlp_snmp_sensor_status_valid(onlp_snmp_sensor_status_t e);
|
||||
|
||||
/** validator */
|
||||
#define ONLP_SNMP_SENSOR_STATUS_VALID(_e) \
|
||||
(onlp_snmp_sensor_status_valid((_e)))
|
||||
|
||||
/** onlp_snmp_sensor_status_map table. */
|
||||
extern aim_map_si_t onlp_snmp_sensor_status_map[];
|
||||
/** onlp_snmp_sensor_status_desc_map table. */
|
||||
extern aim_map_si_t onlp_snmp_sensor_status_desc_map[];
|
||||
|
||||
/** Enum names. */
|
||||
const char* onlp_snmp_psu_type_name(onlp_snmp_psu_type_t e);
|
||||
|
||||
@@ -178,6 +157,27 @@ extern aim_map_si_t onlp_snmp_psu_type_map[];
|
||||
/** onlp_snmp_psu_type_desc_map table. */
|
||||
extern aim_map_si_t onlp_snmp_psu_type_desc_map[];
|
||||
|
||||
/** Enum names. */
|
||||
const char* onlp_snmp_sensor_status_name(onlp_snmp_sensor_status_t e);
|
||||
|
||||
/** Enum values. */
|
||||
int onlp_snmp_sensor_status_value(const char* str, onlp_snmp_sensor_status_t* e, int substr);
|
||||
|
||||
/** Enum descriptions. */
|
||||
const char* onlp_snmp_sensor_status_desc(onlp_snmp_sensor_status_t e);
|
||||
|
||||
/** Enum validator. */
|
||||
int onlp_snmp_sensor_status_valid(onlp_snmp_sensor_status_t e);
|
||||
|
||||
/** validator */
|
||||
#define ONLP_SNMP_SENSOR_STATUS_VALID(_e) \
|
||||
(onlp_snmp_sensor_status_valid((_e)))
|
||||
|
||||
/** onlp_snmp_sensor_status_map table. */
|
||||
extern aim_map_si_t onlp_snmp_sensor_status_map[];
|
||||
/** onlp_snmp_sensor_status_desc_map table. */
|
||||
extern aim_map_si_t onlp_snmp_sensor_status_desc_map[];
|
||||
|
||||
/** Enum names. */
|
||||
const char* onlp_snmp_sensor_type_name(onlp_snmp_sensor_type_t e);
|
||||
|
||||
|
||||
@@ -65,11 +65,6 @@ onlp_snmp_config_settings_t onlp_snmp_config_settings[] =
|
||||
#else
|
||||
{ ONLP_SNMP_CONFIG_DEV_BASE_INDEX(__onlp_snmp_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef ONLP_SNMP_CONFIG_DEV_MAX_INDEX
|
||||
{ __onlp_snmp_config_STRINGIFY_NAME(ONLP_SNMP_CONFIG_DEV_MAX_INDEX), __onlp_snmp_config_STRINGIFY_VALUE(ONLP_SNMP_CONFIG_DEV_MAX_INDEX) },
|
||||
#else
|
||||
{ ONLP_SNMP_CONFIG_DEV_MAX_INDEX(__onlp_snmp_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef ONLP_SNMP_CONFIG_INCLUDE_THERMALS
|
||||
{ __onlp_snmp_config_STRINGIFY_NAME(ONLP_SNMP_CONFIG_INCLUDE_THERMALS), __onlp_snmp_config_STRINGIFY_VALUE(ONLP_SNMP_CONFIG_INCLUDE_THERMALS) },
|
||||
#else
|
||||
|
||||
@@ -69,70 +69,6 @@ onlp_snmp_fan_flow_type_valid(onlp_snmp_fan_flow_type_t e)
|
||||
}
|
||||
|
||||
|
||||
aim_map_si_t onlp_snmp_sensor_status_map[] =
|
||||
{
|
||||
{ "missing", ONLP_SNMP_SENSOR_STATUS_MISSING },
|
||||
{ "good", ONLP_SNMP_SENSOR_STATUS_GOOD },
|
||||
{ "failed", ONLP_SNMP_SENSOR_STATUS_FAILED },
|
||||
{ "unplugged", ONLP_SNMP_SENSOR_STATUS_UNPLUGGED },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
aim_map_si_t onlp_snmp_sensor_status_desc_map[] =
|
||||
{
|
||||
{ "None", ONLP_SNMP_SENSOR_STATUS_MISSING },
|
||||
{ "None", ONLP_SNMP_SENSOR_STATUS_GOOD },
|
||||
{ "None", ONLP_SNMP_SENSOR_STATUS_FAILED },
|
||||
{ "None", ONLP_SNMP_SENSOR_STATUS_UNPLUGGED },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
const char*
|
||||
onlp_snmp_sensor_status_name(onlp_snmp_sensor_status_t e)
|
||||
{
|
||||
const char* name;
|
||||
if(aim_map_si_i(&name, e, onlp_snmp_sensor_status_map, 0)) {
|
||||
return name;
|
||||
}
|
||||
else {
|
||||
return "-invalid value for enum type 'onlp_snmp_sensor_status'";
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
onlp_snmp_sensor_status_value(const char* str, onlp_snmp_sensor_status_t* e, int substr)
|
||||
{
|
||||
int i;
|
||||
AIM_REFERENCE(substr);
|
||||
if(aim_map_si_s(&i, str, onlp_snmp_sensor_status_map, 0)) {
|
||||
/* Enum Found */
|
||||
*e = i;
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
const char*
|
||||
onlp_snmp_sensor_status_desc(onlp_snmp_sensor_status_t e)
|
||||
{
|
||||
const char* name;
|
||||
if(aim_map_si_i(&name, e, onlp_snmp_sensor_status_desc_map, 0)) {
|
||||
return name;
|
||||
}
|
||||
else {
|
||||
return "-invalid value for enum type 'onlp_snmp_sensor_status'";
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
onlp_snmp_sensor_status_valid(onlp_snmp_sensor_status_t e)
|
||||
{
|
||||
return aim_map_si_i(NULL, e, onlp_snmp_sensor_status_map, 0) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
aim_map_si_t onlp_snmp_psu_type_map[] =
|
||||
{
|
||||
{ "unknown", ONLP_SNMP_PSU_TYPE_UNKNOWN },
|
||||
@@ -197,6 +133,70 @@ onlp_snmp_psu_type_valid(onlp_snmp_psu_type_t e)
|
||||
}
|
||||
|
||||
|
||||
aim_map_si_t onlp_snmp_sensor_status_map[] =
|
||||
{
|
||||
{ "missing", ONLP_SNMP_SENSOR_STATUS_MISSING },
|
||||
{ "good", ONLP_SNMP_SENSOR_STATUS_GOOD },
|
||||
{ "failed", ONLP_SNMP_SENSOR_STATUS_FAILED },
|
||||
{ "unplugged", ONLP_SNMP_SENSOR_STATUS_UNPLUGGED },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
aim_map_si_t onlp_snmp_sensor_status_desc_map[] =
|
||||
{
|
||||
{ "None", ONLP_SNMP_SENSOR_STATUS_MISSING },
|
||||
{ "None", ONLP_SNMP_SENSOR_STATUS_GOOD },
|
||||
{ "None", ONLP_SNMP_SENSOR_STATUS_FAILED },
|
||||
{ "None", ONLP_SNMP_SENSOR_STATUS_UNPLUGGED },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
const char*
|
||||
onlp_snmp_sensor_status_name(onlp_snmp_sensor_status_t e)
|
||||
{
|
||||
const char* name;
|
||||
if(aim_map_si_i(&name, e, onlp_snmp_sensor_status_map, 0)) {
|
||||
return name;
|
||||
}
|
||||
else {
|
||||
return "-invalid value for enum type 'onlp_snmp_sensor_status'";
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
onlp_snmp_sensor_status_value(const char* str, onlp_snmp_sensor_status_t* e, int substr)
|
||||
{
|
||||
int i;
|
||||
AIM_REFERENCE(substr);
|
||||
if(aim_map_si_s(&i, str, onlp_snmp_sensor_status_map, 0)) {
|
||||
/* Enum Found */
|
||||
*e = i;
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
const char*
|
||||
onlp_snmp_sensor_status_desc(onlp_snmp_sensor_status_t e)
|
||||
{
|
||||
const char* name;
|
||||
if(aim_map_si_i(&name, e, onlp_snmp_sensor_status_desc_map, 0)) {
|
||||
return name;
|
||||
}
|
||||
else {
|
||||
return "-invalid value for enum type 'onlp_snmp_sensor_status'";
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
onlp_snmp_sensor_status_valid(onlp_snmp_sensor_status_t e)
|
||||
{
|
||||
return aim_map_si_i(NULL, e, onlp_snmp_sensor_status_map, 0) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
aim_map_si_t onlp_snmp_sensor_type_map[] =
|
||||
{
|
||||
{ "temp", ONLP_SNMP_SENSOR_TYPE_TEMP },
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user