diff --git a/computes/templates/computes/instances.html b/computes/templates/computes/instances.html index 79b2edc6..c4f8faa2 100644 --- a/computes/templates/computes/instances.html +++ b/computes/templates/computes/instances.html @@ -7,96 +7,31 @@ {% block page_heading %}{{ compute.name }} - {% trans "Instances" %}{% endblock page_heading %} {% block page_heading_extra %} + +{% if instances %} +{% trans "Bulk Migrate" %} +{% endif %} {% if compute.maintenance %} {# a disabled button shows no title: its wrapper says why #} - - + + {% else %} - - {% bs_icon 'plus-circle-fill' %} - -{% endif %} -{% if instances %} -{% trans "Bulk Migrate" %} - {% include 'search_block.html' %} +{% bs_icon 'plus-lg' %} {% trans "New VM" %} {% endif %} {% endblock page_heading_extra %} {% block content %}
-
-
- {% include "computes/host_nav.html" with section="instances" %} +{% include "computes/host_nav.html" with section="instances" %} +{% if compute.status is not True %} +
+ {% blocktrans with name=compute.name error=compute.connection_error %}Problem occurred with host {{ name }}: {{ error }}{% endblocktrans %}
-
-
-
- {% if compute.status is not True %} -
- {% blocktrans with name=compute.name error=compute.connection_error %}Problem occurred with host {{ name }}: {{ error }}{% endblocktrans %} -
- {% endif %} - {% if not instances %} - {% if compute.status is True %} -
- {% bs_icon 'exclamation-triangle' %} {% trans "Warning" %}: - {% trans "Hypervisor doesn't have any Instances" %} -
- {% endif %} - {% else %} -
- - - - - - - - - - - - - {% for instance in instances %} - - - - - - - - - {% endfor %} - -
{% trans 'Name' %}
{% trans 'Description' %}
{% trans 'User' %}{% trans 'Status' %}{% trans 'VCPU' %}{% trans 'Memory' %}{% trans 'Actions' %}
- {{ instance.name }} -
- {% if instance.info %}

{{ instance.title }}

{% endif %} - {% with tags=instance.tags.all %}{% include 'common/tag_badges.html' with tags=tags|slice:":3" more=tags|slice:"3:" %}{% endwith %} -
- - {% if instance.userinstance_set.all.count > 0 %} - {{ instance.userinstance_set.all.0.user }} - {% if instance.userinstance_set.all.count > 1 %} - (+{{ instance.userinstance_set.all.count|add:"-1" }}) - {% endif %} - {% endif %} - - - {% include 'instance_state.html' %} - {{ instance.info.3 }}

{% if instance.info %}{% widthratio instance.info.2 1024 1 %} MiB{% endif %}

- {% include 'instance_actions.html' %} -
-
- {% endif %} -
-
+{% endif %} +{% include 'instances/vm_list.html' %} {% endblock %} {% block script %} - +{% include 'instances/vm_list_scripts.html' %} {% job_panel_script job_resource %} -{% include "instances/vm_states_poll.html" %} - -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/computes/tests/test_maintenance.py b/computes/tests/test_maintenance.py index a04d2ec9..feb2bf6b 100644 --- a/computes/tests/test_maintenance.py +++ b/computes/tests/test_maintenance.py @@ -74,7 +74,7 @@ class MaintenanceSwitchTests(TestCase): self.compute.maintenance_since = timezone.now() self.compute.save() self.assertFalse(page().xpath("//a[@href=$u]", u=create)) - self.assertTrue(page().xpath("//button[@disabled][contains(@aria-label, 'New Instance')]")) + self.assertTrue(page().xpath("//button[@disabled][contains(., 'New VM')]")) class MaintenanceGuardTests(TestCase): diff --git a/computes/views.py b/computes/views.py index ba6fa53e..ddc10e78 100644 --- a/computes/views.py +++ b/computes/views.py @@ -24,6 +24,7 @@ from django.views.decorators.http import require_POST from webvirtcloud.middleware import error_text from instances.models import Instance from instances.utils import read_list_rows, vm_states +from instances.views import vm_list_context from libvirt import libvirtError from logs.audit import audit, changed_fields, snapshot from operations import claims, jobs @@ -367,13 +368,13 @@ def instances(request, compute_id): # read first: the poll's first answer then tells a change made while the page was read states = vm_states(request.user, [compute]) utils.refresh_instance_database(compute) - instances = list(Instance.objects.filter(compute=compute).order_by("name").prefetch_related("userinstance_set", "tags")) + instances = list(Instance.objects.filter(compute=compute).order_by("name").prefetch_related("userinstance_set__user", "tags")) read_list_rows(instances, [compute]) - + # the VM list's own list, of this host's VMs return render( request, "computes/instances.html", - {"compute": compute, "instances": instances, "job_resource": claims.compute_key(compute.id), - "states_url": reverse("instances:states") + f"?compute={compute.id}", "vm_states": states}, + {"compute": compute, "one_host": compute, "show_hosts": True, "job_resource": claims.compute_key(compute.id), + **vm_list_context(request, instances, reverse("instances:states") + f"?compute={compute.id}", states)}, ) diff --git a/instances/templates/allinstances.html b/instances/templates/allinstances.html index 993c7090..08ec0b50 100644 --- a/instances/templates/allinstances.html +++ b/instances/templates/allinstances.html @@ -40,86 +40,7 @@
{% endif %}
- {% if instances %} - {# the state filter: table_filter.js counts each state's VMs the search finds #} - - - {% include 'common/tag_filter.html' %} - {% if powerable %} - {# the VMs chosen in the list (bulk_power_box.html), a job each (instances.jobs.POWER); bulk_power.js counts those on screen #} - {# and shows this bar at the foot of the window while any is chosen #} - - {% endif %} -
- {% endif %} - {% if not instances %} -

{% trans "There are no VMs here yet." %}

- {% elif app_settings.VIEW_INSTANCES_LIST_STYLE == 'grouped' and request.user.is_superuser %} - {% include 'allinstances_index_grouped.html' %} - {% else %} - {% include 'allinstances_index_nongrouped.html' %} - {% endif %} - {% if instances %} - {# table_filter.js shows it while no row matches #} - - {% endif %} + {% include 'instances/vm_list.html' %}