mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
fix(instances): do not refuse clones for volume-less disks or unusual names
Clone refused VMs that cloned fine before: a disk without a volume got a None disk name, and a source image with characters such as a space or "@" produced a derived name outside the allowed pattern. Disks without a volume (which clone_instance does not copy) are no longer validated, and derived disk names are sanitized to the allowed charset. Names typed by a superuser are still validated strictly.
This commit is contained in:
parent
e4aa4f2372
commit
e626da5002
3 changed files with 29 additions and 2 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import os
|
||||
import random
|
||||
import re
|
||||
import string
|
||||
|
||||
from accounts.models import UserInstance, UserAttributes
|
||||
|
|
@ -263,7 +264,9 @@ def get_clone_disk_name(disk, prefix, clone_name=""):
|
|||
image = f"{name}-clone.{suffix}"
|
||||
else:
|
||||
image = f"{disk['image']}-clone"
|
||||
return image
|
||||
# Derived names go into volume XML and paths: keep them to a safe charset.
|
||||
image = re.sub(r"[^A-Za-z0-9_.+-]+", "-", image).lstrip("_.+-")
|
||||
return image or None
|
||||
|
||||
|
||||
def can_manage_console(user, instance):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue