Fixed PSU power consumption calculation
When PSUs were found, the voltage value was never set, raising an exception when trying to multiply current * voltage (float * None). This patch reads per PSU voltage (with 230V as default) and define power consumption from it.
This commit is contained in:
parent
b092079820
commit
af9df9ab4b
1 changed files with 6 additions and 4 deletions
|
@ -105,18 +105,20 @@ class PowerSupply():
|
|||
return False
|
||||
|
||||
# find power feeds for rack or dc
|
||||
voltage = None
|
||||
pwr_feeds = None
|
||||
if self.netbox_server.rack:
|
||||
pwr_feeds = nb.dcim.power_feeds.filter(
|
||||
rack=self.netbox_server.rack.id
|
||||
)
|
||||
if pwr_feeds is None or not len(pwr_feeds):
|
||||
|
||||
if pwr_feeds:
|
||||
voltage = [p['voltage'] for p in pwr_feeds]
|
||||
else:
|
||||
logging.info('Could not find power feeds for Rack, defaulting value to 230')
|
||||
voltage = 230
|
||||
voltage = [230 for _ in nb_psu]
|
||||
|
||||
for i, nb_psu in enumerate(nb_psus):
|
||||
nb_psu.allocated_draw = float(psu_cons[i]) * voltage
|
||||
nb_psu.allocated_draw = int(float(psu_cons[i]) * voltage[i])
|
||||
if nb_psu.allocated_draw < 1:
|
||||
logging.info('PSU is not connected or in standby mode')
|
||||
continue
|
||||
|
|
Loading…
Reference in a new issue