1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

support for #304

This commit is contained in:
bellwood
2016-07-20 13:23:49 -04:00
committed by GitHub
parent 3f94295d7e
commit 6fe40ef223

View File

@ -360,6 +360,15 @@ class Rack(CreatedUpdatedModel):
def get_0u_devices(self):
return self.devices.filter(position=0)
def get_utilization(self):
"""
Determine the utilization rate of the rack and return it as a percentage.
"""
if self.u_consumed is None:
self.u_consumed = 0
u_available = self.u_height - self.u_consumed
return int(float(self.u_height - u_available) / self.u_height * 100)
#
# Device Types