From 6cad2399c56c424060e21c41dba6df852297dd85 Mon Sep 17 00:00:00 2001 From: Solvik Blum Date: Tue, 10 Sep 2019 15:20:29 +0200 Subject: [PATCH] handle more PSU dmidecode format --- netbox_agent/power.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/netbox_agent/power.py b/netbox_agent/power.py index a5ec922..93ade45 100644 --- a/netbox_agent/power.py +++ b/netbox_agent/power.py @@ -17,7 +17,7 @@ class PowerSupply(): def get_power_supply(self): power_supply = [] for psu in self.server.dmi.get_by_type(PSU_DMI_TYPE): - if 'Present' not in psu['Status']: + if 'Present' not in psu['Status'] or psu['Status'] == 'Not Present': continue try: @@ -86,7 +86,11 @@ class PowerSupply(): return True def report_power_consumption(self): - psu_cons = self.server.get_power_consumption() + try: + psu_cons = self.server.get_power_consumption() + except NotImplementedError: + logging.error('Cannot report power consumption for this vendor') + return False nb_psus = self.get_netbox_power_supply() if not len(nb_psus) or not len(psu_cons): -- 2.47.0