Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
vmdriver
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
2
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f6fe9870
authored
Jul 11, 2013
by
tarokkk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding dump_xml() to VMDisk
parent
83d949f1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
9 deletions
+18
-9
vm.py
+18
-9
No files found.
vm.py
View file @
f6fe9870
...
@@ -42,6 +42,7 @@ class VMDisk:
...
@@ -42,6 +42,7 @@ class VMDisk:
driver_name
=
None
driver_name
=
None
driver_type
=
None
driver_type
=
None
driver_cache
=
None
driver_cache
=
None
target_device
=
None
def
__init__
(
self
,
def
__init__
(
self
,
name
,
name
,
...
@@ -50,7 +51,8 @@ class VMDisk:
...
@@ -50,7 +51,8 @@ class VMDisk:
disk_device
=
"disk"
,
disk_device
=
"disk"
,
driver_name
=
"qemu"
,
driver_name
=
"qemu"
,
driver_type
=
"qcow2"
,
driver_type
=
"qcow2"
,
driver_cache
=
"normal"
):
driver_cache
=
"normal"
,
target_device
=
"dev/vda"
):
self
.
name
=
name
self
.
name
=
name
self
.
source
=
source
self
.
source
=
source
self
.
disk_type
=
disk_type
self
.
disk_type
=
disk_type
...
@@ -58,6 +60,7 @@ class VMDisk:
...
@@ -58,6 +60,7 @@ class VMDisk:
self
.
driver_name
=
driver_name
self
.
driver_name
=
driver_name
self
.
driver_type
=
driver_type
self
.
driver_type
=
driver_type
self
.
driver_cache
=
driver_cache
self
.
driver_cache
=
driver_cache
self
.
target_device
=
target_device
def
dump_xml
(
self
):
def
dump_xml
(
self
):
xml_top
=
ET
.
Element
(
'disk'
,
xml_top
=
ET
.
Element
(
'disk'
,
...
@@ -65,10 +68,17 @@ class VMDisk:
...
@@ -65,10 +68,17 @@ class VMDisk:
'device'
:
self
.
disk_device
})
'device'
:
self
.
disk_device
})
ET
.
SubElement
(
xml_top
,
'source'
,
ET
.
SubElement
(
xml_top
,
'source'
,
attrib
=
{
self
.
disk_type
:
self
.
source
})
attrib
=
{
self
.
disk_type
:
self
.
source
})
ET
.
SubElement
(
xml_top
,
'target'
,
attrib
=
{
'dev'
:
self
.
target_device
})
ET
.
SubElement
(
xml_top
,
'driver'
,
attrib
=
{
'name'
:
self
.
driver_name
,
'type'
:
self
.
driver_type
,
'cache'
:
self
.
driver_cache
})
return
xml_top
class
VMNetwork
:
class
VMNetwork
:
''' Virtual Machine network representing class
''' Virtual Machine network representing class
name -- network device name
name -- network device name
mac -- the MAC address of the quest interface
mac -- the MAC address of the quest interface
...
@@ -106,11 +116,10 @@ class VMNetwork:
...
@@ -106,11 +116,10 @@ class VMNetwork:
ET
.
SubElement
(
xml_top
,
'mac'
,
attrib
=
{
'address'
:
self
.
mac
})
ET
.
SubElement
(
xml_top
,
'mac'
,
attrib
=
{
'address'
:
self
.
mac
})
ET
.
SubElement
(
xml_top
,
'model'
,
attrib
=
{
'type'
:
self
.
model
})
ET
.
SubElement
(
xml_top
,
'model'
,
attrib
=
{
'type'
:
self
.
model
})
ET
.
SubElement
(
xml_top
,
'script'
,
attrib
=
{
'path'
:
self
.
script_exec
})
ET
.
SubElement
(
xml_top
,
'script'
,
attrib
=
{
'path'
:
self
.
script_exec
})
return
ET
.
tostring
(
xml_top
,
return
xml_top
encoding
=
'utf8'
,
method
=
'xml'
,
pretty_print
=
True
)
a
=
VMNetwork
(
name
=
"vm-77"
,
mac
=
"010101"
)
a
=
VMNetwork
(
name
=
"vm-77"
,
mac
=
"010101"
)
print
a
.
dump_xml
()
b
=
VMDisk
(
name
=
"asd"
,
source
=
'/asdasd/adasds/asd'
)
print
ET
.
tostring
(
b
.
dump_xml
(),
encoding
=
'utf8'
,
method
=
'xml'
,
pretty_print
=
True
)
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