Commit 3e865c3b by Guba Sándor Committed by Őry Máté

dashboard: add basic libvirt domain validator

parent 165eb1d7
from django.core.exceptions import ValidationError
from lxml import etree as ET
rng_file = "/usr/share/libvirt/schemas/domain.rng"
header = """<domain type='kvm'>
<name>validator</name>
<memory unit='KiB'>1024</memory>
<os>
<type>hvm</type>
</os>"""
footer = """</domain>"""
def domain_validator(value):
xml = header + value + footer
relaxng = ET.RelaxNG(file=rng_file)
if not relaxng.validate(ET.fromstring(xml)):
raise ValidationError("%s is not valid libvirt Domain xml." % value)
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