1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00
webvirtcloud/instances/templates/instances/power_tab.html
catborise dba2c2b1c2 fix(instances): a VM with a saved state says so and can start without it
A VM with a managed save image showed as plain Off; Power On restored the
saved memory and the panel had no way to boot it fresh or drop the saved
state. The power tab now says the VM has a saved state and offers Start
Without Saved State (confirmed), which boots it with
VIR_DOMAIN_START_FORCE_BOOT and so discards the image. Owners get it as
they get Power On; the audit row names it.
2026-11-11 15:17:59 +03:00

87 lines
6.7 KiB
HTML

{% load i18n %}
{% load vm_states %}
<div class="tab-pane active mt-3" id="power" role="tabpanel">
{% if not can_power %}
<p>{% trans "Only the owners of this instance and administrators can change its power state." %}</p>
{% else %}
{# the three states a VM moves between, the current one marked; under each, the action that takes the VM there #}
{% vm_state instance.status as state %}
<div class="card">
<div class="card-body">
{% if instance.status not in power_states %}
<p class="mb-3">{% blocktrans with state=state.0 %}The VM's state: {{ state }}{% endblocktrans %}</p>
{% endif %}
<form method="post"{% if "poweron" in power_actions %} action="{% url 'instances:poweron' instance.id %}" data-please-wait{% endif %}>{% csrf_token %}
<div class="row g-4">
<div class="col-12 col-md-4">
<div class="d-flex align-items-center gap-2 mb-2">
{% if instance.status == 1 or instance.status == 2 %}
<span class="power-dot bg-success" aria-hidden="true"></span><span class="fw-semibold">{% trans "Active" %}</span><span class="small text-body-secondary">{% trans "now" %}</span>
{% else %}
<span class="power-dot" aria-hidden="true"></span><span class="text-body-secondary">{% trans "Active" %}</span>
{% endif %}
</div>
{% if "poweron" in power_actions %}
<button type="submit" class="btn btn-primary" name="poweron">{% trans "Power On" %}</button>
<p class="small text-body-secondary mt-1 mb-0">{% trans "Starts the VM." %}</p>
{% elif "resume" in power_actions %}
<button type="submit" class="btn btn-primary" name="resume" formaction="{% url 'instances:resume' instance.id %}">{% trans "Resume" %}</button>
<p class="small text-body-secondary mt-1 mb-0">{% trans "Lets it run on." %}</p>
{% endif %}
</div>
<div class="col-12 col-md-4">
<div class="d-flex align-items-center gap-2 mb-2">
{% if instance.status == 3 or instance.status == 7 %}
<span class="power-dot bg-warning" aria-hidden="true"></span><span class="fw-semibold">{% trans "Suspended" %}</span><span class="small text-body-secondary">{% trans "now" %}</span>
{% else %}
<span class="power-dot" aria-hidden="true"></span><span class="text-body-secondary">{% trans "Suspended" %}</span>
{% endif %}
</div>
{% if "suspend" in power_actions %}
<button type="submit" class="btn btn-outline-primary" name="suspend" formaction="{% url 'instances:suspend' instance.id %}">{% trans "Suspend" %}</button>
<p class="small text-body-secondary mt-1 mb-0">{% trans "Pauses it; it stays in memory." %}</p>
{% elif instance.status == 3 and not power_actions %}
<p class="small text-body-secondary mb-0">{% trans "An administrator can resume it." %}</p>
{% endif %}
</div>
<div class="col-12 col-md-4">
<div class="d-flex align-items-center gap-2 mb-2">
{% if instance.status == 5 %}
<span class="power-dot bg-secondary" aria-hidden="true"></span><span class="fw-semibold">{% trans "Off" %}</span><span class="small text-body-secondary">{% trans "now" %}</span>
{% else %}
<span class="power-dot" aria-hidden="true"></span><span class="text-body-secondary">{% trans "Off" %}</span>
{% endif %}
</div>
{% if "poweroff" in power_actions %}
<button type="submit" class="btn btn-outline-primary" name="poweroff" formaction="{% url 'instances:poweroff' instance.id %}">{% trans "Power Off" %}</button>
<p class="small text-body-secondary mt-1 mb-0">{% trans "Asks the guest to shut down." %}</p>
{% elif instance.status == 5 and instance.is_template %}
<p class="small text-body-secondary mb-0">{% trans "A template is not started: clone it to make a VM." %}</p>
{% endif %}
</div>
</div>
</form>
{% if "poweron" in power_actions and instance.has_managed_save_image %}
<form method="post" action="{% url 'instances:poweron' instance.id %}" class="d-flex flex-wrap align-items-center gap-2 border-top mt-4 pt-3" data-please-wait>{% csrf_token %}
<span class="small me-auto">{% trans "The VM has a saved state: Power On resumes it as it was when saved." %}</span>
<button type="submit" class="btn btn-sm btn-outline-danger" name="fresh" value="1"
data-confirm="{% blocktrans with name=instance.name %}Start {{ name }} without its saved state? The saved state is discarded and the VM boots anew; what it had in memory is lost.{% endblocktrans %}">{% trans "Start Without Saved State" %}</button>
</form>
{% endif %}
{% if "force_off" in power_actions or "powercycle" in power_actions %}
<form method="post" class="d-flex flex-wrap align-items-center gap-2 border-top mt-4 pt-3">{% csrf_token %}
<span class="small text-danger me-auto">{% trans "A power cut: what the guest has not written to disk is lost." %}</span>
{% if "force_off" in power_actions %}
<button type="submit" class="btn btn-sm btn-outline-danger" name="powerforce" formaction="{% url 'instances:force_off' instance.id %}"
data-confirm="{% blocktrans with name=instance.name %}Force off {{ name }}? It stops at once, as after a power cut; what the guest has not written to disk is lost.{% endblocktrans %}">{% trans "Force Off" %}</button>
{% endif %}
{% if "powercycle" in power_actions %}
<button type="submit" class="btn btn-sm btn-outline-danger" name="powercycle" formaction="{% url 'instances:powercycle' instance.id %}"
data-confirm="{% blocktrans with name=instance.name %}Power cycle {{ name }}? It stops at once, as after a power cut, and starts again; what the guest has not written to disk is lost.{% endblocktrans %}">{% trans "Power Cycle" %}</button>
{% endif %}
</form>
{% endif %}
</div>
</div>
{% endif %}
</div>