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
a00ce1bb
authored
Nov 29, 2013
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vmdriver: fixing commits
parent
be56fe09
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
1 deletions
+27
-1
netcelery.py
+1
-1
vm.py
+12
-0
vmcelery.py
+3
-0
vmdriver.py
+11
-0
No files found.
netcelery.py
View file @
a00ce1bb
...
...
@@ -11,7 +11,7 @@ celery = Celery('netdriver', backend='amqp',
include
=
[
'netdriver'
])
celery
.
conf
.
update
(
CELERY_TASK_RESULT_EXPIRES
=
300
,
CELERY_QUEUES
=
(
Queue
(
HOSTNAME
+
'.net'
,
Exchange
(
'netdriver'
,
type
=
'direct'
),
routing_key
=
'netdriver'
),
...
...
vm.py
View file @
a00ce1bb
...
...
@@ -69,6 +69,7 @@ class VMInstance:
self
.
raw_data
=
raw_data
self
.
seclabel_type
=
seclabel_type
self
.
seclabel_mode
=
seclabel_mode
self
.
boot_token
=
boot_token
@classmethod
def
deserialize
(
cls
,
desc
):
...
...
@@ -107,6 +108,17 @@ class VMInstance:
devices
.
append
(
disk
.
build_xml
())
for
network
in
self
.
network_list
:
devices
.
append
(
network
.
build_xml
())
# Serial console
serial
=
ET
.
SubElement
(
devices
,
'console'
,
attrib
=
{
'type'
:
'unix'
})
ET
.
SubElement
(
serial
,
'target'
,
attrib
=
{
'port'
:
'0'
})
ET
.
SubElement
(
serial
,
'source'
,
attrib
=
{
'mode'
:
'bind'
,
'path'
:
'/var/lib/libvirt/serial/
%
s'
%
self
.
name
})
# Console/graphics section
if
self
.
graphics
is
not
None
:
ET
.
SubElement
(
devices
,
...
...
vmcelery.py
View file @
a00ce1bb
...
...
@@ -16,9 +16,12 @@ celery = Celery('vmcelery', backend='amqp',
include
=
[
'vmdriver'
])
celery
.
conf
.
update
(
CELERY_TASK_RESULT_EXPIRES
=
300
,
CELERY_QUEUES
=
(
Queue
(
HOSTNAME
+
'.vm'
,
Exchange
(
'vmdriver'
,
type
=
'direct'
),
routing_key
=
"vmdriver"
),
# Queue(HOSTNAME + '.monitor', Exchange(
# 'monitor', type='direct'), routing_key="monitor"),
)
)
...
...
vmdriver.py
View file @
a00ce1bb
...
...
@@ -3,6 +3,8 @@ import libvirt
import
logging
import
os
import
sys
import
socket
import
json
from
decorator
import
decorator
from
psutil
import
NUM_CPUS
,
virtual_memory
...
...
@@ -174,6 +176,15 @@ def create(vm_desc):
Connection
.
get
()
.
createXML
(
vm
.
dump_xml
(),
libvirt
.
VIR_DOMAIN_START_PAUSED
)
logging
.
info
(
"Virtual machine
%
s is created from xml"
,
vm
.
name
)
# context
try
:
sock
=
socket
.
create_connection
((
'127.0.0.1'
,
1235
),
3
)
data
=
{
'boot_token'
:
vm
.
boot_token
,
'socket'
:
'/var/lib/libvirt/serial/
%
s'
%
vm
.
name
}
sock
.
sendall
(
json
.
dumps
(
data
))
sock
.
close
()
except
socket
.
error
:
logging
.
error
(
'Unable to connect to context server'
)
return
domain_info
(
vm
.
name
)
...
...
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