1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 09:26:03 +00:00
webvirtcloud/instances/templates/instances/settings_tab.html
catborise b3cabca8d8 feat(instances): the top of a VM's page in one card
The top of a VM's page was one line of values between pipes, an icon for
the guest agent and a hidden snapshot count, then a row of big action
icons; the host links sat in a bar fixed to the bottom of the window,
over the content.

One card now holds it all (design chosen by the owner from four):
- the name with the state badge, the title under it, and where the VM
  is: its host and the host's VM list for administrators, the VM list
  for owners;
- OS details (with a connected guest agent) and Refresh;
- the guest agent's state in words and the snapshot count;
- CPU, memory, each disk with its device name and size, and the IPv4
  addresses, labelled;
- the page's sections as small labelled pills in the card's footer: one
  row from 992 px, wrapping below.

The page has no other heading: base.html's heading area is a block it
leaves out.

Each section below it (Power, Access, Resize, Snapshot, Settings, Stats,
Destroy) is a card of the same kind, so the page reads as one design
(owner's choice of two): its sub-tabs as a small underlined nav in the
card's header, its panes in the card's body without their own borders.
Buttons are of normal size in the theme's primary colour, and those that
cannot be undone (Power Cycle, Force Off, Destroy) in the danger colour.
The Stats charts lose their coloured borders. instance_tabs.js finds the
Settings tabs by their tablist role.

The bottom bar and its setting (VIEW_INSTANCE_DETAIL_BOTTOM_BAR) are
removed, and with it the CSS that kept the old Settings tabs on one line.
2026-10-29 22:46:24 +03:00

1064 lines
71 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{% load i18n %}
{% load django_bootstrap5 %}
{% load bootstrap_icons %}
{% load operations %}
<div class="tab-pane" id="settings" role="tabpanel">
<!-- Nav tabs -->
<div class="card">
<div class="card-header bg-transparent pb-0">
<ul class="nav nav-underline small" role="tablist" aria-label="Instance settings">
{% if instance.guest_agent_ready %}
<li class="nav-item" role="presentation">
<button class="px-1 nav-link" data-bs-toggle="tab" id="osinfo-tab" data-bs-target="#osinfo" type="button" role="tab" aria-controls="osinfo" aria-selected="false" onclick="get_osinfo();">
<span>{% bs_icon 'info-circle' %} </span>
</button>
</li>
{% endif %}
{% if request.user.is_superuser %}
<li class="nav-item" role="presentation">
<button class="nav-link active" data-bs-toggle="tab" data-bs-target="#boot_opt" type="button" role="tab" aria-controls="boot_opt" aria-selected="true">
{% trans "Boot" %}
</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#disks" type="button" role="tab" aria-controls="disks" aria-selected="false">
{% trans "Disk" %}
</button>
</li>
{% endif %}
{% if can_manage_console %}
<li class="nav-item" role="presentation">
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#vncsettings" type="button" role="tab" aria-controls="vncsettings" aria-selected="false">
{% trans "Console" %}
</button>
</li>
{% endif %}
{% if request.user.is_superuser %}
<li class="nav-item" role="presentation">
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#network" type="button" role="tab" aria-controls="network" aria-selected="false">
{% trans "Network" %}
</button>
</li>
{% endif %}
{% if show_hostdevs %}
<li class="nav-item" role="presentation">
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#hostdevs" type="button" role="tab" aria-controls="hostdevs" aria-selected="false">
{% trans "Host devices" %}
</button>
</li>
{% endif %}
{% if can_clone %}
<li class="nav-item" role="presentation">
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#clone" type="button" role="tab" aria-controls="clone" aria-selected="false">
{% trans "Clone" %}
</button>
</li>
{% endif %}
{% if request.user.is_superuser %}
<li class="nav-item" role="presentation">
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#migrate" type="button" role="tab" aria-controls="migrate" aria-selected="false">
{% trans "Migrate" %}
</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#xmledit" type="button" role="tab" aria-controls="xmledit" aria-selected="false">
{% trans "XML" %}
</button>
</li>
{% endif %}
{% if can_change %}
<li class="nav-item" role="presentation">
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#options" type="button" role="tab" aria-controls="options" aria-selected="false">
{% trans "Options" %}
</button>
</li>
{% endif %}
{% if request.user.is_superuser %}
<li class="nav-item" role="presentation">
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#users" type="button" role="tab" aria-controls="users" aria-selected="false">
{% trans "Users" %}
</button>
</li>
{% endif %}
</ul>
</div>
{% if instance.status != 5 %}
<p class="small text-body-secondary px-3 pt-3 mb-0" id="next-start-note">{% trans "While the VM runs, most settings here apply at its next start." %}</p>
{% endif %}
<!-- Tab panes -->
<div class="tab-content card-body">
{% if instance.guest_agent_ready %}
{% include 'instances/info_tab.html' %}
{% endif %}
{% if request.user.is_superuser %}
<div role="tabpanel" class="tab-pane active" id="boot_opt">
<p class="fw-bold">{% trans 'Autostart' %}</p>
<div class="row">
<div class="col-sm-12 text-center">
<p>{% trans "Autostart your instance when host server is power on " %}</p>
{% if instance.autostart == 0 %}
<form action="{% url 'instances:set_autostart' instance.id %}" method="post" class="d-inline">{% csrf_token %}
<button type="submit" class="btn btn-primary">{% trans "Enable" %}</button>
</form>
{% else %}
<form action="{% url 'instances:unset_autostart' instance.id %}" method="post" class="d-inline">{% csrf_token %}
<button type="submit" class="btn btn-danger">{% trans "Disable" %}</button>
</form>
{% endif %}
</div>
</div>
<p class="fw-bold">{% trans 'Boot Order' %}</p>
<div class="row">
<div class="col-sm-12 text-center">
{% if instance.status == 5 %}
<p>{% trans "Enable Boot Menu for your instance when it starts up " %}
{% if instance.config_bootmenu == 0 %}
<form action="{% url 'instances:set_bootmenu' instance.id %}" method="post" role="form" aria-label="Enable/disable instance boot order form">{% csrf_token %}
<input type="submit" class="btn btn-primary" name="set_bootmenu" title="{% trans 'Show boot menu' %}" value="{% trans "Enable" %}">
</form>
{% else %}
<form action="{% url 'instances:unset_bootmenu' instance.id %}" method="post" role="form" aria-label="Enable/disable instance boot order form">{% csrf_token %}
<input type="submit" class="btn btn-danger" name="unset_bootmenu" title="{% trans 'Hide boot menu' %}" value="{% trans "Disable" %}">
</form>
{% endif %}
{% else %}
{% if instance.config_bootmenu == 0 %}
<p>**** {% trans "Please shutdown instance to modify boot menu" %} ****</p>
{% endif %}
{% endif %}
</div>
</div>
{% if instance.config_bootmenu == 1 %}
<div class="d-flex justify-content-center">
<div class="col-sm-6 bg-light rounded shadow-sm">
{% for idx, val in instance.config_boot_order.items %}
<label>{{ idx|add:1 }}:{{ val.target }}, </label>
{% endfor %}
</div>
</div>
<form action="{% url 'instances:set_bootorder' instance.id %}" method="post" role="form" aria-label="Boot order edit form">{% csrf_token %}
<input id="bootorder" name="bootorder" hidden>
<div class="d-flex justify-content-center">
<div id="b_order" class="list-group me-3">
{% for disk in instance.config_disks %}
<label class="list-group-item"><input class="form-check-input me-2" type="checkbox" name="disk:{{ disk.dev }}" value="disk:{{ disk.dev }}" onclick="set_orderlist($('#bootorder'))">{{ disk.dev }} - {{ disk.image }}</label>
{% endfor %}
{% for cd in instance.config_media %}
<label class="list-group-item"><input class="form-check-input me-2" type="checkbox" name="cdrom:{{ cd.dev }}" value="cdrom:{{ cd.dev }}" onclick="set_orderlist($('#bootorder'))">{{ cd.dev }} - {{ cd.image }}</label>
{% endfor %}
{% for net in instance.config_networks %}
<label class="list-group-item"><input class="form-check-input me-2" type="checkbox" name="network:{{ net.mac }}" value="network:{{ net.mac }}" onclick="set_orderlist($('#bootorder'))">NIC - {{ net.mac|slice:"9:" }}</label>
{% endfor %}
</div>
<div>
<div class="row mt-4">
<a href="#" id="boot_order_up" class="btn btn-light shadow-sm"><span title="{% trans 'up: move selected devices' %}">{% bs_icon 'arrow-up' %} </span></a>
</div>
<div class="row mt-2">
<a href="#" id="boot_order_down" class="btn btn-light shadow-sm"><span title="{% trans 'down: move selected devices' %}">{% bs_icon 'arrow-down' %} </span></a>
</div>
</div>
</div>
<div class="d-flex justify-content-center">
<div class="d-grid col-sm-6">
<input type="submit" class="btn btn-primary" name="set_bootorder" value="{% trans "Apply" %}">
</div>
</div>
</form>
{% endif %}
<div class="clearfix"></div>
</div>
<div role="tabpanel" class="tab-pane" id="disks">
<form action="{% url 'instances:add_cdrom' instance.id %}" method="post" role="form" aria-label="Add CD-ROM form">{% csrf_token %}
<p class="fw-bold">
{% trans "Instance Media" %}
<button class="btn btn-primary float-end"
type="submit"
title="{% trans 'Add CD-ROM' %}"
{% if instance.status != 5 %} disabled {% endif %}>
<span>{% bs_icon 'plus' %} </span>
</button>
</p>
</form>
<div class="clearfix"></div>
{% for cd in instance.media %}
<div class="row mt-2">
<div class="col-sm-12">
{% if not cd.image %}
<form action="{% url 'instances:mount_iso' instance.id %}" method="post">
{% csrf_token %}
<div class="input-group">
<a class="btn btn-secondary"
role="button"
name="details"
title="{% trans 'Details' %}"
tabindex="0"
data-trigger="focus"
data-bs-toggle="popover"
data-bs-html="true"
data-bs-content="<strong>{% trans 'Bus' %}:</strong> {{ cd.bus }} <br/>
<strong>{% trans 'Device' %}:</strong> {{ cd.dev }}">
{% trans "CD-ROM" %} {{ forloop.counter }}
</a>
<select name="media" class="form-select">
{% if instance.media_iso %}
{% for iso in instance.media_iso %}
<option value="{{ iso }}">{{ iso }}</option>
{% endfor %}
{% else %}
<option value="none">{% trans "None" %}</option>
{% endif %}
</select>
{% if instance.media_iso %}
<button type="submit" class="btn btn-sm btn-primary" name="mount_iso" value="{{ cd.dev }}">{% trans "Mount" %}</button>
{% else %}
<button class="btn btn-sm btn-primary disabled" disabled>{% trans "Mount" %}</button>
{% endif %}
{% if instance.status == 5 %}
<button type="submit" class="btn btn-sm btn-danger float-end" formaction="{% url 'instances:detach_cdrom' instance.id cd.dev %}" formmethod="post" title="{% trans "Detach CD-ROM (remove device)" %}">
{% bs_icon 'dash-circle' %}
</button>
{% endif %}
</div>
</form>
{% else %}
<form action="{% url 'instances:unmount_iso' instance.id %}" method="post">
{% csrf_token %}
<div class="input-group">
<a class="btn btn-secondary"
role="button"
name="details"
title="{% trans 'Details' %}"
tabindex="0"
data-trigger="focus"
data-bs-toggle="popover"
data-bs-html="true"
data-bs-content="<strong>{% trans 'Bus' %}:</strong> {{ cd.bus }} <br/>
<strong>{% trans 'Device' %}:</strong> {{ cd.dev }}">
{% trans "CD-ROM" %} {{ forloop.counter }}
</a>
<input type="text" class="form-control" value="{{ cd.image }}" disabled/>
<input type="hidden" name="path" value="{{ cd.path }}">
<button type="submit" class="btn btn-sm btn-primary" value="{{ cd.dev }}" name="umount_iso">{% trans "Unmount" %}</button>
</div>
</form>
{% endif %}
</div>
</div>
{% empty %}
<div class="offset-sm-3 col-sm-6">
<div class="bg-warning rounded shadow-sm">{% trans 'There is not any CD-ROM device.' %}</div>
</div>
{% endfor %}
<div class="clearfix"></div>
<div class="mb-3">
<span class="fw-bold">{% trans "Instance Volume" %}</span>
{% include 'add_instance_volume.html' %}
</div>
<div class="table-responsive">
<table class="table table-hover align-middle">
<thead>
<tr>
<th scope="col">{% trans "Device" %}</th>
<th scope="col">{% trans "Used" %}</th>
<th scope="col">{% trans "Capacity" %}</th>
<th scope="col">{% trans "Storage" %}</th>
<th scope="col">{% trans "Source" %}</th>
<th scope="col">{% trans "Action" %}</th>
</tr>
</thead>
<tbody>
{% for disk in instance.config_disks %}
<tr>
<td>
<button type="submit" class="btn btn-sm btn-secondary"
name="details{{ forloop.counter0 }}"
title="{% trans 'Details' %}"
tabindex="1"
data-trigger="focus"
data-bs-toggle="popover"
data-bs-html="true"
data-bs-content="<strong>{% trans 'Bus' %}:</strong> {{ disk.bus }} <br/>
<strong>{% trans 'Format' %}:</strong> {{ disk.format }} <br/>
<strong>{% trans 'Cache' %}:</strong> {{ disk.cache }} <br/>
<strong>{% trans 'Serial' %}:</strong> {{ disk.serial }} <br/>
<strong>{% trans 'Readonly' %}:</strong> {{ disk.readonly }} <br/>
<strong>{% trans 'Shareable' %}:</strong> {{ disk.shareable }}</br>
<strong>{% trans 'IO Mode' %}:</strong> {{ disk.io }} <br/>
<strong>{% trans 'Discard' %}:</strong> {{ disk.discard }} <br/>
<strong>{% trans 'Detect Zeroes' %}:</strong> {{ disk.detect_zeroes }}">
<span>{% bs_icon 'info' %} </span>
</button>
{{ disk.dev }}
</td>
{% if disk.storage is None %}
<td colspan="4">
<div class="alert alert-danger">
{% trans "Error getting disk info" %}
</div>
</td>
{% else %}
<td>{{ disk.used | filesizeformat}}</td>
<td>{{ disk.size | filesizeformat }}</td>
<td>{{ disk.storage }}</td>
<td>{{ disk.path }}</td>
{% endif %}
<td class="text-nowrap">
<form class="d-inline" action="{% url 'instances:edit_volume' instance.id %}" method="post" role="form" aria-label="Edit instance volume form">
{% csrf_token %}
<input type="hidden" name="path" value="{{ disk.path }}">
<input type="hidden" name="dev" value="{{ disk.dev }}">
<input type="hidden" name="storage" value="{{ disk.storage }}">
<input type="hidden" name="name" value="{{ disk.image }}">
{% include 'instances/edit_instance_volume.html' with id=forloop.counter0 %}
</form>
{% if request.user.is_superuser %}{% include 'instances/move_disk.html' with id=forloop.counter0 %}{% endif %}
<form class="d-inline" action="{% url 'instances:detach_vol' instance.id %}" method="post">
{% csrf_token %}
<input type="hidden" name="path" value="{{ disk.path }}">
<input type="hidden" name="dev" value="{{ disk.dev }}">
<input type="hidden" name="storage" value="{{ disk.storage }}">
<input type="hidden" name="name" value="{{ disk.image }}">
{% if instance.status == 5 %}
<button type="submit" class="btn btn-sm btn-secondary" value="{{ disk.dev }}" title="{% trans "Detach" %}" data-confirm="{% blocktrans with dev=disk.dev %}Detach {{ dev }}? Its file is kept.{% endblocktrans %}" onclick="return confirm(this.dataset.confirm)">
{% bs_icon 'eject' %}
</button>
{% else %}
<button class="btn btn-sm btn-secondary disabled" disabled value="{{ disk.dev }}" title="{% trans "Detach" %}">
{% bs_icon 'eject' %}
</button>
{% endif %}
</form>
<form class="d-inline" action="{% url 'instances:delete_vol' instance.id %}" method="post">
{% csrf_token %}
<input type="hidden" name="path" value="{{ disk.path }}">
<input type="hidden" name="dev" value="{{ disk.dev }}">
<input type="hidden" name="storage" value="{{ disk.storage }}">
<input type="hidden" name="name" value="{{ disk.image }}">
{% if instance.status == 5 %}
<button type="submit" class="btn btn-sm btn-secondary" title="{% trans "Delete" %}" data-confirm="{% blocktrans with dev=disk.dev %}Delete {{ dev }}? It is detached and its file and data are removed.{% endblocktrans %}" onclick="return confirm(this.dataset.confirm)">
{% bs_icon 'trash' %}
</button>
{% else %}
<button class="btn btn-sm btn-secondary disabled" disabled title="{% trans "Delete" %}">
{% bs_icon 'trash' %}
</button>
{% endif %}
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="clearfix"></div>
</div>
<div role="tabpanel" class="tab-pane" id="network">
<div class="mb-3">
{% trans "Add a network device" %}
{% include 'add_instance_network_block.html' %}
</div>
<div class="row mt-3">
<div class="col-lg-12 mt-3">
<h5 class="fw-bold">{% trans "Network Devices" %}</h5>
<div class="table-responsive">
<table align-middle class="table">
<thead>
<tr>
<th scope="col">{% trans 'Name' %}</th>
<th scope="col" class="d-none d-table-cell d-sm-table-cell" colspan="2">{% trans 'Info' %}</th>
<th scope="colgroup" colspan="3" class="col-sm-2">{% trans 'Actions' %}</th>
</tr>
</thead>
<tbody>
{% for network in instance.config_networks %}
<tr>
<td rowspan="2">eth{{ forloop.counter0 }}({{ network.target|default:"no target" }})
<form action="{% url 'instances:set_link_state' instance.id %}" method="post" aria-label="set instance link state form">
{% csrf_token %}
<input name="mac" value="{{ network.mac }}" hidden/>
<input name="set_link_state" value="{{ network.state }}" hidden/>
<input type="checkbox" {% if network.state == 'up' %} checked{% endif %} onclick='submit();' />
<strong>{% trans 'active' %}</strong>
<small>{{ network.type }}</small>
</form>
</td>
<td>
<div class="input-group">
<span class="input-group-text">{% trans 'MAC' %}</span>
<input type="text" class="form-control" value="{{ network.mac }}" aria-label="mac" aria-describedby="mac" readonly>
</div>
</td>
<td class="d-none d-table-cell">
<div class="input-group">
<span class="input-group-text">{% trans 'Filter' %}</span>
<input type="text" class="form-control" value="{{ network.filterref|default:'None' }}" aria-label="filter" aria-describedby="filter" readonly>
</div>
</td>
<td>
<div class="input-group">
<span class="input-group-text">{% trans 'Source' %}</span>
<input type="text" class="form-control" value="{{ network.nic }}" aria-label="source" aria-describedby="source" readonly>
</div>
</td>
<td>
{# a NIC that is a host device is changed in the XML editor #}
{% if network.type != "hostdev" %}
<form action="{% url 'instances:change_network' instance.id %}" method="post" name="edit_network{{ forloop.counter0 }}" role="form">{% csrf_token %}
<button class="btn btn-sm btn-primary"
type="button"
title="{% trans "Edit NIC" %}"
data-bs-target="#editInstanceNetwork{{ forloop.counter0 }}"
data-bs-toggle="modal">
<span aria-hidden="true">{% bs_icon 'pencil-square' %} </span>
</button>
<div class="modal fade" id="editInstanceNetwork{{ forloop.counter0 }}" role="dialog" aria-labelledby="editInstanceNetworkLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{% trans "Edit Instance Network" %}</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="container">
<div class="row">
<label class="col-form-label">{% trans "MAC" %}</label>
<div class="input-group">
<input class="form-control" type="text" name="net-old-mac-{{ forloop.counter0 }}" value="{{ network.mac }}" readonly/>
<input class="form-control" type="text" name="net-mac-{{ forloop.counter0 }}" value="{{ network.mac }}"/>
</div>
</div>
<div class="row">
<label class="col-form-label">{% trans "Net Source" %}</label>
<div class="input-group">
<input class="form-control" type="text" value="{{ network.nic }}" readonly/>
<select class="form-select" name="net-source-{{ forloop.counter0 }}">
{% for c_net in networks_host %}
<option value="net:{{ c_net }}" {% if c_net == network.nic %} selected {% endif %}>{% trans 'Network' %} {{ c_net }}</option>
{% endfor %}
{% for c_iface in interfaces_host %}
<option value="iface:{{ c_iface }}" {% if c_iface == network.nic %} selected {% endif %}>{% trans 'Interface' %} {{ c_iface }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="row">
<label class="col-form-label">{% trans "NWFilter" %}</label>
<div class="input-group">
<input class="form-control" type="text" value="{{ network.filterref }}" readonly/>
<select class="form-select" name="net-nwfilter-{{ forloop.counter0 }}">
<option value="">{% trans "None" %}</option>
{% for c_filters in nwfilters_host %}
<option value="{{ c_filters }}" {% if c_filters == network.filterref %} selected {% endif %}>{{ c_filters }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="row">
<label class="col-form-label">{% trans "Model" %} </label>
<div class="input-group">
<input class="form-control" type="text" value="{{ network.model }}" readonly/>
<select class="form-select" name="net-model-{{ forloop.counter0 }}">
{% for model in net_models_host %}
<option value="{{ model }}" {% if model == network.model %} selected {% endif %}>{{ model }}</option>
{% endfor %}
</select>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" type="button" data-bs-dismiss="modal">{% trans 'Close' %}</button>
<button class="btn btn-primary" name="change_network" title="{% trans "Apply network changes" %}">{% trans "Apply" %}</button>
</div>
</div>
</div>
</div>
</form>
{% endif %}
</td>
<td>
<form action="{% url 'instances:set_qos' instance.id %}" method="post" name="add_qos{{ forloop.counter0 }}" role="form" aria-label="Add network qos form">
{% csrf_token %}
<input type="text" name="net-mac-{{ forloop.counter0 }}" value="{{ network.mac }}" hidden/>
{% include 'add_network_qos.html' with id=forloop.counter0 %}
</form>
</td>
<td>
{% if network.type != "hostdev" %}
<form action="{% url 'instances:delete_network' instance.id %}" method="post" name="delete_network" role="form">{% csrf_token %}
<button class="btn btn-sm btn-danger" value="{{ network.mac }}" name="delete_network" title="{% trans "Delete Device" %}"
data-confirm="{% blocktrans with mac=network.mac %}Remove network card {{ mac }}? A running VM loses its connection through it at once.{% endblocktrans %}" onclick="return confirm(this.dataset.confirm)">
{% bs_icon 'trash' %}
</button>
</form>
{% endif %}
</td>
</tr>
<tr>
<td>
<div class="input-group">
<span class="input-group-text">{% trans 'IPv4' %}</span>
<input type="text" class="form-control" value="{% for ipv4 in network.ipv4|default:'unknown' %}{{ ipv4 }}{% endfor %}" aria-label="ipv4" aria-describedby="ipv4" readonly>
</div>
</td>
<td>
<div class="input-group">
<span class="input-group-text">{% trans 'IPv6' %}</span>
<input type="text" class="form-control" value="{% for ipv6 in network.ipv6|default:'unknown' %}{{ ipv6 }}{% endfor %}" aria-label="ipv6" aria-describedby="ipv6" readonly>
</div>
</td>
<td colspan="3">
<div class="input-group">
<span class="input-group-text px-2">{% trans 'Model' %}</span>
<input type="text" class="form-control px-2" value="{{ network.model }}" aria-label="model" aria-describedby="model" readonly>
</div>
</td>
</tr>
<tr>
<td class="py-1 bg-primary text-white" colspan="9">
{% if network.type == 'direct' %}
<small>{% trans 'In most configurations, macvtap does not work for host to guest network communication' %}</small>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% if instance.config_qos %}
<div class="row mt-3">
<div class="col-sm-10">
<p><strong>{% trans "QoS Configuration" %}</strong></p>
</div>
<div class="col-12 col-sm-12">
<div class="table-responsive">
<table class="table table-hover align-middle">
<thead>
<tr class="d-flex">
<th scope="col" class="col-2">{% trans "MAC" %}/{% trans "Direction" %}</th>
<th scope="col" class="col-2">{% trans "Average" %}</th>
<th scope="col" class="col-3">{% trans "Peak" %}</th>
<th scope="col" class="col-3">{% trans "Burst" %}</th>
<th scope="col" class="col-2">{% trans "Actions" %}</th>
</tr>
</thead>
<tbody>
{% for q, attrs in instance.config_qos.items %}
{% for att in attrs %}
<tr class="d-flex">
<form action="{% url 'instances:set_qos' instance.id %}" method="post" role="form" aria-label="Instance QoS configuration form">
{% csrf_token %}
<td class="col-2"><label class="col-form-label">{{ q }} {{ att.direction | capfirst }}</label></td>
<td class="col-2"><input id="qos_average" class="form-control" name="qos_average"
value="{{ att.average|default:'' }}"/>
</td>
<td class="col-3"><input id="qos_peak" class="form-control" name="qos_peak"
value="{{ att.peak|default:'' }}"/>
</td>
<td class="col-3"><input id="qos_burst" class="form-control" name="qos_burst"
value="{{ att.burst|default:'' }}"/>
</td>
<td class="col-sm-2">
<input name="qos_direction" value="{{ att.direction }}" hidden/>
<input name="net-mac" value="{{ q }}" hidden/>
<button type="submit" class="btn btn-sm btn-primary"
name="set_qos" data-bs-toggle="modal"
title="{% trans "Edit QoS" %}">
<span>{% bs_icon 'save' %} </span>
</button>
</form>
<form action="{% url 'instances:unset_qos' instance.id %}" method="post" role="form" aria-label="Instance QoS configuration form">
{% csrf_token %}
<input name="qos_direction" value="{{ att.direction }}" hidden/>
<input name="net-mac" value="{{ q }}" hidden/>
<button type="submit" class="btn btn-sm btn-danger"
name="unset_qos"
title="{% trans "Delete QoS" %}" data-confirm="{% blocktrans with direction=att.direction mac=q %}Remove the {{ direction }} limit of {{ mac }}? A running VM keeps it until it is powered off and on.{% endblocktrans %}" onclick="return confirm(this.dataset.confirm)">
{% bs_icon 'trash' %}
</button>
</form>
</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endif %}
<div class="clearfix"></div>
</div>
{% if show_hostdevs %}
<div role="tabpanel" class="tab-pane" id="hostdevs">
<p class="small text-body-secondary">{% trans "Devices of the host given to the VM. The VM starts only on a host that has them; it is not migrated while it has them, and its clones get none." %}</p>
{% if request.user.is_superuser %}
{# the add forms come when the tab opens: their choices scan every VM of the host #}
<div id="host-devices" class="mb-3" data-url="{% url 'instances:host_devices' instance.id %}">
<span class="small text-body-secondary">{% trans "Reading the host's devices…" %}</span>
</div>
{% endif %}
{% if usb_hostdevs %}
<div class="table-responsive position-relative">
<table class="table align-middle">
<thead>
<tr>
<th scope="col">{% trans "USB device" %}</th>
<th scope="col">{% trans "Chosen by" %}</th>
<th scope="col">{% trans "Running VM" %}</th>
<th scope="col">{% trans "Next start" %}</th>
{% if request.user.is_superuser %}<th scope="col"><span class="visually-hidden">{% trans "Actions" %}</span></th>{% endif %}
</tr>
</thead>
<tbody>
{% for device in usb_hostdevs %}
<tr>
<td>{{ device.name|default:"–" }} <span class="small text-body-secondary font-monospace">{{ device.vendor|slice:"2:" }}:{{ device.product|slice:"2:" }}</span></td>
<td>{% if device.address %}{% blocktrans with bus=device.address.0 device=device.address.1 %}Its address {{ bus }}/{{ device }}{% endblocktrans %}{% else %}{% trans "Its model: any device of it" %}{% endif %}</td>
<td>{% if device.now %}{% blocktrans with bus=device.now.0 device=device.now.1 %}Has {{ bus }}/{{ device }}{% endblocktrans %}{% else %}–{% endif %}</td>
<td>{% if device.next %}{% trans "Yes" %}{% else %}{% trans "No" %}{% endif %}</td>
{% if request.user.is_superuser %}
<td class="text-end">
<form method="post" action="{% url 'instances:delete_usb_hostdev' instance.id %}">{% csrf_token %}
<input type="hidden" name="vendor" value="{{ device.vendor }}">
<input type="hidden" name="product" value="{{ device.product }}">
<input type="hidden" name="address" value="{% if device.address %}{{ device.address.0 }}/{{ device.address.1 }}{% endif %}">
<button type="submit" class="btn btn-sm btn-outline-danger" aria-label="{% trans "Remove the USB device" %}"
data-confirm="{% trans "Remove this USB device from the VM? A running VM loses it at once." %}"
onclick="return confirm(this.dataset.confirm)">{% bs_icon 'trash' %}</button>
</form>
</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
{% if pci_hostdevs %}
<div class="table-responsive position-relative">
<table class="table align-middle">
<thead>
<tr>
<th scope="col">{% trans "PCI device" %}</th>
<th scope="col">{% trans "Running VM" %}</th>
<th scope="col">{% trans "Next start" %}</th>
{% if request.user.is_superuser %}<th scope="col"><span class="visually-hidden">{% trans "Actions" %}</span></th>{% endif %}
</tr>
</thead>
<tbody>
{% for device in pci_hostdevs %}
<tr>
<td>{{ device.name|default:"–" }} <span class="small text-body-secondary font-monospace">{{ device.address }}</span></td>
<td>{% if device.now %}{% trans "Has it" %}{% else %}–{% endif %}</td>
<td>{% if device.next %}{% trans "Yes" %}{% else %}{% trans "No" %}{% endif %}</td>
{% if request.user.is_superuser %}
<td class="text-end">
<form method="post" action="{% url 'instances:delete_pci_hostdev' instance.id %}">{% csrf_token %}
<input type="hidden" name="address" value="{{ device.address }}">
<button type="submit" class="btn btn-sm btn-outline-danger" aria-label="{% trans "Remove the PCI device" %}"
{% if instance.status != 1 and instance.status != 5 or instance.has_managed_save_image %}disabled title="{% trans "A paused VM, or one with a saved state, does not change its PCI devices" %}"{% endif %}
data-confirm="{% trans "Remove this PCI device from the VM? A running VM's guest has to let it go." %}" onclick="return confirm(this.dataset.confirm)">{% bs_icon 'trash' %}</button>
</form>
</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
{% for device in other_hostdevs %}
<p class="mb-1">
{% if device.type == "nic" %}{% trans "Network interface" %}{% else %}{{ device.type|upper }}{% endif %} <span class="font-monospace">{{ device.address }}</span>
<span class="small text-body-secondary">{% if device.now and device.next %}{% trans "running VM and next start" %}{% elif device.now %}{% trans "running VM only" %}{% else %}{% trans "next start only" %}{% endif %}; {% trans "changed in the XML editor" %}</span>
</p>
{% endfor %}
{% if not usb_hostdevs and not pci_hostdevs and not other_hostdevs %}
<p class="small text-body-secondary mb-0">{% trans "The VM has no host devices." %}</p>
{% endif %}
</div>
{% endif %}
<div role="tabpanel" class="tab-pane" id="migrate">
<p>{% trans "For migration both host servers must have equal settings and OS type" %}</p>
<form action="{% url 'instances:migrate' instance.id %}" class="ms-3 form" method="post" role="form" aria-label="Migrate instance form">
{% csrf_token %}{% submission_key %}
<div class="row">
<label class="col-sm-3 col-form-label">{% trans "Original host" %}</label>
<div class="col-sm-6">
<label class="form-control" readonly="readonly">{{ compute.name }}</label>
</div>
</div>
<div class="row">
<label class="col-sm-3 col-form-label">{% trans "Host migration" %}</label>
<div class="col-sm-6">
<select name="compute_id" class="form-select" id="migrate_compute">
{% if computes_count != 1 %}
{% for comp in computes %}
{% if comp.id != compute.id %}
<option value="{{ comp.id }}">{{ comp.name }}</option>
{% endif %}
{% endfor %}
{% endif %}
</select>
</div>
</div>
<div class="row">
<label class="col-sm-3 col-form-label">{% trans "Disks" %}</label>
<div class="col-sm-9 py-2" id="migrate-plan" data-url="{% url 'instances:migrate_plan' instance.id %}" aria-live="polite"></div>
</div>
<div class="row">
<div class="col-sm-6 offset-sm-3">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" name="live_migrate" value="true" id="vm_live_migrate" {% if instance.status != 5 %}checked{% else %}disabled{% endif %}>
<label class="form-check-label" for="vm_live_migrate">{% trans "Live migration" %}</label>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6 offset-sm-3">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" name="unsafe_migrate" value="true" id="vm_unsafe_migrate">
<label class="form-check-label" for="vm_unsafe_migrate">{% trans "Unsafe migration" %}</label>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6 offset-sm-3">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" name="offline_migrate" value="true" id="offline_migrate" {% if instance.status == 5 %}checked{% else %}disabled{% endif %}>
<label class="form-check-label" for="offline_migrate">{% trans "Offline migration" %}</label>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6 offset-sm-3">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" name="autoconverge" value="true" id="autoconverge" {% if instance.status != 1 %}disabled{% else %}checked{% endif %}>
<label class="form-check-label" for="autoconverge" title="{% trans 'Forces CPU convergence during live migration' %}">{% trans "Auto converge" %}</label>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6 offset-sm-3">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" name="compress" value="true" id="compress" {% if instance.status != 1 %}disabled{% endif %}>
<label class="form-check-label" for="compress" title="{% trans 'Compress instance memory for fast migration' %}">{% trans "Compressed" %}</label>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6 offset-sm-3">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" name="delete_source" value="true" id="delete_source">
<label class="form-check-label" for="delete_source">{% trans "Delete the source files of copied disks" %}</label>
</div>
</div>
</div>
{% if computes_count != 1 %}
<button type="submit" class="btn btn-primary float-end" name="migrate" >{% trans "Migrate" %}</button>
{% else %}
<button class="btn btn-primary float-end disabled" disabled>{% trans "Migrate" %}</button>
{% endif %}
</form>
<div class="clearfix"></div>
</div>
<div role="tabpanel" class="tab-pane" id="xmledit">
{% if instance.status != 5 %}
<p id="xml-next-start">{% trans "This is the definition for the VM's next start; a saved change applies then." %}</p>
{% endif %}
<form action="{% url 'instances:change_xml' instance.id %}" method="post" role="form" aria-label="Edit instance XML form" id="xml-form">
{% csrf_token %}
<div class="col-sm-12 xmlheight">
<textarea id="editor">{{ instance.inst_xml }}</textarea>
</div>
<button type="submit" class="btn btn-primary float-end" name="change_xml">
{% trans "Change" %}
</button>
</form>
<div class="clearfix"></div>
<div class="modal fade" id="xml-review" tabindex="-1" aria-labelledby="xml-review-title" aria-hidden="true"
data-failed="{% trans "The request did not go through; your edit is still in the editor. Try again, or copy it and reload the page." %}">
<div class="modal-dialog modal-xl modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="xml-review-title">{% trans "Review the XML change" %}</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="{% trans "Close" %}"></button>
</div>
<div class="modal-body">
<div class="alert alert-danger d-none" role="alert" id="xml-review-error"></div>
<p class="d-none" id="xml-review-same">{% trans "The XML is the same as the VM's definition; there is nothing to save." %}</p>
<pre class="d-none mb-0" id="xml-review-diff"></pre>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{% trans "Cancel" %}</button>
<button type="button" class="btn btn-primary" id="xml-review-save">{% trans "Save" %}</button>
</div>
</div>
</div>
</div>
</div>
<div role="tabpanel" class="tab-pane" id="users">
<div>
<div class="mb-3">
<span class="fw-bold">{% trans "Instance owners" %}</span>
{% include 'add_instance_owner_block.html' %}
</div>
</div>
<div class="table-responsive">
<table class="table table-striped mt-3 align-middle">
<tbody class="searchable">
{% for userinstance in userinstances %}
<tr>
<td><a href="{% url 'accounts:account' userinstance.user.id %}">{{ userinstance.user }}</a></td>
<td style="width:30px;">
<a href="{% url 'accounts:user_instance_delete' userinstance.id %}?next={% url 'instances:instance' instance.id %}#users">
{% bs_icon 'trash' %}
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="clearfix"></div>
</div>
{% endif %}
{% if can_manage_console %}
<div role="tabpanel" class="tab-pane" id="vncsettings">
<form method="post" action="{% url 'instances:update_console' instance.id %}">
{% csrf_token %}
{% if instance.status != 5 %}
<div class="alert alert-warning">
{% trans "To change console settings, shutdown the instance." %}
</div>
{% endif %}
{% bootstrap_form console_form layout='horizontal' %}
<div class="float-end">
{% if instance.status != 5 %}
<button class="btn btn-primary" disabled>{% trans "Update" %}</button>
{% else %}
<button type="submit" class="btn btn-primary ">{% trans "Update" %}</button>
{% endif %}
</div>
</form>
<div class="clearfix"></div>
</div>
{% endif %}
{% if can_clone %}
<div role="tabpanel" class="tab-pane" id="clone">
<p class="fw-bold">{% trans "Create a clone" %}</p>
{% if usb_hostdevs or pci_hostdevs or other_hostdevs %}<p class="small text-body-secondary">{% trans "The clone gets none of the VM's host devices: one VM holds a device of the host." %}</p>{% endif %}
<form class="form" action="{% url 'instances:clone' instance.id %}" method="post" role="form" aria-label="Create clone form">{% csrf_token %}{% submission_key %}
<div class="row">
<label class="col-sm-3 col-form-label fw-normal">{% trans "Clone Name" %}</label>
{% if request.user.is_superuser %}
<div class="col-sm-6">
<div class="input-group">
<input id="clone_name" type="text" class="form-control" name="name" value="{{ instance.name }}-clone">
<button type="button" class="btn btn-primary" name="guess-clone-name"
onclick="guess_clone_name()">{% trans "Guess" %}</button>
</div>
</div>
{% elif app_settings.CLONE_INSTANCE_AUTO_NAME == 'True'%}
<div class="col-sm-4">
<input id="clone_instance_auto_name" type="text" class="form-control" name="auto_name" value="Automatic" disabled/>
</div>
{% else %}
<div class="col-sm-4">
<select id="select_clone_name" class="form-control" name="name" size="1">
{% for name in clone_free_names %}
<option value="{{ name }}">{{ name }}</option>
{% endfor %}
</select>
</div>
{% endif %}
</div>
{% if request.user.is_superuser %}
<label>{% trans "Network devices" %}:</label>
{% for network in instance.config_networks %}
<div class="mb-3">
<div class="row">
<label class="col-sm-2 col-form-label offset-sm-1">eth{{ forloop.counter0 }} ({{ network.nic }})</label>
<div class="col-sm-6">
<div class="input-group">
<input type="text" class="form-control" name="clone-net-mac-{{ forloop.counter0 }}" value="{{ network.mac }}"/>
<button type="button" class="btn btn-primary" name="random-mac-{{ forloop.counter0 }}"
onclick="random_mac('clone-net-mac-{{ forloop.counter0 }}')">{% trans "Random" %}</button>
<button type="button" class="btn btn-primary" name="guess-mac-{{ forloop.counter0 }}"
onclick="guess_mac_address('#clone_name', {{ forloop.counter0 }})">{% trans "Guess" %}</button>
</div>
</div>
</div>
</div>
{% endfor %}
{% else %}
{% for network in instance.config_networks %}
<input type="hidden" class="form-control" name="clone-net-mac-{{ forloop.counter0 }}" value="{{ network.mac }}"/>
{% endfor %}
{% endif %}
{% if request.user.is_superuser %}
<label>{% trans "Storage devices" %}:</label>
{% for disk in instance.config_disks %}
<div class="row">
<label class="col-sm-2 col-form-label offset-sm-1">{{ disk.dev }} ({{ disk.storage }})</label>
<div class="col-sm-6">
<div class="input-group mb-3">
<input id="disk_name-{{ disk.dev }}" type="text" class="form-control" name="disk-{{ disk.dev }}" value="{{ disk.image }}"/>
{% if disk.format == 'qcow2' %}
<span class="input-group-text" >{% trans 'Metadata' %}</span>
<div class="input-group-text">
<input type="checkbox" name="meta-{{ disk.dev }}" value="true">
</div>
{% endif %}
</div>
</div>
</div>
{% endfor %}
{% else %}
{% for disk in instance.disks %}
<input id="disk_name-{{ disk.dev }}" type="hidden" class="form-control" name="disk-{{ disk.dev }}" value="{{ disk.image }}"/>
{% endfor %}
{% endif %}
<div class="row mb-3">
<label class="col-sm-3 col-form-label">{% trans "Title" %}</label>
<div class="col-sm-6">
<input type="text" name="clone-title" class="form-control">
</div>
</div>
<div class="row">
<label class="col-sm-3 col-form-label">{% trans "Description" %}</label>
<div class="col-sm-6">
<textarea name="clone-description" class="form-control"></textarea>
</div>
</div>
{% if instance.status == 1 or instance.status == 3 or instance.status == 5 %}
<button type="submit" class="btn btn-primary float-end" name="clone">{% trans "Clone" %}</button>
{% else %}
<button class="btn btn-primary float-end disabled" disabled name="clone">{% trans "Clone" %}</button>
{% endif %}
</form>
<div class="clearfix"></div>
</div>
{% 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>
</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 %}
</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>
</div>
</div>
</div>
</form>
{% endif %}
<div class="clearfix"></div>
</div>
{% endif %}
</div>
</div>
</div>