mirror of
https://github.com/retspen/webvirtcloud
synced 2025-07-31 12:41:08 +00:00
The storage pool path should be allowed to contain '-' and '_'
Signed-off-by: herengui <herengui@uniontech.com>
This commit is contained in:
parent
7db75784c6
commit
fea1571e1a
3 changed files with 54 additions and 93 deletions
|
|
@ -135,10 +135,7 @@ class VolumeViewSet(viewsets.ViewSet):
|
|||
)
|
||||
state = conn.is_active()
|
||||
|
||||
if state:
|
||||
volume_queryset = conn.get_volume_details(pk)
|
||||
else:
|
||||
volume_queryset = None
|
||||
volume_queryset = conn.get_volume_details(pk) if state else None
|
||||
conn.close()
|
||||
serializer = VolumeSerializer(
|
||||
volume_queryset, many=False, context={"request": request}
|
||||
|
|
|
|||
|
|
@ -38,22 +38,22 @@ class AddStgPool(forms.Form):
|
|||
def clean_target(self):
|
||||
storage_type = self.cleaned_data["stg_type"]
|
||||
target = self.cleaned_data["target"]
|
||||
have_symbol = re.match("^[a-zA-Z0-9/]+$", target)
|
||||
if storage_type == "dir" or storage_type == "netfs":
|
||||
if not have_symbol:
|
||||
raise forms.ValidationError(
|
||||
_("The target must not contain any special characters")
|
||||
)
|
||||
if storage_type == "dir" or storage_type == "netfs":
|
||||
if not target:
|
||||
raise forms.ValidationError(_("No path has been entered"))
|
||||
have_symbol = re.match("^[^-][a-zA-Z0-9/_-]+$", target) and not re.match(
|
||||
".*/-", target
|
||||
)
|
||||
if storage_type in ["dir", "netfs"] and not have_symbol:
|
||||
raise forms.ValidationError(
|
||||
_("The target must not contain any special characters")
|
||||
)
|
||||
if storage_type in ["dir", "netfs"] and not target:
|
||||
raise forms.ValidationError(_("No path has been entered"))
|
||||
return target
|
||||
|
||||
def clean_source(self):
|
||||
storage_type = self.cleaned_data["stg_type"]
|
||||
source = self.cleaned_data["source"]
|
||||
have_symbol = re.match("^[a-zA-Z0-9\/]+$", source)
|
||||
if storage_type == "logical" or storage_type == "netfs":
|
||||
if storage_type in ["logical", "netfs"]:
|
||||
if not source:
|
||||
raise forms.ValidationError(_("No device or path has been entered"))
|
||||
if not have_symbol:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue