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

Fixes #660: Correct calculation of utilized space for rack list display

This commit is contained in:
Jeremy Stretch
2016-10-31 16:44:00 -04:00
parent 2d58cfaa05
commit 41af9c8900
3 changed files with 8 additions and 13 deletions

View File

@@ -488,7 +488,7 @@ class Rack(CreatedUpdatedModel, CustomFieldModel):
"""
# Gather all devices which consume U space within the rack
devices = self.devices.select_related().filter(position__gte=1).exclude(pk__in=exclude)
devices = self.devices.select_related('device_type').filter(position__gte=1).exclude(pk__in=exclude)
# Initialize the rack unit skeleton
units = range(1, self.u_height + 1)
@@ -518,9 +518,7 @@ class Rack(CreatedUpdatedModel, CustomFieldModel):
"""
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
u_available = len(self.get_available_units())
return int(float(self.u_height - u_available) / self.u_height * 100)