Skip to content

Commit

Permalink
Merge pull request #1809 from tcaiazza/issue_1371_1372
Browse files Browse the repository at this point in the history
Handle non standard output for NXOS PSU's in get_environment
  • Loading branch information
mirceaulinic authored Mar 21, 2024
2 parents f7dbc1c + 8ece950 commit 343dea0
Show file tree
Hide file tree
Showing 5 changed files with 2,283 additions and 2 deletions.
14 changes: 12 additions & 2 deletions napalm/nxos/nxos.py
Original file line number Diff line number Diff line change
Expand Up @@ -1563,9 +1563,19 @@ def _process_pdus(power_data: Dict) -> Dict[str, models.PowerDict]:
][0]
for psinfo in ps_info_table[ps_info_row_key]:
normalized[psinfo["psnum"]]["status"] = (
psinfo.get("ps_status", "ok") == "ok"
psinfo.get("ps_status", "ok").lower() == "ok"
)
normalized[psinfo["psnum"]]["output"] = float(psinfo.get("watts", -1.0))
# typically the power output is key'd by watts
# other times it is keyed by "actual_out"
if "watts" in psinfo:
normalized[psinfo["psnum"]]["output"] = float(
psinfo.get("watts", -1.0)
)
else:
# When the power output is keyed by actual_out, it appears like "99 W"
normalized[psinfo["psnum"]]["output"] = float(
psinfo.get("actual_out", -1.0).split()[0]
)
# Newer nxos versions provide the total capacity in the `tot_capa` key
if "tot_capa" in psinfo:
normalized[psinfo["psnum"]]["capacity"] = float(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"power": {
"1": {
"status": true,
"output": 98,
"capacity": 400
},
"2": {
"status": false,
"output": 0,
"capacity": 0
}
},
"fans": {
"Fan1(sys_fan1)": {
"status": true
},
"Fan2(sys_fan2)": {
"status": true
},
"Fan3(sys_fan3)": {
"status": true
}
},
"temperature": {
"1-1 FRONT": {
"temperature": 27,
"is_alert": false,
"is_critical": false
},
"1-2 BACK": {
"temperature": 27,
"is_alert": false,
"is_critical": false
},
"1-3 CPU": {
"temperature": 35,
"is_alert": false,
"is_critical": false
},
"1-4 Homewood": {
"temperature": 39,
"is_alert": false,
"is_critical": false
}
},
"cpu": {
"0": {
"%usage": 4.8
}
},
"memory": {
"available_ram": 575000,
"used_ram": 52000
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
"fandetails": {
"fan_filter_status": "NotSupported",
"TABLE_faninfo": {
"ROW_faninfo": [
{
"fanname": "Fan1(sys_fan1)",
"fanmodel": "NXA-FAN-30CFM-F",
"fanhwver": "--",
"fandir": "back-to-front",
"fanstatus": "Ok"
},
{
"fanname": "Fan2(sys_fan2)",
"fanmodel": "NXA-FAN-30CFM-F",
"fanhwver": "--",
"fandir": "back-to-front",
"fanstatus": "Ok"
},
{
"fanname": "Fan3(sys_fan3)",
"fanmodel": "NXA-FAN-30CFM-F",
"fanhwver": "--",
"fandir": "back-to-front",
"fanstatus": "Ok"
},
{
"fanname": "Fan_in_PS1",
"fanmodel": "",
"fanhwver": "--",
"fandir": "back-to-front",
"fanstatus": "Ok"
},
{
"fanname": "Fan_in_PS2",
"fanmodel": "",
"fanhwver": "--",
"fandir": "back-to-front",
"fanstatus": "Shutdown"
}
]
},
"TABLE_fan_zone_speed": {
"ROW_fan_zone_speed": {
"zone": "1",
"zonespeed": "0xb3"
}
}
},
"TABLE_tempinfo": {
"ROW_tempinfo": [
{
"tempmod": "1",
"sensor": "FRONT",
"majthres": "80",
"minthres": "70",
"curtemp": "27",
"alarmstatus": "Ok"
},
{
"tempmod": "1",
"sensor": "BACK",
"majthres": "70",
"minthres": "42",
"curtemp": "27",
"alarmstatus": "Ok"
},
{
"tempmod": "1",
"sensor": "CPU",
"majthres": "90",
"minthres": "80",
"curtemp": "35",
"alarmstatus": "Ok"
},
{
"tempmod": "1",
"sensor": "Homewood",
"majthres": "110",
"minthres": "90",
"curtemp": "39",
"alarmstatus": "Ok"
}
]
},
"powersup": {
"voltage_level": 12,
"power_summary": {
"ps_redun_mode": "PS-Redundant",
"ps_oper_mode": "Non-Redundant",
"tot_pow_capacity": " 400.00 W",
"tot_gridA_capacity": " 400.00 W",
"tot_gridB_capacity": " 0.00 W",
"cumulative_power": " 400.00 W",
"tot_pow_out_actual_draw": " 98.00 W",
"tot_pow_input_actual_draw": " 115.00 W",
"tot_pow_alloc_budgeted": " N/A ",
"available_pow": " N/A "
},
"TABLE_psinfo": {
"ROW_psinfo": [
{
"psnum": 1,
"psmodel": "N2200-PAC-400W",
"actual_out": " 98 W",
"actual_input": " 115 W",
"tot_capa": " 400 W",
"ps_status": "Ok"
},
{
"psnum": 2,
"psmodel": "N2200-PAC-400W",
"actual_out": " 0 W",
"actual_input": " 0 W",
"tot_capa": " 0 W",
"ps_status": "Shutdown"
}
]
}
}
}
Loading

0 comments on commit 343dea0

Please sign in to comment.