handle more PSU dmidecode format (#75)

This commit is contained in:
Solvik 2019-09-11 10:37:31 +02:00 committed by GitHub
parent 4303312b17
commit a0106675e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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):