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
87b23a79
authored
Jul 14, 2014
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added disk/network attach/detach
parent
36847ff2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
3 deletions
+40
-3
vmdriver.py
+40
-3
No files found.
vmdriver.py
View file @
87b23a79
...
...
@@ -12,7 +12,7 @@ from psutil import NUM_CPUS, virtual_memory, cpu_percent
from
celery.contrib.abortable
import
AbortableTask
from
vm
import
VMInstance
from
vm
import
VMInstance
,
VMDisk
,
VMNetwork
from
vmcelery
import
celery
,
lib_connection
,
to_bool
sys
.
path
.
append
(
os
.
path
.
dirname
(
os
.
path
.
basename
(
__file__
)))
...
...
@@ -519,8 +519,8 @@ def screenshot(name):
stream
.
recvAll
(
_stream_handler
,
fd
)
finally
:
stream
.
finish
()
#Convert ppm to png
#Seek to the beginning of the stream
#
Convert ppm to png
#
Seek to the beginning of the stream
fd
.
seek
(
0
)
# Get the image
image
=
BytesIO
()
...
...
@@ -547,6 +547,43 @@ def migrate(name, host, live=False):
@celery.task
@req_connection
@wrap_libvirtError
def
attach_disk
(
name
,
disk
):
domain
=
lookupByName
(
name
)
disk
=
VMDisk
.
deserialize
(
disk
)
domain
.
attachDevice
(
disk
.
dump_xml
())
@celery.task
@req_connection
@wrap_libvirtError
def
detach_disk
(
name
,
disk
):
domain
=
lookupByName
(
name
)
disk
=
VMDisk
.
deserialize
(
disk
)
domain
.
detachDevice
(
disk
.
dump_xml
())
@celery.task
@req_connection
@wrap_libvirtError
def
attach_network
(
name
,
net
):
domain
=
lookupByName
(
name
)
net
=
VMNetwork
.
deserialize
(
net
)
logging
.
error
(
net
.
dump_xml
())
domain
.
attachDevice
(
net
.
dump_xml
())
@celery.task
@req_connection
@wrap_libvirtError
def
detach_network
(
name
,
net
):
domain
=
lookupByName
(
name
)
net
=
VMNetwork
.
deserialize
(
net
)
domain
.
detachDevice
(
net
.
dump_xml
())
@celery.task
def
ping
():
return
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