Skip to content

Wrong rounding in rack-level power utilization figure #12838

@candlerb

Description

@candlerb

NetBox version

v3.5.3

Python version

3.8

Steps to Reproduce

  1. Create a power feed and some devices in a rack, such that the power utilization on the power feed is 2.5% - specific instructions in discussion Documenting the "power utilization" features of Netbox #12837
  2. Look at the power feed utilization
  3. Look at the rack level power utilization

Expected Behavior

Both to show the same

Observed Behavior

Power-feed utilization shows as "2.5%"

But rack-level utilization power shows as "2.0%"

The problem is that percentage() in netbox/utilities/templatetags/helpers.py rounds to nearest 0.1%

return round(x / y * 100, 1)

Whereas Rack.get_power_utilization in netbox/dcim/models/racks.py rounds down to integer:

return int(allocated_draw / available_power_total * 100)

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions