Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
e433937a
authored
Jun 26, 2013
by
tarokkk
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'vmdriver'
parents
67dab7f2
c31095cb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
0 deletions
+56
-0
miscellaneous/vmdriver/vm.py
+56
-0
No files found.
miscellaneous/vmdriver/vm.py
0 → 100755
View file @
e433937a
#!/usr/bin/env python
import
lxml.etree
as
ET
# VM Instance class
class
VMInstance
:
name
=
None
vcpu
=
None
cpu_share
=
None
memory_max
=
None
network_list
=
list
()
disk_list
=
list
()
context
=
dict
()
class
VMNetwork
:
''' Virtual Machine network representing class
name -- network device name
mac -- the MAC address of the quest interface
network_type -- need to be "ethernet" by default
model -- available models in libvirt
QoS -- CIRCLE QoS class?
script -- Executable network script /bin/true by default
'''
# Class attributes
name
=
None
network_type
=
None
mac
=
None
model
=
None
QoS
=
None
script_exec
=
'/bin/true'
def
__init__
(
self
,
name
,
mac
,
network_type
=
'ethernet'
,
model
=
'virtio'
,
QoS
=
None
):
self
.
name
=
name
self
.
network_type
=
network_type
self
.
mac
=
mac
self
.
model
=
model
self
.
QoS
=
QoS
# XML dump
def
dump_xml
(
self
):
xml_top
=
ET
.
Element
(
'interface'
,
attrib
=
{
'type'
:
self
.
network_type
})
ET
.
SubElement
(
xml_top
,
'target'
,
attrib
=
{
'dev'
:
self
.
name
})
ET
.
SubElement
(
xml_top
,
'mac'
,
attrib
=
{
'address'
:
self
.
mac
})
ET
.
SubElement
(
xml_top
,
'model'
,
attrib
=
{
'type'
:
self
.
model
})
ET
.
SubElement
(
xml_top
,
'script'
,
attrib
=
{
'path'
:
self
.
script_exec
})
return
ET
.
tostring
(
xml_top
,
encoding
=
'utf8'
,
method
=
'xml'
,
pretty_print
=
True
)
class
VMDisk
:
disk_type
=
None
disk_driver
=
None
source
=
None
target
=
None
a
=
VMNetwork
(
name
=
"vm-77"
,
mac
=
"010101"
)
print
a
.
dump_xml
()
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