1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-11 04:36:48 +00:00

feat(storages): volume clone runs as a job

This commit is contained in:
catborise 2026-10-14 23:34:21 +03:00
parent bb91c13926
commit 49232c6e1d
10 changed files with 178 additions and 42 deletions

View file

@ -40,6 +40,14 @@ def instance_key(uuid):
return f"instance:{uuid}"
def pool_key(compute_id, pool):
return f"pool:{compute_id}:{pool}"
def volume_key(compute_id, pool, name):
return f"volume:{compute_id}:{pool}/{name}"
def quota_key(user_id):
return f"quota:user:{user_id}"

View file

@ -0,0 +1,9 @@
{% load static %}
<script src="{% static 'operations/job_panel.js' %}"></script>
<script>
jobPanel(document.getElementById("job-panel"), {
resource: "{% url 'operation-resource' %}?key={{ resource|urlencode:'' }}",
job: function (id) { return "{% url 'operation-list' %}" + id + "/"; },
cancel: function (id) { return "{% url 'operation-list' %}" + id + "/cancel/"; },
}, "{{ csrf_token }}", {{ remembered|safe }});
</script>

View file

@ -1,3 +1,4 @@
import json
import uuid
from django import template
@ -5,6 +6,7 @@ from django.utils.html import format_html, format_html_join
from django.utils.safestring import mark_safe
from django.utils.translation import pgettext_lazy
from operations.jobs import take_remembered
from operations.models import Operation
register = template.Library()
@ -53,3 +55,10 @@ def state_label(state):
def wrap_at_slash(label):
"""A "<compute>/<vm>" label that wraps after its slash only, never inside a name."""
return format_html_join(mark_safe("/<wbr>"), '<span class="text-nowrap">{}</span>', ((part,) for part in label.split("/")))
@register.inclusion_tag("operations/job_panel_script.html", takes_context=True)
def job_panel_script(context, resource):
"""The job panel's script for the page of resource."""
return {"resource": resource, "csrf_token": context.get("csrf_token"),
"remembered": json.dumps(take_remembered(context["request"], resource))}