{% load i18n %} {% load vm_states %}
{% if not can_power %}

{% trans "Only the owners of this instance and administrators can change its power state." %}

{% else %} {# the actions the VM's state allows this user (states.allowed_actions): those that keep the guest's data, and those that cut the power #} {% vm_state instance.status as state %}

{% trans "Power" %} ยท {{ state.0 }}

{% if "poweroff" in power_actions or "suspend" in power_actions or "resume" in power_actions or "poweron" in power_actions or "force_off" in power_actions or "powercycle" in power_actions %}
{% if "poweroff" in power_actions or "suspend" in power_actions or "resume" in power_actions or "poweron" in power_actions %}
{% csrf_token %}
{% if "poweron" in power_actions %}{% endif %} {% if "poweroff" in power_actions %}{% endif %} {% if "resume" in power_actions %}{% endif %} {% if "suspend" in power_actions %}{% endif %}

{% if "poweron" in power_actions %}{% trans "Power On starts the VM." %}{% endif %} {% if "poweroff" in power_actions %}{% trans "Power Off asks the guest to shut down; the guest decides." %}{% endif %} {% if "resume" in power_actions %}{% trans "Resume lets the paused VM run on." %}{% endif %} {% if "suspend" in power_actions %}{% trans "Suspend pauses its vCPUs; the VM stays in memory." %}{% endif %}

{% endif %} {% if "force_off" in power_actions or "powercycle" in power_actions %}
{% csrf_token %}
{% if "powercycle" in power_actions %} {% endif %} {% if "force_off" in power_actions %} {% endif %}

{% trans "These cut the power: what the guest has not written to disk is lost." %} {% if "powercycle" in power_actions %}{% trans "Power Cycle then starts the VM again, with the settings pending its next start." %}{% endif %}

{% endif %}
{% elif instance.status == 3 %}

{% trans "The VM is paused. An administrator can resume it." %}

{% elif instance.status == 5 and instance.is_template %}

{% trans "A template is not started: clone it to make a VM." %}

{% else %}

{% trans "There is no power action for the VM in this state." %}

{% endif %}
{% endif %}