diff --git a/instances/models.py b/instances/models.py index 2c8ae0ce..91370ce9 100644 --- a/instances/models.py +++ b/instances/models.py @@ -296,12 +296,20 @@ class Instance(models.Model): return self.proxy.get_video_models(self.arch, self.machine) def _snapshots(self, flag): - return sorted(self.proxy.get_snapshot(flag), reverse=True, key=lambda k: k["date"]) + external = flag == VIR_DOMAIN_SNAPSHOT_LIST_EXTERNAL + return sorted(({**snap, "external": external} for snap in self.proxy.get_snapshot(flag)), + reverse=True, key=lambda k: k["date"]) @cached_property def snapshots(self) -> list[dict]: + """Both kinds, the newest first; "external" tells them apart.""" return sorted(self.internal_snapshots + self.external_snapshots, reverse=True, key=lambda k: k["date"]) + @cached_property + def newer_than_current_snapshot(self) -> bool: + """Snapshots newer than the one reverted to: an external snapshot waits until they are deleted.""" + return any(snap["current"] and snap["children"] for snap in self.external_snapshots) + @cached_property def internal_snapshots(self) -> list[dict]: return self._snapshots(VIR_DOMAIN_SNAPSHOT_LIST_INTERNAL) diff --git a/instances/templates/instances/snapshots_tab.html b/instances/templates/instances/snapshots_tab.html index 46e28f68..f9a22e1f 100755 --- a/instances/templates/instances/snapshots_tab.html +++ b/instances/templates/instances/snapshots_tab.html @@ -1,196 +1,124 @@ {% load i18n %} {% load tz %} {% get_current_timezone as TIME_ZONE %} -{% load bootstrap_icons %} {% load operations %} +{% load vm_states %}
{% trans "With running machine, internal snapshots may take more than an hour, depending on how much memory has on your instance and how large the disk is." %}
-{% trans "The VM is paused while its memory is saved." %}
- {% else %} -{% trans "Create an internal snapshot" %}
+{% trans "Snapshots" %} · {{ state.0 }}
+ {% if busy %} +