Commit bacf18e7 by Karsa Zoltán István

validation error message

parent c486bc51
......@@ -24,6 +24,7 @@ import yaml
from vm.models import Instance
rng_file = "/usr/share/libvirt/schemas/domain.rng"
# Mandatory xml elements dor parsing
......@@ -57,14 +58,32 @@ def meta_data_validator(value):
try:
Instance.validate_meta_data(value)
except yaml.YAMLError as exc:
raise ValidationError(exc.problem_mark)
if hasattr(exc, 'problem_mark'):
if exc.context != None:
raise ValidationError(' parser says\n' + str(exc.problem_mark) + '\n ' +
str(exc.problem) + ' ' + str(exc.context) +
'\nPlease correct data and retry.')
else:
raise ValidationError(' parser says\n' + str(exc.problem_mark) + '\n ' +
str(exc.problem) + '\nPlease correct data and retry.')
else:
raise ValidationError("Something went wrong while parsing yaml file")
def user_data_validator(value):
try:
Instance.validate_user_data(value)
except yaml.YAMLError as exc:
raise ValidationError(exc.problem_mark)
if hasattr(exc, 'problem_mark'):
if exc.context != None:
raise ValidationError(' parser says\n' + str(exc.problem_mark) + '\n ' +
str(exc.problem) + ' ' + str(exc.context) +
'\nPlease correct data and retry.')
else:
raise ValidationError(' parser says\n' + str(exc.problem_mark) + '\n ' +
str(exc.problem) + '\nPlease correct data and retry.')
else:
raise ValidationError("Something went wrong while parsing yaml file")
def connect_command_template_validator(value):
......
......@@ -70,6 +70,7 @@ from ..forms import (
VmRemoveInterfaceForm,
VmRenameForm,
)
from django.views.generic.edit import FormMixin
from request.models import TemplateAccessType, LeaseType
from request.forms import LeaseRequestForm, TemplateRequestForm
from ..models import Favourite
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment