Skip to content

Get current rack utilization in units out of total rack space #7332

Answered by drmsoffall
domainzero asked this question in Q&A
Discussion options

You must be logged in to vote

If I understand your intent, I think you can still do this with export templates if you want. You'll definitely have to iterate over racks to get this info. The trick is working with what we can get; the following is based on the export template example in the docs and a glance at the available attributes on the Rack model.

Site,Rack,Occupied,Free,Total{% set ttls = {'u': 0, 'free': 0} %}
{% for rack in queryset %}{% set free_u = rack.get_available_units()|length %}{{ rack.site.name }},{{ rack.name }},{{ rack.u_height - free_u }},{{ free_u }},{{ rack.u_height }}{% set _ = ttls.update({'u': ttls['u']+rack.u_height}) %}{% set _ = ttls.update({'free': ttls['free']+free_u}) %}
{% endfor %}TOT…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@domainzero
Comment options

Answer selected by domainzero
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants