Commit 87b23a79 by Guba Sándor

added disk/network attach/detach

parent 36847ff2
...@@ -12,7 +12,7 @@ from psutil import NUM_CPUS, virtual_memory, cpu_percent ...@@ -12,7 +12,7 @@ from psutil import NUM_CPUS, virtual_memory, cpu_percent
from celery.contrib.abortable import AbortableTask from celery.contrib.abortable import AbortableTask
from vm import VMInstance from vm import VMInstance, VMDisk, VMNetwork
from vmcelery import celery, lib_connection, to_bool from vmcelery import celery, lib_connection, to_bool
sys.path.append(os.path.dirname(os.path.basename(__file__))) sys.path.append(os.path.dirname(os.path.basename(__file__)))
...@@ -519,8 +519,8 @@ def screenshot(name): ...@@ -519,8 +519,8 @@ def screenshot(name):
stream.recvAll(_stream_handler, fd) stream.recvAll(_stream_handler, fd)
finally: finally:
stream.finish() stream.finish()
#Convert ppm to png # Convert ppm to png
#Seek to the beginning of the stream # Seek to the beginning of the stream
fd.seek(0) fd.seek(0)
# Get the image # Get the image
image = BytesIO() image = BytesIO()
...@@ -547,6 +547,43 @@ def migrate(name, host, live=False): ...@@ -547,6 +547,43 @@ def migrate(name, host, live=False):
@celery.task @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(): def ping():
return True return True
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment