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
25b22a1e
authored
Sep 03, 2013
by
tarokkk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changing parameters to match with model
parent
690f8f52
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
12 deletions
+16
-12
vm.py
+16
-12
No files found.
vm.py
View file @
25b22a1e
...
@@ -15,20 +15,19 @@ class VMInstance:
...
@@ -15,20 +15,19 @@ class VMInstance:
network_list
=
list
()
network_list
=
list
()
disk_list
=
list
()
disk_list
=
list
()
graphics
=
dict
graphics
=
dict
context
=
dict
raw_data
=
None
raw_data
=
None
def
__init__
(
self
,
def
__init__
(
self
,
name
,
name
,
vcpu
,
vcpu
,
memory_max
,
memory_max
,
cpu_share
=
"100"
,
memory
=
None
,
cpu_share
=
100
,
arch
=
"x86_64"
,
arch
=
"x86_64"
,
os_boot
=
"hd"
,
boot_menu
=
False
,
vm_type
=
"kvm"
,
vm_type
=
"kvm"
,
network_list
=
None
,
network_list
=
None
,
disk_list
=
None
,
disk_list
=
None
,
context
=
None
,
graphics
=
None
,
graphics
=
None
,
acpi
=
True
,
acpi
=
True
,
raw_data
=
None
,
raw_data
=
None
,
...
@@ -38,13 +37,13 @@ class VMInstance:
...
@@ -38,13 +37,13 @@ class VMInstance:
name - unique name for the instance
name - unique name for the instance
vcpu - nubmer of processors
vcpu - nubmer of processors
memory_max - maximum virtual memory (actual memory maybe add late)
memory_max - maximum virtual memory (actual memory maybe add late)
memory
cpu_share - KVM process priority (0-100)
cpu_share - KVM process priority (0-100)
arch - libvirt arch parameter default x86_64
arch - libvirt arch parameter default x86_64
os_boot - boot device default hd
os_boot - boot device default hd
vm_type - hypervisor type default kvm
vm_type - hypervisor type default kvm
network_list - VMNetwork list
network_list - VMNetwork list
disk_list - VMDIsk list
disk_list - VMDIsk list
context - Key-Value pars (not used)
graphics - Dict that keys are: type, listen, port, passwd
graphics - Dict that keys are: type, listen, port, passwd
acpi - True/False to enable acpi
acpi - True/False to enable acpi
seclabel_type - libvirt security label type
seclabel_type - libvirt security label type
...
@@ -54,12 +53,15 @@ class VMInstance:
...
@@ -54,12 +53,15 @@ class VMInstance:
self
.
vcpu
=
vcpu
self
.
vcpu
=
vcpu
self
.
cpu_share
=
cpu_share
self
.
cpu_share
=
cpu_share
self
.
memory_max
=
memory_max
self
.
memory_max
=
memory_max
if
memory
is
None
:
self
.
memory
=
memory_max
else
:
self
.
memory
=
memory
self
.
arch
=
arch
self
.
arch
=
arch
self
.
os_boot
=
os_boot
self
.
boot_menu
=
boot_menu
self
.
vm_type
=
vm_type
self
.
vm_type
=
vm_type
self
.
network_list
=
network_list
self
.
network_list
=
network_list
self
.
disk_list
=
disk_list
self
.
disk_list
=
disk_list
self
.
conext
=
context
self
.
graphics
=
graphics
self
.
graphics
=
graphics
self
.
acpi
=
acpi
self
.
acpi
=
acpi
self
.
raw_data
=
raw_data
self
.
raw_data
=
raw_data
...
@@ -78,15 +80,17 @@ class VMInstance:
...
@@ -78,15 +80,17 @@ class VMInstance:
})
})
# Basic virtual machine paramaters
# Basic virtual machine paramaters
ET
.
SubElement
(
xml_top
,
'name'
)
.
text
=
self
.
name
ET
.
SubElement
(
xml_top
,
'name'
)
.
text
=
self
.
name
ET
.
SubElement
(
xml_top
,
'vcpu'
)
.
text
=
self
.
vcpu
ET
.
SubElement
(
xml_top
,
'vcpu'
)
.
text
=
str
(
self
.
vcpu
)
ET
.
SubElement
(
xml_top
,
'memory'
)
.
text
=
self
.
memory_max
ET
.
SubElement
(
xml_top
,
'memory'
)
.
text
=
str
(
self
.
memory_max
)
ET
.
SubElement
(
xml_top
,
'currentMemory'
)
.
text
=
str
(
self
.
memory
)
# Cpu tune
# Cpu tune
cputune
=
ET
.
SubElement
(
xml_top
,
'cputune'
)
cputune
=
ET
.
SubElement
(
xml_top
,
'cputune'
)
ET
.
SubElement
(
cputune
,
'shares'
)
.
text
=
s
elf
.
cpu_share
ET
.
SubElement
(
cputune
,
'shares'
)
.
text
=
s
tr
(
self
.
cpu_share
)
# Os specific options
# Os specific options
os
=
ET
.
SubElement
(
xml_top
,
'os'
)
os
=
ET
.
SubElement
(
xml_top
,
'os'
)
ET
.
SubElement
(
os
,
'type'
,
attrib
=
{
'arch'
:
self
.
arch
})
.
text
=
"hvm"
ET
.
SubElement
(
os
,
'type'
,
attrib
=
{
'arch'
:
self
.
arch
})
.
text
=
"hvm"
ET
.
SubElement
(
os
,
'boot'
,
attrib
=
{
'dev'
:
self
.
os_boot
})
ET
.
SubElement
(
os
,
'bootmenu'
,
attrib
=
{
'enable'
:
"yes"
if
self
.
boot_menu
else
"no"
})
# Devices
# Devices
devices
=
ET
.
SubElement
(
xml_top
,
'devices'
)
devices
=
ET
.
SubElement
(
xml_top
,
'devices'
)
ET
.
SubElement
(
devices
,
'emulator'
)
.
text
=
'/usr/bin/kvm'
ET
.
SubElement
(
devices
,
'emulator'
)
.
text
=
'/usr/bin/kvm'
...
@@ -210,8 +214,8 @@ class VMNetwork:
...
@@ -210,8 +214,8 @@ class VMNetwork:
def
__init__
(
self
,
def
__init__
(
self
,
name
,
name
,
bridge
,
mac
,
mac
,
bridge
=
"cloud"
,
ipv4
=
None
,
ipv4
=
None
,
ipv6
=
None
,
ipv6
=
None
,
network_type
=
'ethernet'
,
network_type
=
'ethernet'
,
...
...
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