mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-16 04:02:52 -06:00
Closes #3297: Include reserved units when calculating rack utilization
This commit is contained in:
parent
a359d88897
commit
f54774f6a1
@ -2,6 +2,7 @@ v2.6.5 (FUTURE)
|
|||||||
|
|
||||||
## Enhancements
|
## Enhancements
|
||||||
|
|
||||||
|
* [#3297](https://github.com/netbox-community/netbox/issues/3297) - Include reserved units when calculating rack utilization
|
||||||
* [#3347](https://github.com/netbox-community/netbox/issues/3347) - Extend upgrade script to automatically remove stale content types
|
* [#3347](https://github.com/netbox-community/netbox/issues/3347) - Extend upgrade script to automatically remove stale content types
|
||||||
* [#3352](https://github.com/netbox-community/netbox/issues/3352) - Enable filtering changelog API by `changed_object_id`
|
* [#3352](https://github.com/netbox-community/netbox/issues/3352) - Enable filtering changelog API by `changed_object_id`
|
||||||
* [#3524](https://github.com/netbox-community/netbox/issues/3524) - Enable bulk editing of power outlet/power port associations
|
* [#3524](https://github.com/netbox-community/netbox/issues/3524) - Enable bulk editing of power outlet/power port associations
|
||||||
|
@ -732,10 +732,21 @@ class Rack(ChangeLoggedModel, CustomFieldModel):
|
|||||||
|
|
||||||
def get_utilization(self):
|
def get_utilization(self):
|
||||||
"""
|
"""
|
||||||
Determine the utilization rate of the rack and return it as a percentage.
|
Determine the utilization rate of the rack and return it as a percentage. Occupied and reserved units both count
|
||||||
|
as utilized.
|
||||||
"""
|
"""
|
||||||
u_available = len(self.get_available_units())
|
# Determine unoccupied units
|
||||||
return int(float(self.u_height - u_available) / self.u_height * 100)
|
available_units = self.get_available_units()
|
||||||
|
|
||||||
|
# Remove reserved units
|
||||||
|
for u in self.get_reserved_units():
|
||||||
|
if u in available_units:
|
||||||
|
available_units.remove(u)
|
||||||
|
|
||||||
|
occupied_unit_count = self.u_height - len(available_units)
|
||||||
|
percentage = int(float(occupied_unit_count) / self.u_height * 100)
|
||||||
|
|
||||||
|
return percentage
|
||||||
|
|
||||||
def get_power_utilization(self):
|
def get_power_utilization(self):
|
||||||
"""
|
"""
|
||||||
|
@ -135,6 +135,10 @@
|
|||||||
<a href="{% url 'dcim:device_list' %}?rack_id={{ rack.id }}">{{ rack.devices.count }}</a>
|
<a href="{% url 'dcim:device_list' %}?rack_id={{ rack.id }}">{{ rack.devices.count }}</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Utilization</td>
|
||||||
|
<td>{% utilization_graph rack.get_utilization %}</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
|
Loading…
Reference in New Issue
Block a user