mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
feat(instances): a VM's options in one list, each saved when it can be
Settings > Options was four forms under bold sentences, most of them disabled while the VM ran. The owner chose this layout from three rendered options: one list, each row a setting with its description on the left and its control on the right: VM details (title, description), Template, primary video model, QEMU guest agent. vCPU hot plug moved to Resize > CPU, next to the vCPU counts. Codex reviewed the four forms; these are fixed: - Title, description and the video model are saved while the VM runs: they are in the persistent definition, used at the next start. - The template flag has its own form and view, set_template, for superusers and staff, and only for a shut-off VM: a running VM made a template left the quota while it kept running. Turning a template back into a VM checks the quota there, and each change is audited. The title form no longer touches the flag. - A new video model stays the primary one; the old model's memory and head settings, which are its own, go with it. - The agent and vCPU hot plug forms show the persistent definition; they showed the running VM's, so a pending change looked undone. - Enabling the guest agent adds its channel only where it is missing: saving Enabled again failed, and a channel pending the next start kept a running VM from getting one. - The agent line tells a VM that is not running, one without a channel, and a connected or not connected agent apart.
This commit is contained in:
parent
46188d3230
commit
a993c12db0
13 changed files with 272 additions and 172 deletions
|
|
@ -84,6 +84,32 @@
|
|||
<button class="btn btn-primary float-end disabled" disabled>{% trans "Resize" %}</button>
|
||||
{% endif %}
|
||||
<div class="clearfix"></div>
|
||||
{% if request.user.is_superuser %}
|
||||
<form class="border-top pt-3 mt-3" action="{% url 'instances:set_vcpu_hotplug' instance.id %}" method="post">{% csrf_token %}
|
||||
<div class="row g-3 align-items-center">
|
||||
<div class="col-12 col-lg-4">
|
||||
<label class="form-label fw-semibold mb-0" for="vcpu_hotplug">{% trans "vCPU hot plug" %}</label>
|
||||
<p class="small text-body-secondary mb-0" id="vcpu-hotplug-help">
|
||||
{% trans "Lets vCPUs up to the maximum be turned on and off while the VM runs." %}
|
||||
{% if instance.status != 5 %}{% trans "Shut the VM down to change this." %}{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-12 col-lg-8">
|
||||
<div class="row g-2">
|
||||
<div class="col-12 col-sm">
|
||||
<select id="vcpu_hotplug" class="form-select" name="vcpu_hotplug" aria-describedby="vcpu-hotplug-help">
|
||||
<option value="True"{% if instance.config_vcpu_hotplug %} selected{% endif %}>{% trans "Enabled" %}</option>
|
||||
<option value="False"{% if not instance.config_vcpu_hotplug %} selected{% endif %}>{% trans "Disabled" %}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-12 col-sm-auto d-grid">
|
||||
<button class="btn btn-secondary" type="submit" name="set_vcpu_hotplug"{% if instance.status != 5 %} disabled{% endif %}>{% trans "Save" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div role="tabpanel" class="tab-pane" id="resizevm_mem">
|
||||
{% if can_change %}
|
||||
|
|
|
|||
|
|
@ -809,110 +809,96 @@
|
|||
{% endif %}
|
||||
{% if can_change %}
|
||||
<div role="tabpanel" class="tab-pane" id="options">
|
||||
<p>{% trans "To set instance template name description, shutdown the instance." %}</p>
|
||||
<form action="{% url 'instances:change_options' instance.id %}" method="post" role="form" aria-label="Set instance template name description form">{% csrf_token %}
|
||||
<div class="row">
|
||||
<label class="col-sm-3 col-form-label">{% trans "Title" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" name="title" class="form-control" value="{{ instance.config_title }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label class="col-sm-3 col-form-label">{% trans "Description" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<textarea name="description" class="form-control">{{ instance.config_description }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label class="col-sm-3 col-form-label">{% trans "Is template" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="checkbox"
|
||||
name="is_template"
|
||||
value="True"
|
||||
id="is_template"
|
||||
{% if instance.is_template %}checked{% endif %}
|
||||
{% if not request.user.is_superuser and not request.user.is_staff %}disabled{% endif %}>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="d-grid offset-sm-3 col-sm-6">
|
||||
{% if instance.status == 5 %}
|
||||
<button type="submit" class="btn btn-primary" name="change_options">{% trans "Change" %}</button>
|
||||
{% else %}
|
||||
<button class="btn btn-primary disabled" disabled name="change_options">{% trans "Change" %}</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% if request.user.is_superuser %}
|
||||
<p class="fw-bold">{% trans "To set instance video model, shutdown the instance." %}</p>
|
||||
<form action="{% url 'instances:set_video_model' instance.id %}" method="post" role="form" aria-label="Set instance video model form">{% csrf_token %}
|
||||
<div class="row">
|
||||
<label class="col-sm-3 col-form-label" for="video_model_select">{% trans "Primary Video Model" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<div class="input-group">
|
||||
<select id="video_model_select" class="form-select" name="video_model">
|
||||
<option class="fw-bold" value="">{% trans "please choose" %}</option>
|
||||
{% for vmodel in instance.video_models %}
|
||||
<option value="{{ vmodel }}"{% if vmodel == instance.config_video_model %} selected{% endif %}>{{ vmodel }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% if instance.status == 5 %}
|
||||
<button type="submit" class="btn btn-primary" name="set_video_model">{% trans "Set" %}</button>
|
||||
{% else %}
|
||||
<button class="btn btn-primary disabled" disabled name="set_video_model">{% trans "Set" %}</button>
|
||||
{% endif %}
|
||||
<div class="list-group">
|
||||
<form class="list-group-item p-3 p-md-4" action="{% url 'instances:change_options' instance.id %}" method="post" aria-labelledby="options-details">{% csrf_token %}
|
||||
<div class="row g-3">
|
||||
<div class="col-12 col-lg-4">
|
||||
<h2 class="h6" id="options-details">{% bs_icon 'pencil-square' %} {% trans "VM details" %}</h2>
|
||||
<p class="small text-body-secondary mb-0">{% trans "A title and description to identify the VM." %}</p>
|
||||
</div>
|
||||
<div class="col-12 col-lg-8">
|
||||
<label class="form-label" for="options-title">{% trans "Title" %}</label>
|
||||
<input class="form-control mb-3" type="text" id="options-title" name="title" value="{{ instance.config_title }}">
|
||||
<label class="form-label" for="options-description">{% trans "Description" %}</label>
|
||||
<textarea class="form-control mb-3" id="options-description" name="description" rows="2">{{ instance.config_description }}</textarea>
|
||||
<div class="text-end">
|
||||
<button class="btn btn-primary" type="submit" name="change_options">{% trans "Save" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<p class="fw-bold">{% trans "To set instance vCPUs hotpluggable" %}</p>
|
||||
<form action="{% url 'instances:set_vcpu_hotplug' instance.id %}" method="post" role="form" aria-label="Set instance vCPUs hotpluggable form">{% csrf_token %}
|
||||
<div class="row">
|
||||
<label for="vcpu_hotplug" class="col-sm-3 col-form-label">{% trans "vCPU Hot Plug" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<div class="input-group">
|
||||
<select id="vcpu_hotplug" class="form-control" name="vcpu_hotplug">
|
||||
<option value="True" {% if instance.vcpus %} selected {% endif %}>{% trans 'Enabled' %}</option>
|
||||
<option value="False" {% if not instance.vcpus %} selected {% endif %}>{% trans 'Disabled' %}</option>
|
||||
</select>
|
||||
{% if instance.status == 5 %}
|
||||
<button type="submit" class="btn btn-primary" name="set_vcpu_hotplug">{% trans "Set" %}</button>
|
||||
{% else %}
|
||||
<button class="btn btn-primary" name="set_vcpu_hotplug" disabled>{% trans "Set" %}</button>
|
||||
{% endif %}
|
||||
</form>
|
||||
<form class="list-group-item p-3 p-md-4" action="{% url 'instances:set_template' instance.id %}" method="post">{% csrf_token %}
|
||||
<div class="row g-3 align-items-center">
|
||||
<div class="col-12 col-lg-4">
|
||||
<label class="form-label fw-semibold mb-0" for="is_template">{% trans "Template" %}</label>
|
||||
<p class="small text-body-secondary mb-0" id="template-help">{% trans "A template is a VM to clone: it is not counted in quotas and cannot be started." %}</p>
|
||||
</div>
|
||||
<div class="col-12 col-lg-8">
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" role="switch" name="is_template" value="True" id="is_template" aria-describedby="template-help template-state"
|
||||
{% if instance.is_template %}checked{% endif %}
|
||||
{% if instance.status != 5 or not request.user.is_superuser and not request.user.is_staff %}disabled{% endif %} onchange="this.form.submit()">
|
||||
<label class="form-check-label" for="is_template">{% trans "Use as a template" %}</label>
|
||||
</div>
|
||||
<p class="small text-body-secondary mt-1 mb-0" id="template-state">
|
||||
{% if not request.user.is_superuser and not request.user.is_staff %}{% trans "Only administrators and staff can change this." %}
|
||||
{% elif instance.status != 5 %}{% trans "Shut the VM down to change this." %}{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<p class="fw-bold">{% trans "To Enable/Disable Qemu Guest Agent. Status" %}:
|
||||
{% if instance.status == 1 %}
|
||||
{% if instance.guest_agent_ready %}
|
||||
<label class="badge bg-success">{% trans 'Connected' %}</label>
|
||||
{% else %}
|
||||
<label class="badge bg-danger">{% trans 'Disconnected' %}</label>
|
||||
{% endif %}</p>
|
||||
{% else %}
|
||||
<label class="badge bg-default">{% trans 'Unknown' %}</label>
|
||||
{% endif %}
|
||||
<form action="{% url 'instances:set_guest_agent' instance.id %}" method="post" role="form" aria-label="Enable/Disable Qemu Guest Agent form">{% csrf_token %}
|
||||
<div class="row">
|
||||
<label class="col-sm-3 col-form-label" for="guest_agent">{% trans "Qemu Guest Agent" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<div class="input-group">
|
||||
<select id="guest_agent" class="form-select" name="guest_agent">
|
||||
<option value="True" {% if instance.guest_agent %} selected {% endif %}>{% trans 'Enabled' %}</option>
|
||||
<option value="False" {% if not instance.guest_agent %} selected {% endif %}>{% trans 'Disabled' %}</option>
|
||||
</select>
|
||||
<button type="submit" class="btn btn-primary" name="set_guest_agent">{% trans "Set" %}</button>
|
||||
</form>
|
||||
{% if request.user.is_superuser %}
|
||||
<form class="list-group-item p-3 p-md-4" action="{% url 'instances:set_video_model' instance.id %}" method="post">{% csrf_token %}
|
||||
<div class="row g-3 align-items-center">
|
||||
<div class="col-12 col-lg-4">
|
||||
<label class="form-label fw-semibold mb-0" for="video_model_select">{% trans "Primary video model" %}</label>
|
||||
<p class="small text-body-secondary mb-0" id="video-help">{% trans "The graphics device the guest sees." %}</p>
|
||||
</div>
|
||||
<div class="col-12 col-lg-8">
|
||||
<div class="row g-2">
|
||||
<div class="col-12 col-sm">
|
||||
<select id="video_model_select" class="form-select" name="video_model" aria-describedby="video-help">
|
||||
{% for vmodel in instance.video_models %}
|
||||
<option value="{{ vmodel }}"{% if vmodel == instance.config_video_model %} selected{% endif %}>{{ vmodel }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-12 col-sm-auto d-grid">
|
||||
<button class="btn btn-secondary" type="submit" name="set_video_model">{% trans "Save" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% endif %}
|
||||
<div class="clearfix"></div>
|
||||
</form>
|
||||
<form class="list-group-item p-3 p-md-4" action="{% url 'instances:set_guest_agent' instance.id %}" method="post">{% csrf_token %}
|
||||
<div class="row g-3 align-items-center">
|
||||
<div class="col-12 col-lg-4">
|
||||
<label class="form-label fw-semibold mb-0" for="guest_agent">{% trans "QEMU guest agent" %}</label>
|
||||
<p class="small text-body-secondary mb-0" id="agent-help">{% trans "The channel to the agent in the guest: a running VM gets it at once." %}</p>
|
||||
<p class="small mt-2 mb-0">{% trans "Agent" %}:
|
||||
{% if instance.status != 1 and instance.status != 3 %}<span class="badge bg-secondary">{% trans "VM not running" %}</span>
|
||||
{% elif not instance.guest_agent %}<span class="badge bg-secondary">{% trans "No channel" %}</span>
|
||||
{% elif instance.guest_agent_ready %}<span class="badge bg-success">{% trans "Connected" %}</span>
|
||||
{% else %}<span class="badge bg-danger">{% trans "Not connected" %}</span>{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-12 col-lg-8">
|
||||
<div class="row g-2">
|
||||
<div class="col-12 col-sm">
|
||||
<select id="guest_agent" class="form-select" name="guest_agent" aria-describedby="agent-help">
|
||||
<option value="True"{% if instance.config_guest_agent %} selected{% endif %}>{% trans "Enabled" %}</option>
|
||||
<option value="False"{% if not instance.config_guest_agent %} selected{% endif %}>{% trans "Disabled" %}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-12 col-sm-auto d-grid">
|
||||
<button class="btn btn-secondary" type="submit" name="set_guest_agent">{% trans "Save" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue