1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-10-31 19:44:16 +00:00

experimental: external snapshot fixes 2

This commit is contained in:
catborise 2023-04-14 16:11:13 +03:00
parent 06994b0423
commit f4aa925e2a
2 changed files with 5 additions and 1 deletions

View file

@ -1056,10 +1056,13 @@ def revert_external_snapshot(request, pk):
if allow_admin_or_not_template and request.user.has_perm( if allow_admin_or_not_template and request.user.has_perm(
"instances.snapshot_instances" "instances.snapshot_instances"
): ):
instance_state = True if instance.proxy.get_status() != 5 else False
name = request.POST.get("name", "") name = request.POST.get("name", "")
date = request.POST.get("date", "") date = request.POST.get("date", "")
desc = request.POST.get("desc", "") desc = request.POST.get("desc", "")
instance.proxy.revert_external_snapshot(name, instance, date, desc) instance.proxy.force_shutdown() if instance_state else None
instance.proxy.revert_external_snapshot(name, date, desc)
instance.proxy.start() if instance_state else None
msg = _("Revert external snapshot: %(snap)s") % {"snap": name} msg = _("Revert external snapshot: %(snap)s") % {"snap": name}
addlogmsg(request.user.username, instance.compute.name, instance.name, msg) addlogmsg(request.user.username, instance.compute.name, instance.name, msg)
return redirect(request.META.get("HTTP_REFERER") + "#managesnapshot") return redirect(request.META.get("HTTP_REFERER") + "#managesnapshot")

View file

@ -1335,6 +1335,7 @@ class wvmInstance(wvmConnect):
info = self.instance.blockJobInfo(target_dev, 0) info = self.instance.blockJobInfo(target_dev, 0)
if info.get('cur') == info.get('end'): if info.get('cur') == info.get('end'):
self.instance.blockJobAbort(target_dev,flags=VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT) self.instance.blockJobAbort(target_dev,flags=VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT)
time.sleep(2)
break break
# Check again pool for snapshot delta volume; if it exist, remove it manually # Check again pool for snapshot delta volume; if it exist, remove it manually
with contextlib.suppress(libvirtError): with contextlib.suppress(libvirtError):