support netbox >=2.9 #177
1 changed files with 6 additions and 4 deletions
|
@ -105,18 +105,20 @@ class PowerSupply():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# find power feeds for rack or dc
|
# find power feeds for rack or dc
|
||||||
voltage = None
|
|
||||||
pwr_feeds = None
|
pwr_feeds = None
|
||||||
if self.netbox_server.rack:
|
if self.netbox_server.rack:
|
||||||
pwr_feeds = nb.dcim.power_feeds.filter(
|
pwr_feeds = nb.dcim.power_feeds.filter(
|
||||||
rack=self.netbox_server.rack.id
|
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')
|
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):
|
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:
|
if nb_psu.allocated_draw < 1:
|
||||||
logging.info('PSU is not connected or in standby mode')
|
logging.info('PSU is not connected or in standby mode')
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in a new issue