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
f7af8615
authored
Aug 15, 2013
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding celery annotations
parent
ea4f921b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
vmdriver.py
+21
-0
No files found.
vmdriver.py
View file @
f7af8615
...
@@ -4,6 +4,7 @@ import libvirt
...
@@ -4,6 +4,7 @@ import libvirt
import
logging
import
logging
import
os
import
os
from
decorator
import
decorator
from
decorator
import
decorator
from
vmcelery
import
celery
connection
=
None
connection
=
None
...
@@ -40,6 +41,7 @@ def req_connection(original_function, *args, **kw):
...
@@ -40,6 +41,7 @@ def req_connection(original_function, *args, **kw):
return
return_value
return
return_value
@celery.task
def
connect
(
connection_string
=
'qemu:///system'
):
def
connect
(
connection_string
=
'qemu:///system'
):
'''Connect to the libvirt daemon specified in the
'''Connect to the libvirt daemon specified in the
connection_string or the local root.
connection_string or the local root.
...
@@ -52,6 +54,7 @@ def connect(connection_string='qemu:///system'):
...
@@ -52,6 +54,7 @@ def connect(connection_string='qemu:///system'):
logging
.
error
(
"There is already an active connection to libvirt."
)
logging
.
error
(
"There is already an active connection to libvirt."
)
@celery.task
def
disconnect
():
def
disconnect
():
'''Disconnect from the active libvirt daemon connection.
'''Disconnect from the active libvirt daemon connection.
'''
'''
...
@@ -64,6 +67,7 @@ def disconnect():
...
@@ -64,6 +67,7 @@ def disconnect():
connection
=
None
connection
=
None
@celery.task
@req_connection
@req_connection
def
define
(
vm
):
def
define
(
vm
):
'''Define permanent virtual machine from xml
'''Define permanent virtual machine from xml
...
@@ -72,6 +76,7 @@ def define(vm):
...
@@ -72,6 +76,7 @@ def define(vm):
logging
.
info
(
"Virtual machine
%
s is defined from xml"
,
vm
.
name
)
logging
.
info
(
"Virtual machine
%
s is defined from xml"
,
vm
.
name
)
@celery.task
@req_connection
@req_connection
def
create
(
vm
):
def
create
(
vm
):
'''Create and start non-permanent virtual machine from xml
'''Create and start non-permanent virtual machine from xml
...
@@ -86,6 +91,7 @@ def create(vm):
...
@@ -86,6 +91,7 @@ def create(vm):
logging
.
info
(
"Virtual machine
%
s is created from xml"
,
vm
.
name
)
logging
.
info
(
"Virtual machine
%
s is created from xml"
,
vm
.
name
)
@celery.task
@req_connection
@req_connection
def
delete
(
name
):
def
delete
(
name
):
'''Destroy the running called 'name' virtual machine.
'''Destroy the running called 'name' virtual machine.
...
@@ -94,6 +100,7 @@ def delete(name):
...
@@ -94,6 +100,7 @@ def delete(name):
domain
.
destroy
()
domain
.
destroy
()
@celery.task
@req_connection
@req_connection
def
list_domains
():
def
list_domains
():
'''
'''
...
@@ -106,6 +113,7 @@ def list_domains():
...
@@ -106,6 +113,7 @@ def list_domains():
return
domain_list
return
domain_list
@celery.task
@req_connection
@req_connection
def
lookupByName
(
name
):
def
lookupByName
(
name
):
'''Return with the requested Domain
'''Return with the requested Domain
...
@@ -116,6 +124,7 @@ def lookupByName(name):
...
@@ -116,6 +124,7 @@ def lookupByName(name):
logging
.
error
(
e
.
get_error_message
())
logging
.
error
(
e
.
get_error_message
())
@celery.task
@req_connection
@req_connection
def
undefine
(
name
):
def
undefine
(
name
):
'''Undefine an already defined virtual machine.
'''Undefine an already defined virtual machine.
...
@@ -125,6 +134,7 @@ def undefine(name):
...
@@ -125,6 +134,7 @@ def undefine(name):
domain
.
undefine
()
domain
.
undefine
()
@celery.task
@req_connection
@req_connection
def
start
(
name
):
def
start
(
name
):
'''Start an already defined virtual machine.
'''Start an already defined virtual machine.
...
@@ -133,6 +143,7 @@ def start(name):
...
@@ -133,6 +143,7 @@ def start(name):
domain
.
create
()
domain
.
create
()
@celery.task
@req_connection
@req_connection
def
save
(
name
,
path
):
def
save
(
name
,
path
):
'''Stop virtual machine and save its memory to path.
'''Stop virtual machine and save its memory to path.
...
@@ -141,6 +152,7 @@ def save(name, path):
...
@@ -141,6 +152,7 @@ def save(name, path):
domain
.
save
(
path
)
domain
.
save
(
path
)
@celery.task
@req_connection
@req_connection
def
restore
(
path
):
def
restore
(
path
):
'''Restore a saved virtual machine
'''Restore a saved virtual machine
...
@@ -148,6 +160,7 @@ def restore(path):
...
@@ -148,6 +160,7 @@ def restore(path):
connection
.
restore
(
path
)
connection
.
restore
(
path
)
@celery.task
@req_connection
@req_connection
def
resume
(
name
):
def
resume
(
name
):
'''Resume stopped virtual machines.
'''Resume stopped virtual machines.
...
@@ -156,6 +169,7 @@ def resume(name):
...
@@ -156,6 +169,7 @@ def resume(name):
domain
.
resume
()
domain
.
resume
()
@celery.task
@req_connection
@req_connection
def
reset
(
name
):
def
reset
(
name
):
'''Reset (power reset) virtual machine.
'''Reset (power reset) virtual machine.
...
@@ -164,6 +178,7 @@ def reset(name):
...
@@ -164,6 +178,7 @@ def reset(name):
domain
.
reset
()
domain
.
reset
()
@celery.task
@req_connection
@req_connection
def
reboot
(
name
):
def
reboot
(
name
):
'''Reboot (with guest acpi support) virtual machine.
'''Reboot (with guest acpi support) virtual machine.
...
@@ -172,6 +187,7 @@ def reboot(name):
...
@@ -172,6 +187,7 @@ def reboot(name):
domain
.
reboot
()
domain
.
reboot
()
@celery.task
@req_connection
@req_connection
def
node_info
():
def
node_info
():
''' Get info from Host as dict:
''' Get info from Host as dict:
...
@@ -194,6 +210,7 @@ def node_info():
...
@@ -194,6 +210,7 @@ def node_info():
return
dict
(
zip
(
keys
,
values
))
return
dict
(
zip
(
keys
,
values
))
@celery.task
@req_connection
@req_connection
def
domain_info
(
name
):
def
domain_info
(
name
):
'''
'''
...
@@ -212,6 +229,7 @@ def domain_info(name):
...
@@ -212,6 +229,7 @@ def domain_info(name):
return
info
return
info
@celery.task
@req_connection
@req_connection
def
network_info
(
name
,
network
):
def
network_info
(
name
,
network
):
'''
'''
...
@@ -232,6 +250,7 @@ def network_info(name, network):
...
@@ -232,6 +250,7 @@ def network_info(name, network):
return
info
return
info
@celery.task
@req_connection
@req_connection
def
send_key
(
name
,
key_code
):
def
send_key
(
name
,
key_code
):
''' Sending linux key_code to the name vm
''' Sending linux key_code to the name vm
...
@@ -247,6 +266,7 @@ def _stream_handler(stream, buf, opaque):
...
@@ -247,6 +266,7 @@ def _stream_handler(stream, buf, opaque):
os
.
write
(
fd
,
buf
)
os
.
write
(
fd
,
buf
)
@celery.task
@req_connection
@req_connection
def
screenshot
(
name
,
path
):
def
screenshot
(
name
,
path
):
"""Save screenshot of virtual machine
"""Save screenshot of virtual machine
...
@@ -275,6 +295,7 @@ def screenshot(name, path):
...
@@ -275,6 +295,7 @@ def screenshot(name, path):
os
.
close
(
fd
)
os
.
close
(
fd
)
@celery.task
@req_connection
@req_connection
def
migrate
(
name
,
host
,
live
=
False
):
def
migrate
(
name
,
host
,
live
=
False
):
'''Migrate domain to host'''
'''Migrate domain to host'''
...
...
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