Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
vmdriver
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8455af9c
authored
Sep 03, 2013
by
tarokkk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding deserializers to VM classes
parent
25b22a1e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
vm.py
+14
-0
No files found.
vm.py
View file @
8455af9c
...
@@ -68,6 +68,12 @@ class VMInstance:
...
@@ -68,6 +68,12 @@ class VMInstance:
self
.
seclabel_type
=
seclabel_type
self
.
seclabel_type
=
seclabel_type
self
.
seclabel_mode
=
seclabel_mode
self
.
seclabel_mode
=
seclabel_mode
@classmethod
def
deserialize
(
cls
,
desc
):
desc
[
'disk_list'
]
=
[
VMDisk
.
deserialize
(
d
)
for
d
in
desc
[
'disk_list'
]]
desc
[
'network_list'
]
=
[
VMNetwork
.
deserialize
(
n
)
for
n
in
desc
[
'network_list'
]]
return
cls
(
**
desc
)
def
build_xml
(
self
):
def
build_xml
(
self
):
'''Return the root Element Tree object
'''Return the root Element Tree object
'''
'''
...
@@ -160,6 +166,10 @@ class VMDisk:
...
@@ -160,6 +166,10 @@ class VMDisk:
self
.
driver_cache
=
driver_cache
self
.
driver_cache
=
driver_cache
self
.
target_device
=
target_device
self
.
target_device
=
target_device
@classmethod
def
deserialize
(
cls
,
desc
):
return
cls
(
**
desc
)
def
build_xml
(
self
):
def
build_xml
(
self
):
xml_top
=
ET
.
Element
(
'disk'
,
xml_top
=
ET
.
Element
(
'disk'
,
attrib
=
{
'type'
:
self
.
disk_type
,
attrib
=
{
'type'
:
self
.
disk_type
,
...
@@ -234,6 +244,10 @@ class VMNetwork:
...
@@ -234,6 +244,10 @@ class VMNetwork:
self
.
vlan
=
vlan
self
.
vlan
=
vlan
self
.
managed
=
managed
self
.
managed
=
managed
@classmethod
def
deserialize
(
cls
,
desc
):
return
cls
(
**
desc
)
# XML dump
# XML dump
def
build_xml
(
self
):
def
build_xml
(
self
):
xml_top
=
ET
.
Element
(
'interface'
,
attrib
=
{
'type'
:
self
.
network_type
})
xml_top
=
ET
.
Element
(
'interface'
,
attrib
=
{
'type'
:
self
.
network_type
})
...
...
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