Files
Netbox-Utilities/netbox_utilities/templates/netbox_utilities/cluster_capacity_panel.html
T
MrBlakeandClaude Opus 5.5 9fd3e01cdf feat: clearer cluster capacity panel
Key figures (hosts, vCPU:core, RAM allocation, N+1) as tiles with
colours, warnings in one compact box and the host table across the full
width with RAM bars, coloured ratios and one-line VM figures.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 12:50:05 +01:00

135 lines
6.7 KiB
HTML

<div class="card">
<h2 class="card-header d-flex align-items-center">
<span class="me-auto"><i class="mdi mdi-chip me-1" aria-hidden="true"></i>Kapazität (CPU &amp; RAM)</span>
<a href="{{ hardware_list_url }}" class="btn btn-sm btn-outline-secondary">Hardware-Liste</a>
</h2>
{% if not rows %}
<div class="card-body text-muted">Dem Cluster sind keine Hosts (Geräte) zugeordnet.</div>
{% else %}
<div class="card-body pb-0">
<div class="row g-3">
{# Hosts #}
<div class="col-6 col-xl-3">
<div class="border rounded p-3 h-100">
<div class="text-muted small text-uppercase">Hosts</div>
<div class="fs-3 fw-semibold lh-sm">{{ rows|length }}</div>
<div class="small text-muted">
{% if capacity.cores %}{{ capacity.cores }} Kerne · {{ capacity.threads }} Threads · {{ memory }}{% else %}keine CPU erfasst{% endif %}
</div>
</div>
</div>
{# vCPU ratio #}
<div class="col-6 col-xl-3">
<div class="border rounded p-3 h-100">
<div class="text-muted small text-uppercase">vCPU : Kern</div>
<div class="fs-3 fw-semibold lh-sm text-{{ cluster_ratio_level }}">{{ vcpu_per_core }}</div>
<div class="small text-muted">
{{ capacity.vcpus|floatformat:"-1" }} vCPUs in {{ capacity.vm_count }} VM{{ capacity.vm_count|pluralize:",s" }}
{% if ratio_limit %}· Grenze {{ ratio_limit }} : 1{% endif %}
</div>
</div>
</div>
{# RAM #}
<div class="col-6 col-xl-3">
<div class="border rounded p-3 h-100">
<div class="text-muted small text-uppercase">RAM belegt</div>
<div class="fs-3 fw-semibold lh-sm text-{{ cluster_memory_level }}">
{% if capacity.memory_percent is not None %}{{ capacity.memory_percent }} %{% else %}—{% endif %}
</div>
<div class="progress my-1" style="height: .4rem">
<div class="progress-bar bg-{{ cluster_memory_level }}" style="width: {{ cluster_memory_bar }}%"></div>
</div>
<div class="small text-muted">{{ vm_memory }} von {{ memory }}</div>
</div>
</div>
{# N+1 #}
<div class="col-6 col-xl-3">
<div class="border rounded p-3 h-100">
<div class="text-muted small text-uppercase">Ausfall größter Host (N+1)</div>
{% if capacity.failover_memory_gb is None %}
<div class="fs-3 fw-semibold lh-sm text-muted">—</div>
<div class="small text-muted">braucht mindestens 2 Hosts mit erfasstem RAM</div>
{% else %}
<div class="fs-3 fw-semibold lh-sm text-{% if capacity.failover_ok %}success{% else %}warning{% endif %}">
{% if capacity.failover_ok %}OK{% else %}Nicht erfüllt{% endif %}
</div>
<div class="small text-muted">{{ failover_memory }} verbleiben · {{ vm_memory }} benötigt</div>
{% endif %}
</div>
</div>
</div>
{% if capacity_warnings %}
<div class="alert alert-warning mt-3 mb-0 py-2">
<ul class="mb-0 ps-3 small">
{% for level, text in capacity_warnings %}<li>{{ text }}</li>{% endfor %}
</ul>
</div>
{% endif %}
</div>
<div class="table-responsive mt-3">
<table class="table table-hover align-middle mb-0">
<thead>
<tr>
<th>Host</th>
<th>CPU</th>
<th class="text-end">Kerne / Threads</th>
<th class="text-end">RAM</th>
<th>VMs</th>
<th class="text-end">vCPU : Kern</th>
<th style="min-width: 11rem">RAM belegt</th>
</tr>
</thead>
<tbody>
{% for row in rows %}
<tr>
<td class="text-nowrap"><a href="{{ row.device.get_absolute_url }}">{{ row.device }}</a></td>
<td class="small">
{% if row.record and row.record.cpu %}{{ row.record.cpu_display }}
{% elif can_add %}<a href="{% url 'plugins:netbox_utilities:devicehardware_add' %}?device={{ row.device.pk }}&return_url={{ request.path|urlencode }}" class="text-warning"><i class="mdi mdi-plus-circle-outline"></i> erfassen</a>
{% else %}<span class="text-warning">fehlt</span>{% endif %}
</td>
<td class="text-end text-nowrap">{% if row.host.cores %}{{ row.host.cores }} / {{ row.host.threads }}{% else %}—{% endif %}</td>
<td class="text-end text-nowrap">{{ row.memory }}</td>
<td class="text-nowrap">
{% if row.host.vm_count or row.host.total_vcpus %}
{{ row.host.vm_count }} VM{{ row.host.vm_count|pluralize:",s" }}{% if row.host.shared_vcpus or row.host.shared_memory_gb %} <span class="badge text-bg-light border">+ anteilig</span>{% endif %}
<span class="text-muted small">· {{ row.host.total_vcpus|floatformat:"-1" }} vCPU · {{ row.vm_memory }}</span>
{% else %}
<span class="text-muted">keine VMs</span>
{% endif %}
</td>
<td class="text-end text-nowrap">
{% if row.host.cores %}<span class="fw-semibold text-{{ row.ratio_level }}">{{ row.vcpu_per_core }}</span>{% else %}—{% endif %}
</td>
<td>
{% if row.memory_percent is not None %}
<div class="d-flex align-items-center gap-2">
<div class="progress flex-grow-1" style="height: .5rem">
<div class="progress-bar bg-{{ row.memory_level }}" style="width: {{ row.memory_bar }}%"></div>
</div>
<span class="small text-nowrap" style="min-width: 2.75rem">{{ row.memory_percent }} %</span>
</div>
{% else %}—{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="card-footer small text-muted">
Gezählt werden alle VMs außer „Offline“ und „Außer Betrieb“.
{% if capacity.distributed %}
VMs ohne festen Host sind anteilig nach Größe auf die Hosts verteilt: vCPUs nach Threads, RAM nach Host-RAM
(zu gleichen Teilen, wenn bei keinem Host CPU/RAM erfasst ist).
{% elif capacity.unplaced_vm_count %}
{{ capacity.unplaced_vm_count }} VM{{ capacity.unplaced_vm_count|pluralize:",s" }} ohne festen Host
{{ capacity.unplaced_vm_count|pluralize:"zählt,zählen" }} nur zur Cluster-Summe: Im Cluster sind VMs fest Hosts
zugewiesen, deshalb wird nicht automatisch verteilt.
{% endif %}
</div>
{% endif %}
</div>