Skip to content

Commit f77af8a

Browse files
committed
adds missing power control data #163
1 parent ca72bf9 commit f77af8a

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

cr_module/power.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -228,34 +228,36 @@ def get_single_chassi_power(redfish_url, chassi_id, power_data):
228228

229229
for power_control in power_control_data:
230230

231-
if power_control.get("Status") is None:
232-
continue
233-
234231
power_control_status = get_status_data(grab(power_control, "Status"))
235232
status = power_control_status.get("Health")
236233
state = power_control_status.get("State")
237-
name = power_control.get("Name")
234+
name = power_control.get("Name", "Power Control")
238235
reading = power_control.get("PowerConsumedWatts")
239236

240-
if status is None:
241-
continue
242-
243237
if str(reading) == "0":
244238
reading = None
245239

240+
if reading is None and status is None:
241+
continue
242+
246243
power_control_num += 1
247244

248245
if plugin_object.rf.vendor == "Ami" and state == "Disabled":
249246
status = "OK"
250247

248+
status_text = f"{name}"
249+
if status is not None and state is not None:
250+
status_text += f" (status: {status}/{state})"
251251
if reading is not None:
252-
status_text = f"{name} (status: {status}/{state}) current consumption: {reading}W"
253-
else:
254-
status_text = f"{name} status: {status}/{state}"
252+
status_text += f" - current power consumption: {reading}W"
255253

256-
if status != "OK":
254+
if status is not None and status != "OK":
257255
issue_detected = True
258256

257+
# mock status for power control without status attribute
258+
if status is None:
259+
status = "OK"
260+
259261
plugin_object.add_output_data("CRITICAL" if status not in ["OK", "WARNING"] else status,
260262
status_text, location=f"Chassi {chassi_id}")
261263

0 commit comments

Comments
 (0)