Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3e865c3b
authored
Jul 21, 2014
by
Guba Sándor
Committed by
Őry Máté
Jul 28, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add basic libvirt domain validator
parent
165eb1d7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
circle/dashboard/virtvalidator.py
+20
-0
No files found.
circle/dashboard/virtvalidator.py
0 → 100644
View file @
3e865c3b
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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment